LCRegionSingle.h

Go to the documentation of this file.
00001 //# LCRegionSingle.h: Abstract base class to define a single region
00002 //# Copyright (C) 1998,1999,2003
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_LCREGIONSINGLE_H
00029 #define LATTICES_LCREGIONSINGLE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/lattices/LRegions/LCRegion.h>
00034 
00035 
00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00037 
00038 // <summary>
00039 // Abstract base class to define a single region.
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="" date="" tests="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> <linkto class=Slicer>Slicer</linkto>
00049 // </prerequisite>
00050 
00051 // <synopsis> 
00052 // The LCRegion class is the abstract base class for various types
00053 // of LCRegion's (e.g. LCRegionEllipsoid, LCRegionBox).
00054 // It contains the minimal bounding box of the region and, if needed,
00055 // a mask with the same shape as the bounding box. A mask element
00056 // is true if the element is inside the box.
00057 // <p>
00058 // Each LCRegion object must be able to convert itself to and from a Record.
00059 // In that way they can be made persistent (in for example a Table).
00060 // <p>
00061 // The LCRegion can be used in several Lattices and Images classes and
00062 // functions to limit the area to operate on.
00063 // </synopsis> 
00064 
00065 // <example>
00066 // <srcblock>
00067 // </srcblock>
00068 // </example>
00069 
00070 // <motivation>
00071 // The Slicer class is too limited as a region, because it can only
00072 // describe a rectangular region. Specialized classes are needed to
00073 // describe arbitrary regions. They need a base class to combine them.
00074 // </motivation>
00075 
00076 //# <todo asof="1997/11/11">
00077 //# <li>
00078 //# </todo>
00079 
00080 class LCRegionSingle : public LCRegion
00081 {
00082 public:
00083     LCRegionSingle();
00084 
00085     // Construct with the lattice shape only.
00086     LCRegionSingle (const IPosition& latticeShape);
00087 
00088     // Copy constructor (copy semantics).
00089     LCRegionSingle (const LCRegionSingle& other);
00090 
00091     virtual ~LCRegionSingle();
00092 
00093     // Does the region have a mask?
00094     virtual Bool hasMask() const;
00095 
00096     // Get the mask (as an array).
00097     const Array<Bool> maskArray() const;
00098 
00099     // Is the mask of this region the same as the mask of the other
00100     Bool masksEqual (const LCRegion& other) const;
00101 
00102     // The following "put" functions are described in detail in class
00103     // <linkto class=Lattice>Lattice</linkto>.
00104     // They'll throw an exception is no mask is available or if
00105     // the mask is not writable.
00106     // <group>
00107     virtual void set (const Bool& value);
00108     virtual void apply (Bool (*function)(Bool));
00109     virtual void apply (Bool (*function)(const Bool&));
00110     virtual void apply (const Functional<Bool,Bool>& function);
00111     virtual void putAt (const Bool& value, const IPosition& where);
00112     virtual void copyData (const Lattice<Bool>& from);
00113     // </group>
00114 
00115 protected:
00116     // Assignment (copy semantics) is only useful for derived classes.
00117     LCRegionSingle& operator= (const LCRegionSingle& other);
00118 
00119     // Set the pointer to the mask in the derived class.
00120     void setMaskPtr (Lattice<Bool>& mask);
00121     
00122     // Do the actual getting of the mask.
00123     virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
00124 
00125     // Do the actual putting of the mask. Only possible if region is writable.
00126     virtual void doPutSlice (const Array<Bool>& sourceBuffer,
00127                              const IPosition& where,
00128                              const IPosition& stride);
00129 
00130     // Get the best cursor shape.
00131     virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00132 
00133     // Make an iterator.
00134     // When the underlying region has a mask, an iterator for that region
00135     // is returned. Otherwise the standard iterator is returned.
00136     virtual LatticeIterInterface<Bool>* makeIter
00137                                 (const LatticeNavigator& navigator,
00138                                  Bool useRef) const;
00139 
00140 private:
00141     Bool           itsHasMask;
00142     Lattice<Bool>* itsMaskPtr;
00143 };
00144 
00145 
00146 
00147 } //# NAMESPACE CASACORE - END
00148 
00149 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1