casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
WCConcatenation.h
Go to the documentation of this file.
00001 //# WCConcatenation.h: Combine multiple ImageRegion's into a new dimension
00002 //# Copyright (C) 1998
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: WCConcatenation.h 20615 2009-06-09 02:16:01Z Malte.Marquarding $
00027 
00028 #ifndef IMAGES_WCCONCATENATION_H
00029 #define IMAGES_WCCONCATENATION_H
00030 
00031 //# Includes
00032 #include <images/Regions/WCCompound.h>
00033 #include <images/Regions/WCBox.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // Combine multiple ImageRegion's into a new dimension.
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="" date="" tests="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> <linkto class=WCCompound>WCCompound</linkto>
00049 // </prerequisite>
00050 
00051 // <synopsis> 
00052 // The WCConcatenation class is a specialization of class
00053 // <linkto class=WCCompound>WCCompound</linkto>.
00054 // It makes it possible to combine multiple regions and to add a
00055 // dimension on them. The axis and the range (beginning and end)
00056 // of that new dimension have to be specified using an
00057 // <linkto class=WCBox>WCBox</linkto> object.
00058 // That axes should not be an axis in the given regions.
00059 // <p>
00060 // WCConcatenation can be seen as a mixture of the classes
00061 // <linkto class=WCUnion>WCUnion</linkto> and
00062 // <linkto class=WCExtension>WCExtension</linkto>. Like WCUnion it
00063 // combines regions and like WCExtension it increases the dimensionality
00064 // for the new region (be it with only 1).
00065 // <br>
00066 // Unlike WCUnion the axes have to be the same in all regions,
00067 // because creating a WCConcatenation means combining similar regions.
00068 // <p>
00069 // E.g. One can define a different polygon in the RA-DEC plane of each
00070 // channel. WCConcatenation makes it possible to combine the polygons
00071 // to one 3D region in the RA-DEC-Freq cube.
00072 // </synopsis> 
00073 
00074 // <example>
00075 // This example combines <src>n</src> (relative) circles 
00076 // given in the RA,DEC plane along the FREQ-axis.
00077 // In this example the regions used are circles with the same centers,
00078 // but it is also  possible to combine differently shaped regions.
00079 // Note that WCConcatenation takes over the pointers to the individual regions,
00080 // so they do not need to be deleted (the WCConcatenation destructor does it).
00081 // <srcblock>
00082 // IPosition center (2,10,20);
00083 // PtrBlock<ImageRegion*> cirPtr(n);
00084 // for (i=0; i<n; i++) {
00085 //   // Each circle has a different radius.
00086 //   cirPtr(i) = new WCEllipsoid cir1 (center, 1 + i%(n/2));
00087 // }
00088 // // Construct the concatenation for a range (given as a box in fractions).
00089 // // Extend along the FREQ-axis (the 2nd axis in the given cSys)..
00090 // // Take over the region pointers.
00091 // Vector<Quantity> blc(1);
00092 // Vector<Quantity> trc(1);
00093 // blc(0) = Quantity (0.25, "frac");
00094 // trc(0) = Quantity (0.75, "frac");
00095 // WCConcatenation region (True, cirPtr, WCBox(blc, trc, cSys, IPosition(1,2));
00096 // </srcblock>
00097 // This example is artificial in the sense that WCEllipsoid does not
00098 // exist yet and the WCBox constructor looks a bit different.
00099 // One should probably also do a bit more trouble to find out if FREQ
00100 // is indeed the 2nd axis in the coordinate system.
00101 // </example>
00102 
00103 //# <todo asof="1997/11/11">
00104 //# <li> 
00105 //# </todo>
00106 
00107 
00108 class WCConcatenation: public WCCompound
00109 {
00110 public:
00111     // Combine the given regions.
00112     // When <src>takeOver</src> is True, the destructor will delete the
00113     // given regions. Otherwise a copy of the regions is made.
00114     // The extend range has to be given as a 1-dimensional box.
00115     // <group>
00116     WCConcatenation (const PtrBlock<const ImageRegion*>& regions,
00117                      const WCBox& extendRange);
00118     WCConcatenation (Bool takeOver, const PtrBlock<const WCRegion*>& regions,
00119                      const WCBox& extendRange);
00120     // </group>
00121 
00122     // Copy constructor (copy semantics).
00123     WCConcatenation (const WCConcatenation& other);
00124 
00125     virtual ~WCConcatenation();
00126 
00127     // Assignment (copy semantics).
00128     WCConcatenation& operator= (const WCConcatenation& other);
00129 
00130     // Comparison
00131     virtual Bool operator== (const WCRegion& other) const;
00132 
00133     // Make a copy of the derived object.
00134     virtual WCRegion* cloneRegion() const;
00135 
00136     // Get the class name (to store in the record).
00137     static String className();
00138 
00139     // Get the region type.  Returns className()
00140     virtual String type() const;
00141 
00142     // Convert the (derived) object to a record.
00143     virtual TableRecord toRecord (const String& tableName) const;
00144 
00145     // Convert correct object from a record.
00146     static WCConcatenation* fromRecord (const TableRecord&,
00147                                         const String& tableName);
00148 
00149 protected:
00150     // Convert to an LCRegion using the given coordinate system and shape.
00151     // pixelAxesMap(i) gives the pixel axis in cSys of axes <src>i</src>
00152     // in the axesDesc.
00153     virtual LCRegion* doToLCRegion (const CoordinateSystem& cSys,
00154                                     const IPosition& shape,
00155                                     const IPosition& pixelAxesMap,
00156                                     const IPosition& outOrder) const;
00157 
00158 private:
00159     // Do a check and fill the remainder of the object.
00160     void fill();
00161 
00162     //# Variables
00163     WCBox itsExtendBox;
00164 };
00165 
00166 
00167 
00168 } //# NAMESPACE CASA - END
00169 
00170 #endif