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