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