LCRegionMulti.h

Go to the documentation of this file.
00001 //# LCRegionMulti.h: Make the intersection of 2 or more regions
00002 //# Copyright (C) 1998,1999
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_LCREGIONMULTI_H
00029 #define LATTICES_LCREGIONMULTI_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/lattices/LRegions/LCRegion.h>
00034 #include <casacore/casa/Arrays/IPosition.h>
00035 #include <casacore/casa/Containers/Block.h>
00036 
00037 
00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00039 
00040 // <summary>
00041 // Make the intersection of 2 or more regions.
00042 // </summary>
00043 
00044 // <use visibility=export>
00045 
00046 // <reviewed reviewer="" date="" tests="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class=LCRegion>LCRegion</linkto>
00051 // </prerequisite>
00052 
00053 // <synopsis> 
00054 // The LCRegionMulti class is a specialization of class
00055 // <linkto class=LCRegion>LCRegion</linkto>.
00056 // It makes it possible to extend a LCRegion along straight lines to
00057 // other dimensions. E.g. a circle in the xy-plane can be extended to
00058 // a cylinder in the xyz-space.
00059 // includes the intersection border.
00060 // It can only be used for a lattice of any dimensionality as long as the
00061 // dimensionality of the (hyper-)intersection matches the dimensionality of
00062 // the lattice.
00063 // <p>
00064 // The center of the intersection must be inside the lattice
00065 // </synopsis> 
00066 
00067 // <example>
00068 // <srcblock>
00069 // </srcblock>
00070 // </example>
00071 
00072 // <todo asof="1997/11/11">
00073 // <li>
00074 // </todo>
00075 
00076 class LCRegionMulti: public LCRegion
00077 {
00078 public:
00079     LCRegionMulti();
00080 
00081     // Construct from 2 regions.
00082     LCRegionMulti (const LCRegion& region1, const LCRegion& region2);
00083 
00084     // Construct from multiple regions.
00085     LCRegionMulti (Bool takeOver, const LCRegion* region1,
00086                    const LCRegion* region2 = 0,
00087                    const LCRegion* region3 = 0,
00088                    const LCRegion* region4 = 0,
00089                    const LCRegion* region5 = 0,
00090                    const LCRegion* region6 = 0,
00091                    const LCRegion* region7 = 0,
00092                    const LCRegion* region8 = 0,
00093                    const LCRegion* region9 = 0,
00094                    const LCRegion* region10 = 0);
00095 
00096     // Construct from multiple regions given as a Block.
00097     // When <src>takeOver</src> is True, the destructor will delete the
00098     // given regions. Otherwise a copy of the regions is made.
00099     LCRegionMulti (Bool takeOver, const PtrBlock<const LCRegion*>& regions);
00100 
00101     // Copy constructor (copy semantics).
00102     LCRegionMulti (const LCRegionMulti& other);
00103 
00104     virtual ~LCRegionMulti();
00105 
00106     // Assignment (copy semantics).
00107     LCRegionMulti& operator= (const LCRegionMulti& other);
00108 
00109     // Comparison 
00110     virtual Bool operator== (const LCRegion& other) const;
00111 
00112     // Does the region have a mask?
00113     virtual Bool hasMask() const;
00114 
00115 protected:
00116     // Store the contributing regions in a record.
00117     TableRecord makeRecord (const String& tableName) const;
00118 
00119     // Retrieve the contributing objects from the record.
00120     static void unmakeRecord (PtrBlock<const LCRegion*>&,
00121                               const TableRecord&,
00122                               const String& tableName);
00123 
00124     // Translate all regions.
00125     void multiTranslate (PtrBlock<const LCRegion*>&,
00126                          const Vector<Float>& translateVector,
00127                          const IPosition& newLatticeShape) const;
00128 
00129     // Determine if all regions have mask (used by LCIntersection).
00130     void fillHasMask();
00131 
00132     // Find which area of the section and region are needed.
00133     // False is returned if no part of the region is included in the section.
00134     Bool findAreas (IPosition& bufStart, IPosition& bufEnd,
00135                     IPosition& regStart, IPosition& regEnd,
00136                     const Slicer& section, uInt regNr) const;
00137 
00138     // Get the contributing regions.
00139     const PtrBlock<const LCRegion*>& regions() const;
00140     
00141 protected:
00142     // Construct from lattice shape and region pointer, which is
00143     // taken over.
00144     // Primarily meant for LCExtension.
00145     LCRegionMulti (const LCRegion* region, const IPosition& latticeShape);
00146 
00147     // Do the actual getting of an array of values.
00148     virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
00149 
00150     // Get the values from the class derived from Multi.
00151     // It is called when there is a mask. Note that it is not sure
00152     // whether the buffer has the correct size.
00153     virtual void multiGetSlice (Array<Bool>& buffer,
00154                                 const Slicer& section) = 0;
00155 
00156     // Get the best cursor shape.
00157     virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00158 
00159 private:
00160     // Check if the regions are correct.
00161     // If needed, make a copy of the region objects.
00162     void init (Bool takeOver);
00163 
00164     //# >=0 means this region has a mask.
00165     //# Its value gives the region with the biggest mask.
00166     Int itsHasMask;
00167     PtrBlock<const LCRegion*> itsRegions;
00168 };
00169 
00170 
00171 inline const PtrBlock<const LCRegion*>& LCRegionMulti::regions() const
00172 {
00173     return itsRegions;
00174 }
00175 
00176 
00177 
00178 } //# NAMESPACE CASACORE - END
00179 
00180 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1