casacore
Loading...
Searching...
No Matches
WCLELMask.h
Go to the documentation of this file.
1//# WCLELMask.h: Class to define a mask as a LEL expression
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
27
28#ifndef IMAGES_WCLELMASK_H
29#define IMAGES_WCLELMASK_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/images/Regions/WCRegion.h>
34#include <casacore/lattices/LRegions/RegionType.h>
35#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
36#include <casacore/casa/Arrays/Vector.h>
37#include <casacore/casa/Quanta/Quantum.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41//# Forward Declarations
42class LCRegion;
43class TableRecord;
44class IPosition;
45template<class T> class ImageExpr;
46template<class T> class LatticeExpr;
47class LatticeExprNode;
48
49
50// <summary>
51// Class to define a mask as a LEL expression
52// </summary>
53
54// <use visibility=export>
55
56// <reviewed reviewer="" date="" tests="">
57// </reviewed>
58
59// <prerequisite>
60// <li> <linkto class=WCRegion>WCRegion</linkto>
61// <li> <linkto class=ImageExpr>ImageExpr</linkto>
62// </prerequisite>
63
64// <synopsis>
65// The WCLELMask class is a specialization of class
66// <linkto class=WCRegion>WCRegion</linkto>.
67// <br>
68// It can be used to define an on-the-fly mask for an image
69// using a boolean <linkto class=LatticeExpr>LatticeExpr</linkto>.
70// The contents of the mask are calculated on the fly from the expression.
71// Thus the mask may change if the data in the image(s) used in the
72// expression change.
73// <note role=caution>
74// This mask is only persistent if constructed from an expression string.
75// When constructed from an <linkto class=ImageExpr>ImageExpr</linkto>
76// the mask is not persistent.
77// </note>
78// </synopsis>
79
80// <example>
81// </example>
82
83// <motivation>
84// Users must be able to specify a mask based on an expression.
85// </motivation>
86
87//# <todo asof="1998/05/20">
88//# <li>
89//# </todo>
90
91class WCLELMask : public WCRegion
92{
93public:
95
96 // Construct from the given expression command.
97 // The command will be parsed and converted to an ImageExpr.
98 // <group>
99 explicit WCLELMask (const String& command);
100 explicit WCLELMask (const char* command);
101 // </group>
102
103 // Construct from the given image expression.
104 explicit WCLELMask (const ImageExpr<Bool>& expr);
105
106 // Construct from the given lattice expression.
107 explicit WCLELMask (const LatticeExpr<Bool>& expr);
108
109 // Construct from the given lattice expression.
110 // This constructor makes it possible to have an expression with an
111 // unknown shape (e.g. using LEL function INDEXIN).
112 // If the shape is known, the LatticeExprNode will be converted to
113 // a LatticeExpr<Bool>.
114 explicit WCLELMask (const LatticeExprNode& expr);
115
116 // Copy constructor (copy semantics).
117 WCLELMask (const WCLELMask& other);
118
119 // Destructor
120 virtual ~WCLELMask();
121
122 // Assignment (copy semantics)
124
125 // Comparison
126 virtual Bool operator== (const WCRegion& other) const;
127
128 // Clone a WCLELMask object.
129 virtual WCRegion* cloneRegion() const;
130
131 // Get the dimensionality (i.e. the number of axes).
132 virtual uInt ndim() const;
133
134 // WCLELMask cannot extend a region.
135 virtual Bool canExtend() const;
136
137 // Convert to an LCRegion using the given new coordinate system and shape.
138 // If the region has coordinates, the WCRegion implementation will
139 // be called. Otherwise the LatticeExpr is returned after checking
140 // that the shape matches.
141 virtual LCRegion* toLCRegion (const CoordinateSystem& cSys,
142 const IPosition& latticeShape) const;
143
144 // Convert to an LCRegion using the supplied <src>CoordinateSystem</src>
145 // and shape.
146 // It checks that coordinates match and that axes are not swapped.
148 const IPosition& latticeShape,
149 const IPosition& pixelAxesMap,
150 const IPosition& outOrder) const;
151
152 // Convert the WCLELMask object to a record.
153 // The record can be used to make the object persistent.
154 // The <src>tableName</src> argument can be used by derived
155 // classes (e.g. LCPagedMask) to put very large objects.
156 virtual TableRecord toRecord (const String& tableName) const;
157
158 // Convert to a WCLELMask from a record.
159 static WCLELMask* fromRecord (const TableRecord& rec,
160 const String& tableName);
161
162 // Returns WCLELMask
164
165 // Return region type. Returns the class name
166 virtual String type() const;
167
169
170private:
171 // Process the command.
173
174 // Initialize as a LatticeExprNode if expression's shape is unknown.
175 // Otherwise as a LatticeExpr<Bool> if coordinates are unknown.
176 // Otherwise as an ImageExpr<Bool>.
177 void init (const LatticeExprNode& expr);
178
179
184};
185
186
187
188} //# NAMESPACE CASACORE - END
189
190#endif
String: the storage and methods of handling collections of characters.
Definition String.h:223
void init(const LatticeExprNode &expr)
Initialize as a LatticeExprNode if expression's shape is unknown.
virtual WCRegion * cloneRegion() const
Clone a WCLELMask object.
LatticeExpr< Bool > * itsLattExpr
Definition WCLELMask.h:182
virtual ~WCLELMask()
Destructor.
const ImageExpr< Bool > * getImageExpr() const
Definition WCLELMask.h:168
WCLELMask(const WCLELMask &other)
Copy constructor (copy semantics).
virtual String type() const
Return region type.
WCLELMask(const ImageExpr< Bool > &expr)
Construct from the given image expression.
WCLELMask(const LatticeExpr< Bool > &expr)
Construct from the given lattice expression.
virtual LCRegion * toLCRegion(const CoordinateSystem &cSys, const IPosition &latticeShape) const
Convert to an LCRegion using the given new coordinate system and shape.
virtual Bool canExtend() const
WCLELMask cannot extend a region.
WCLELMask & operator=(const WCLELMask &other)
Assignment (copy semantics)
static String className()
Returns WCLELMask.
virtual TableRecord toRecord(const String &tableName) const
Convert the WCLELMask object to a record.
virtual Bool operator==(const WCRegion &other) const
Comparison.
LatticeExprNode * itsLattNode
Definition WCLELMask.h:183
void processCommand()
Process the command.
ImageExpr< Bool > * itsImageExpr
Definition WCLELMask.h:181
virtual uInt ndim() const
Get the dimensionality (i.e.
virtual LCRegion * doToLCRegion(const CoordinateSystem &cSys, const IPosition &latticeShape, const IPosition &pixelAxesMap, const IPosition &outOrder) const
Convert to an LCRegion using the supplied CoordinateSystem and shape.
WCLELMask(const char *command)
WCLELMask(const String &command)
Construct from the given expression command.
static WCLELMask * fromRecord(const TableRecord &rec, const String &tableName)
Convert to a WCLELMask from a record.
WCLELMask(const LatticeExprNode &expr)
Construct from the given lattice expression.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40