casa
$Rev:20696$
|
00001 //# LCMask.h: Class to define a rectangular mask as a temporary region 00002 //# Copyright (C) 2000,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: LCMask.h 18093 2004-11-30 17:51:10Z ddebonis $ 00027 00028 #ifndef LATTICES_LCMASK_H 00029 #define LATTICES_LCMASK_H 00030 00031 00032 //# Includes 00033 #include <lattices/Lattices/LCBox.h> 00034 #include <lattices/Lattices/Lattice.h> 00035 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 // <summary> 00040 // Class to define a rectangular mask as a temporary region 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 LCMask class is a specialization of class 00054 // <linkto class=LCRegion>LCRegion</linkto>. 00055 // <br> 00056 // It can be used to define a temporary mask (e.g. for a 00057 // <linkto class=TempImage>TempImage</linkto>). 00058 // It is possible to define the mask for the full lattice, but one 00059 // can also define it for part of a lattice. In the latter case a 00060 // <linkto class=LCBox>LCBox</linkto> has to be given as well to 00061 // define for which part of the image the mask has to be used. 00062 // </synopsis> 00063 00064 // <example> 00065 // <srcblock> 00066 // </srcblock> 00067 // </example> 00068 00069 // <todo asof="1997/11/11"> 00070 // </todo> 00071 00072 class LCMask: public LCRegionSingle 00073 { 00074 public: 00075 LCMask(); 00076 00077 // Construct an LCMask object for a full lattice with the given shape. 00078 // It creates a TempLattice<Bool> to hold the mask. 00079 explicit LCMask (const IPosition& latticeShape); 00080 00081 // Construct an LCMask object for a full lattice with the shape of the mask. 00082 // It clones the mask object. 00083 explicit LCMask (Lattice<Bool>& mask); 00084 00085 // Construct an LCMask object for the part of a lattice given by the box. 00086 // The box defines the position of the mask in the lattice. 00087 // The box shape and given mask shape should be equal. 00088 // It creates a TempImage<Bool> to hold the mask. 00089 LCMask (const IPosition& maskShape, const LCBox& box); 00090 00091 // Construct an LCMask object for the part of a lattice given by the box. 00092 // The box defines the position of the mask in the lattice. 00093 // The box shape and given mask shape should be equal. 00094 // It clones the mask object. 00095 LCMask (Lattice<Bool>& mask, const LCBox& box); 00096 00097 // Copy constructor (copy semantics). 00098 LCMask (const LCMask& other); 00099 00100 // Destructor 00101 virtual ~LCMask(); 00102 00103 // Assignment (reference semantics). 00104 LCMask& operator= (const LCMask& other); 00105 00106 // Comparison 00107 virtual Bool operator==(const LCRegion& other) const; 00108 00109 // Make a copy of the derived object. 00110 virtual LCRegion* cloneRegion() const; 00111 00112 // This function is used by the LatticeIterator class to generate an 00113 // iterator of the correct type for this Lattice. Not recommended 00114 // for general use. 00115 virtual LatticeIterInterface<Bool>* makeIter 00116 (const LatticeNavigator& navigator, 00117 Bool useRef) const; 00118 00119 // Returns the maximum recommended number of pixels for a cursor. 00120 // This is the number of pixels in a tile. 00121 virtual uInt advisedMaxPixels() const; 00122 00123 // Help the user pick a cursor for most efficient access. 00124 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00125 00126 // Maximum size - not necessarily all used. In pixels. 00127 virtual uInt maximumCacheSize() const; 00128 00129 // Set the maximum (allowed) cache size as indicated. 00130 virtual void setMaximumCacheSize (uInt howManyPixels); 00131 00132 // Set the cache size as to "fit" the indicated path. 00133 virtual void setCacheSizeFromPath (const IPosition& sliceShape, 00134 const IPosition& windowStart, 00135 const IPosition& windowLength, 00136 const IPosition& axisPath); 00137 00138 // Set the actual cache size for this Array to be be big enough for the 00139 // indicated number of tiles. This cache is not shared with PagedArrays 00140 // in other rows and is always clipped to be less than the maximum value 00141 // set using the setMaximumCacheSize member function. 00142 // tiles. Tiles are cached using a first in first out algorithm. 00143 virtual void setCacheSizeInTiles (uInt howManyTiles); 00144 00145 // Clears and frees up the caches, but the maximum allowed cache size is 00146 // unchanged from when setCacheSize was called 00147 virtual void clearCache(); 00148 00149 // Report on cache success. 00150 virtual void showCacheStatistics (ostream& os) const; 00151 00152 // Handle the (un)locking. 00153 // <group> 00154 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00155 virtual void unlock(); 00156 virtual Bool hasLock (FileLocker::LockType) const; 00157 // </group> 00158 00159 // Resynchronize the object with the contenta tof the possible file. 00160 // This function is only useful if no read-locking is used, ie. 00161 // if the table lock option is UserNoReadLocking or AutoNoReadLocking. 00162 // In that cases the table system does not acquire a read-lock, thus 00163 // does not synchronize itself automatically. 00164 virtual void resync(); 00165 00166 // Flush the data (but do not unlock). 00167 virtual void flush(); 00168 00169 // Temporarily close the lattice. 00170 // It will be reopened automatically on the next access. 00171 virtual void tempClose(); 00172 00173 // Explicitly reopen the temporarily closed lattice. 00174 virtual void reopen(); 00175 00176 // Get the class name (to store in the record). 00177 static String className(); 00178 00179 // Region type. Returns class name. 00180 virtual String type() const; 00181 00182 // Convert the (derived) object to a record. 00183 // This cannot be done and results in an exception. 00184 virtual TableRecord toRecord (const String& tableName) const; 00185 00186 // An LCMask is writable if the underlying Lattice is. 00187 virtual Bool isWritable() const; 00188 00189 protected: 00190 // Construct another LCMask (for e.g. another lattice) by moving 00191 // this one. It recalculates the bounding mask. 00192 // A positive translation value indicates "to right". 00193 virtual LCRegion* doTranslate (const Vector<Float>& translateVector, 00194 const IPosition& newLatticeShape) const; 00195 00196 private: 00197 LCBox itsBox; 00198 Lattice<Bool>* itsMask; 00199 }; 00200 00201 00202 00203 } //# NAMESPACE CASA - END 00204 00205 #endif