casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_LCMASK_H
27#define LATTICES_LCMASK_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LRegions/LCBox.h>
32#include <casacore/lattices/Lattices/Lattice.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Class to define a rectangular mask as a temporary region
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="" date="" tests="">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=LCRegion>LCRegion</linkto>
47// </prerequisite>
48
49// <synopsis>
50// The LCMask class is a specialization of class
51// <linkto class=LCRegion>LCRegion</linkto>.
52// <br>
53// It can be used to define a temporary mask (e.g. for a
54// <linkto class=TempImage>TempImage</linkto>).
55// It is possible to define the mask for the full lattice, but one
56// can also define it for part of a lattice. In the latter case a
57// <linkto class=LCBox>LCBox</linkto> has to be given as well to
58// define for which part of the image the mask has to be used.
59// </synopsis>
60
61// <example>
62// <srcblock>
63// </srcblock>
64// </example>
65
66// <todo asof="1997/11/11">
67// </todo>
68
69class LCMask : public LCRegionSingle {
70 public:
72
73 // Construct an LCMask object for a full lattice with the given shape.
74 // It creates a TempLattice<Bool> to hold the mask.
75 explicit LCMask(const IPosition& latticeShape);
76
77 // Construct an LCMask object for a full lattice with the shape of the mask.
78 // It clones the mask object.
80
81 // Construct an LCMask object for the part of a lattice given by the box.
82 // The box defines the position of the mask in the lattice.
83 // The box shape and given mask shape should be equal.
84 // It creates a TempImage<Bool> to hold the mask.
85 LCMask(const IPosition& maskShape, const LCBox& box);
86
87 // Construct an LCMask object for the part of a lattice given by the box.
88 // The box defines the position of the mask in the lattice.
89 // The box shape and given mask shape should be equal.
90 // It clones the mask object.
92
93 // Copy constructor (copy semantics).
94 LCMask(const LCMask& other);
95
96 // Destructor
97 virtual ~LCMask();
98
99 // Assignment (reference semantics).
100 LCMask& operator=(const LCMask& other);
101
102 // Make a copy of the derived object.
103 LCRegion* cloneRegion() const override;
104
105 // This function is used by the LatticeIterator class to generate an
106 // iterator of the correct type for this Lattice. Not recommended
107 // for general use.
109 Bool useRef) const override;
110
111 // Returns the maximum recommended number of pixels for a cursor.
112 // This is the number of pixels in a tile.
113 uInt advisedMaxPixels() const override;
114
115 // Help the user pick a cursor for most efficient access.
116 IPosition doNiceCursorShape(uInt maxPixels) const override;
117
118 // Maximum size - not necessarily all used. In pixels.
119 uInt maximumCacheSize() const override;
120
121 // Set the maximum (allowed) cache size as indicated.
122 void setMaximumCacheSize(uInt howManyPixels) override;
123
124 // Set the cache size as to "fit" the indicated path.
125 void setCacheSizeFromPath(const IPosition& sliceShape, const IPosition& windowStart,
126 const IPosition& windowLength, const IPosition& axisPath) override;
127
128 // Set the actual cache size for this Array to be be big enough for the
129 // indicated number of tiles. This cache is not shared with PagedArrays
130 // in other rows and is always clipped to be less than the maximum value
131 // set using the setMaximumCacheSize member function.
132 // tiles. Tiles are cached using a first in first out algorithm.
133 void setCacheSizeInTiles(uInt howManyTiles) override;
134
135 // Clears and frees up the caches, but the maximum allowed cache size is
136 // unchanged from when setCacheSize was called
137 void clearCache() override;
138
139 // Report on cache success.
140 void showCacheStatistics(std::ostream& os) const override;
141
142 // Handle the (un)locking.
143 // <group>
144 Bool lock(FileLocker::LockType, uInt nattempts) override;
145 void unlock() override;
147 // </group>
148
149 // Resynchronize the object with the contenta tof the possible file.
150 // This function is only useful if no read-locking is used, ie.
151 // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
152 // In that cases the table system does not acquire a read-lock, thus
153 // does not synchronize itself automatically.
154 void resync() override;
155
156 // Flush the data (but do not unlock).
157 void flush() override;
158
159 // Temporarily close the lattice.
160 // It will be reopened automatically on the next access.
161 void tempClose() override;
162
163 // Explicitly reopen the temporarily closed lattice.
164 void reopen() override;
165
166 // Get the class name (to store in the record).
168
169 // Region type. Returns class name.
170 String type() const override;
171
172 // Convert the (derived) object to a record.
173 // This cannot be done and results in an exception.
174 TableRecord toRecord(const String& tableName) const override;
175
176 // An LCMask is writable if the underlying Lattice is.
177 Bool isWritable() const override;
178
179 protected:
180 // Comparison
181 Bool equals(const LCRegion& other) const override;
182
183 // Construct another LCMask (for e.g. another lattice) by moving
184 // this one. It recalculates the bounding mask.
185 // A positive translation value indicates "to right".
186 LCRegion* doTranslate(const Vector<Float>& translateVector,
187 const IPosition& newLatticeShape) const override;
188
189 private:
192};
193
194} // namespace casacore
195
196#endif
LockType
Define the possible lock types.
Definition FileLocker.h:89
LCMask(const IPosition &latticeShape)
Construct an LCMask object for a full lattice with the given shape.
void showCacheStatistics(std::ostream &os) const override
Report on cache success.
static String className()
Get the class name (to store in the record).
LCRegion * cloneRegion() const override
Make a copy of the derived object.
void tempClose() override
Temporarily close the lattice.
void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath) override
Set the cache size as to "fit" the indicated path.
virtual ~LCMask()
Destructor.
LCMask(const IPosition &maskShape, const LCBox &box)
Construct an LCMask object for the part of a lattice given by the box.
uInt maximumCacheSize() const override
Maximum size - not necessarily all used.
IPosition doNiceCursorShape(uInt maxPixels) const override
Help the user pick a cursor for most efficient access.
LatticeIterInterface< Bool > * makeIter(const LatticeNavigator &navigator, Bool useRef) const override
This function is used by the LatticeIterator class to generate an iterator of the correct type for th...
void flush() override
Flush the data (but do not unlock).
void unlock() override
LCMask(const LCMask &other)
Copy constructor (copy semantics).
void reopen() override
Explicitly reopen the temporarily closed lattice.
Bool hasLock(FileLocker::LockType) const override
void setCacheSizeInTiles(uInt howManyTiles) override
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
Bool lock(FileLocker::LockType, uInt nattempts) override
Handle the (un)locking.
LCMask(Lattice< Bool > &mask)
Construct an LCMask object for a full lattice with the shape of the mask.
void resync() override
Resynchronize the object with the contenta tof the possible file.
uInt advisedMaxPixels() const override
Returns the maximum recommended number of pixels for a cursor.
void setMaximumCacheSize(uInt howManyPixels) override
Set the maximum (allowed) cache size as indicated.
Bool isWritable() const override
An LCMask is writable if the underlying Lattice is.
LCMask(Lattice< Bool > &mask, const LCBox &box)
Construct an LCMask object for the part of a lattice given by the box.
Lattice< Bool > * itsMask
Definition LCMask.h:191
Bool equals(const LCRegion &other) const override
Comparison.
TableRecord toRecord(const String &tableName) const override
Convert the (derived) object to a record.
void clearCache() override
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
LCMask & operator=(const LCMask &other)
Assignment (reference semantics).
String type() const override
Region type.
LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const override
Construct another LCMask (for e.g.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition LCRegion.h:211
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40