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