00001 //# LCConcatenation.h: Combine multiple LCRegion'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 LATTICES_LCCONCATENATION_H 00029 #define LATTICES_LCCONCATENATION_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/lattices/LRegions/LCRegionMulti.h> 00034 #include <casacore/lattices/LRegions/LCBox.h> 00035 00036 00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00038 00039 // <summary> 00040 // Combine multiple LCRegion'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=LCRegion>LCRegion</linkto> 00050 // </prerequisite> 00051 00052 // <synopsis> 00053 // The LCConcatenation class is a specialization of class 00054 // <linkto class=LCRegion>LCRegion</linkto>. 00055 // It makes it possible to combine multiple LCRegion's and to add a 00056 // dimension on them. The range (beginning and end) in that new 00057 // dimension have to be specified using an 00058 // <linkto class=LCBox>LCBox</linkto> object. 00059 // When the LCBox is complete, it will be checked if the given number 00060 // of regions matches the length of the given range (so it could only 00061 // be done after the makeComplete call). 00062 // Using a fractional box does not make much sense, because it results 00063 // in a varying length range when used with varying shaped lattices. 00064 // However, one can use it if wanted. 00065 // <br> 00066 // LCConcatenation can be seen as a mixture of the classes 00067 // <linkto class=LCUnion>LCUnion</linkto> and 00068 // <linkto class=LCExtension>LCExtension</linkto>. Like LCUnion it 00069 // combines regions and like LCExtension it increases the dimensionality 00070 // for the new region (be it with only 1). 00071 // <br> 00072 // E.g. One can define a different polygon in the RA-DEC plane of each 00073 // channel. LCConcatenation makes it possible to combine the polygons 00074 // to one 3D region in the RA-DEC-Freq cube. 00075 // </synopsis> 00076 00077 // <example> 00078 // This example combines <src>n</src> (relative) circles 00079 // given in the x-z plane along the y-axis. 00080 // In this example the regions used are circles with the same centers, 00081 // but it is also possible to combine differently shaped regions. 00082 // Note that LCConcatenation takes over the pointers to the individual regions, 00083 // so they do not need to be deleted (the LCConcatenation destructor does it). 00084 // <srcblock> 00085 // IPosition center (2,10,20); 00086 // PtrBlock<LCRegion*> cirPtr(n); 00087 // for (i=0; i<n; i++) { 00088 // // Each circle has a different radius. 00089 // cirPtr(i) = new LCEllipsoid cir1 (center, 1 + i%(n/2)); 00090 // } 00091 // // Construct the concatenation for a range (given as a relative box). 00092 // // Extend along the y-axis (axis numbers start counting at 0!). 00093 // // Take over the region pointers. 00094 // LCConcatenation region (True, cirPtr, 1, LCBox(n/2-n, n/2-1)); 00095 // </srcblock> 00096 // </example> 00097 00098 //# <todo asof="1997/11/11"> 00099 //# <li> 00100 //# </todo> 00101 00102 class LCConcatenation: public LCRegionMulti 00103 { 00104 public: 00105 LCConcatenation(); 00106 00107 // Combine the given regions. 00108 // When <src>takeOver</src> is True, the destructor will delete the 00109 // given regions. Otherwise a copy of the regions is made. 00110 // The extend range has to be given as a 1-dimensional box. 00111 // The default range is the entire axis. 00112 // <group> 00113 LCConcatenation (Bool takeOver, const PtrBlock<const LCRegion*>& regions, 00114 Int extendAxis); 00115 LCConcatenation (Bool takeOver, const PtrBlock<const LCRegion*>& regions, 00116 Int extendAxis, const LCBox& extendRange); 00117 // </group> 00118 00119 // Copy constructor (copy semantics). 00120 LCConcatenation (const LCConcatenation& other); 00121 00122 virtual ~LCConcatenation(); 00123 00124 // Assignment (copy semantics). 00125 LCConcatenation& operator= (const LCConcatenation& other); 00126 00127 // Comparison 00128 virtual Bool operator== (const LCRegion& other) const; 00129 00130 // Make a copy of the derived object. 00131 virtual LCRegion* cloneRegion() const; 00132 00133 // Get the extend axis. 00134 Int extendAxis() const; 00135 00136 // Get the extend box. 00137 const LCBox& extendBox() const; 00138 00139 // Get the class name (to store in the record). 00140 static String className(); 00141 00142 // Get the region type. Returns the class name. 00143 virtual String type() const; 00144 00145 // Convert the (derived) object to a record. 00146 virtual TableRecord toRecord (const String& tableName) const; 00147 00148 // Convert correct object from a record. 00149 static LCConcatenation* fromRecord (const TableRecord&, 00150 const String& tableName); 00151 00152 protected: 00153 // Construct another LCRegion (for e.g. another lattice) by moving 00154 // this one. It recalculates the bounding box and mask. 00155 // A positive translation value indicates "to right". 00156 virtual LCRegion* doTranslate (const Vector<Float>& translateVector, 00157 const IPosition& newLatticeShape) const; 00158 00159 // Do the actual getting of the mask. 00160 virtual void multiGetSlice (Array<Bool>& buffer, const Slicer& section); 00161 00162 // This function is needed here because the niceCursorShape of the 00163 // contributing region does not make any sense (other dimensionality). 00164 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00165 00166 private: 00167 // Fill the object. 00168 // <group> 00169 void fillRegionAxes(); 00170 void fill(); 00171 // </group> 00172 00173 Int itsExtendAxis; 00174 IPosition itsRegionAxes; 00175 LCBox itsExtendBox; 00176 }; 00177 00178 00179 inline Int LCConcatenation::extendAxis() const 00180 { 00181 return itsExtendAxis; 00182 } 00183 inline const LCBox& LCConcatenation::extendBox() const 00184 { 00185 return itsExtendBox; 00186 } 00187 00188 00189 00190 } //# NAMESPACE CASACORE - END 00191 00192 #endif