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