casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LCMask.h
Go to the documentation of this file.
1 //# LCMask.h: Class to define a rectangular mask as a temporary region
2 //# Copyright (C) 2000,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_LCMASK_H
29 #define LATTICES_LCMASK_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Class to define a rectangular mask as a temporary region
42 // </summary>
43 
44 // <use visibility=export>
45 
46 // <reviewed reviewer="" date="" tests="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=LCRegion>LCRegion</linkto>
51 // </prerequisite>
52 
53 // <synopsis>
54 // The LCMask class is a specialization of class
55 // <linkto class=LCRegion>LCRegion</linkto>.
56 // <br>
57 // It can be used to define a temporary mask (e.g. for a
58 // <linkto class=TempImage>TempImage</linkto>).
59 // It is possible to define the mask for the full lattice, but one
60 // can also define it for part of a lattice. In the latter case a
61 // <linkto class=LCBox>LCBox</linkto> has to be given as well to
62 // define for which part of the image the mask has to be used.
63 // </synopsis>
64 
65 // <example>
66 // <srcblock>
67 // </srcblock>
68 // </example>
69 
70 // <todo asof="1997/11/11">
71 // </todo>
72 
73 class LCMask: public LCRegionSingle
74 {
75 public:
76  LCMask();
77 
78  // Construct an LCMask object for a full lattice with the given shape.
79  // It creates a TempLattice<Bool> to hold the mask.
80  explicit LCMask (const IPosition& latticeShape);
81 
82  // Construct an LCMask object for a full lattice with the shape of the mask.
83  // It clones the mask object.
84  explicit LCMask (Lattice<Bool>& mask);
85 
86  // Construct an LCMask object for the part of a lattice given by the box.
87  // The box defines the position of the mask in the lattice.
88  // The box shape and given mask shape should be equal.
89  // It creates a TempImage<Bool> to hold the mask.
90  LCMask (const IPosition& maskShape, const LCBox& box);
91 
92  // Construct an LCMask object for the part of a lattice given by the box.
93  // The box defines the position of the mask in the lattice.
94  // The box shape and given mask shape should be equal.
95  // It clones the mask object.
96  LCMask (Lattice<Bool>& mask, const LCBox& box);
97 
98  // Copy constructor (copy semantics).
99  LCMask (const LCMask& other);
100 
101  // Destructor
102  virtual ~LCMask();
103 
104  // Assignment (reference semantics).
105  LCMask& operator= (const LCMask& other);
106 
107  // Comparison
108  virtual Bool operator==(const LCRegion& other) const;
109 
110  // Make a copy of the derived object.
111  virtual LCRegion* cloneRegion() const;
112 
113  // This function is used by the LatticeIterator class to generate an
114  // iterator of the correct type for this Lattice. Not recommended
115  // for general use.
117  (const LatticeNavigator& navigator,
118  Bool useRef) const;
119 
120  // Returns the maximum recommended number of pixels for a cursor.
121  // This is the number of pixels in a tile.
122  virtual uInt advisedMaxPixels() const;
123 
124  // Help the user pick a cursor for most efficient access.
125  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
126 
127  // Maximum size - not necessarily all used. In pixels.
128  virtual uInt maximumCacheSize() const;
129 
130  // Set the maximum (allowed) cache size as indicated.
131  virtual void setMaximumCacheSize (uInt howManyPixels);
132 
133  // Set the cache size as to "fit" the indicated path.
134  virtual void setCacheSizeFromPath (const IPosition& sliceShape,
135  const IPosition& windowStart,
136  const IPosition& windowLength,
137  const IPosition& axisPath);
138 
139  // Set the actual cache size for this Array to be be big enough for the
140  // indicated number of tiles. This cache is not shared with PagedArrays
141  // in other rows and is always clipped to be less than the maximum value
142  // set using the setMaximumCacheSize member function.
143  // tiles. Tiles are cached using a first in first out algorithm.
144  virtual void setCacheSizeInTiles (uInt howManyTiles);
145 
146  // Clears and frees up the caches, but the maximum allowed cache size is
147  // unchanged from when setCacheSize was called
148  virtual void clearCache();
149 
150  // Report on cache success.
151  virtual void showCacheStatistics (ostream& os) const;
152 
153  // Handle the (un)locking.
154  // <group>
155  virtual Bool lock (FileLocker::LockType, uInt nattempts);
156  virtual void unlock();
157  virtual Bool hasLock (FileLocker::LockType) const;
158  // </group>
159 
160  // Resynchronize the object with the contenta tof the possible file.
161  // This function is only useful if no read-locking is used, ie.
162  // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
163  // In that cases the table system does not acquire a read-lock, thus
164  // does not synchronize itself automatically.
165  virtual void resync();
166 
167  // Flush the data (but do not unlock).
168  virtual void flush();
169 
170  // Temporarily close the lattice.
171  // It will be reopened automatically on the next access.
172  virtual void tempClose();
173 
174  // Explicitly reopen the temporarily closed lattice.
175  virtual void reopen();
176 
177  // Get the class name (to store in the record).
178  static String className();
179 
180  // Region type. Returns class name.
181  virtual String type() const;
182 
183  // Convert the (derived) object to a record.
184  // This cannot be done and results in an exception.
185  virtual TableRecord toRecord (const String& tableName) const;
186 
187  // An LCMask is writable if the underlying Lattice is.
188  virtual Bool isWritable() const;
189 
190 protected:
191  // Construct another LCMask (for e.g. another lattice) by moving
192  // this one. It recalculates the bounding mask.
193  // A positive translation value indicates "to right".
194  virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
195  const IPosition& newLatticeShape) const;
196 
197 private:
200 };
201 
202 
203 
204 } //# NAMESPACE CASACORE - END
205 
206 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the cache size as to &quot;fit&quot; the indicated path.
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
Class to define a rectangular box of interest.
Definition: LCBox.h:67
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCMask (for e.g.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access.
virtual void unlock()
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
virtual String type() const
Region type.
virtual ~LCMask()
Destructor.
virtual Bool isWritable() const
An LCMask is writable if the underlying Lattice is.
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
Lattice< Bool > * itsMask
Definition: LCMask.h:199
A base class for Lattice iterators.
Definition: ImageExpr.h:47
LCBox itsBox
Definition: LCMask.h:198
virtual Bool operator==(const LCRegion &other) const
Comparison.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
static String className()
Get the class name (to store in the record).
Class to define a rectangular mask as a temporary region.
Definition: LCMask.h:73
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LCMask & operator=(const LCMask &other)
Assignment (reference semantics).
virtual void resync()
Resynchronize the object with the contenta tof the possible file.
virtual Bool hasLock(FileLocker::LockType) const
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking.
virtual void tempClose()
Temporarily close the lattice.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles...
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual void flush()
Flush the data (but do not unlock).
LockType
Define the possible lock types.
Definition: FileLocker.h:95
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
Abstract base class to define a single region.
virtual LatticeIterInterface< Bool > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
This function is used by the LatticeIterator class to generate an iterator of the correct type for th...
unsigned int uInt
Definition: aipstype.h:51
Abstract base class to steer lattice iterators.
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87