casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
WCCompound.h
Go to the documentation of this file.
00001 //# WCCompound.h: Base class for compound WCRegion objects
00002 //# Copyright (C) 1998,1999,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: WCCompound.h 20615 2009-06-09 02:16:01Z Malte.Marquarding $
00027 
00028 #ifndef IMAGES_WCCOMPOUND_H
00029 #define IMAGES_WCCOMPOUND_H
00030 
00031 //# Includes
00032 #include <images/Regions/WCRegion.h>
00033 #include <casa/Containers/Block.h>
00034 #include <casa/Arrays/IPosition.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class ImageRegion;
00040 class LCRegion;
00041 class CoordinateSystem;
00042 class RecordInterface;
00043 class TableRecord;
00044 class String;
00045 
00046 
00047 // <summary>
00048 // Base class for compound WCRegion objects.
00049 // </summary>
00050 
00051 // <use visibility=local>
00052 
00053 // <reviewed reviewer="" date="" tests="">
00054 // </reviewed>
00055 
00056 // <prerequisite>
00057 //   <li> <linkto class=WCRegion>WCRegion</linkto>
00058 // </prerequisite>
00059 
00060 // <synopsis> 
00061 // WCCompound is the base class for world coordinate regions.
00062 // It defines the functionality simply as conversion to an LCRegion.
00063 // This is because you need an LCRegion to be able to access the
00064 // pixels in a Lattice.
00065 
00066 // The conversion functions should be flexible in that the
00067 // supplied CoordinateSystem does not have to be the same
00068 // as that with which the derived class was constructed. 
00069 // This means that you can apply a WCCompound from one image
00070 // to another, provided that operation has some meaning.
00071 // </synopsis> 
00072 
00073 // <example>
00074 // <srcblock>
00075 // </srcblock>
00076 // </example>
00077 
00078 //# <todo asof="1997/11/11">
00079 //# <li>
00080 //# </todo>
00081 
00082 
00083 class WCCompound : public WCRegion
00084 {
00085 public:
00086     // Construct from one or more image regions.
00087     // The image regions have to contain WCRegion objects, otherwise an
00088     // exception is thrown.
00089     // <group>
00090     WCCompound (const ImageRegion& region1, const ImageRegion& region2);
00091     WCCompound (const ImageRegion* region1,
00092                 const ImageRegion* region2 = 0,
00093                 const ImageRegion* region3 = 0,
00094                 const ImageRegion* region4 = 0,
00095                 const ImageRegion* region5 = 0,
00096                 const ImageRegion* region6 = 0,
00097                 const ImageRegion* region7 = 0,
00098                 const ImageRegion* region8 = 0,
00099                 const ImageRegion* region9 = 0,
00100                 const ImageRegion* region10 = 0);
00101     WCCompound (const PtrBlock<const ImageRegion*>& regions);
00102     // </group>
00103 
00104     // Construct from multiple regions given as a Block.
00105     // When <src>takeOver</src> is True, the destructor will delete the
00106     // given regions. Otherwise a copy of the regions is made.
00107     WCCompound (Bool takeOver, const PtrBlock<const WCRegion*>& regions);
00108 
00109     // Copy constructor (copy semantics).
00110     WCCompound (const WCCompound& other);
00111 
00112     virtual ~WCCompound();
00113 
00114     // Comparison
00115     virtual Bool operator==(const WCRegion& other) const;
00116 
00117     // Get the contributing regions.
00118     const PtrBlock<const WCRegion*>& regions() const;
00119     
00120 protected:
00121     // Assignment (copy semantics) makes only sense for a derived class.
00122     WCCompound& operator= (const WCCompound& other);
00123 
00124     // Convert each WCRegion to an LCRegion.
00125     // The axes argument tells which axes to use from the coordinate
00126     // system and shape.
00127     void multiToLCRegion (PtrBlock<const LCRegion*>& regions,
00128                           const CoordinateSystem& cSys,
00129                           const IPosition& shape,
00130                           const IPosition& pixelAxesMap,
00131                           const IPosition& extendAxes) const;
00132 
00133     // Store the contributing regions in a record.
00134     TableRecord makeRecord (const String& tableName) const;
00135 
00136     // Retrieve the contributing objects from the record.
00137     static void unmakeRecord (PtrBlock<const WCRegion*>&,
00138                               const TableRecord&,
00139                               const String& tableName);
00140 
00141 private:
00142     // Check if the ImageRegion's contain WCRegion's and extract them.
00143     void makeWCRegion (const PtrBlock<const ImageRegion*>&);
00144 
00145     // Check if the regions are correct.
00146     // If needed, make a copy of the region objects.
00147     void init (Bool takeOver);
00148 
00149     //# Member variables.
00150     PtrBlock<const WCRegion*> itsRegions;
00151     Block<IPosition>          itsAxesUsed;
00152 };
00153 
00154 
00155 inline const PtrBlock<const WCRegion*>& WCCompound::regions() const
00156 {
00157     return itsRegions;
00158 }
00159 
00160 
00161 
00162 } //# NAMESPACE CASA - END
00163 
00164 #endif