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