casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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:
95  WCLELMask();
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)
124  WCLELMask& operator= (const WCLELMask& other);
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.
173  void processCommand();
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
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual Bool operator==(const WCRegion &other) const
Comparison.
virtual uInt ndim() const
Get the dimensionality (i.e.
virtual TableRecord toRecord(const String &tableName) const
Convert the WCLELMask object to a record.
void init(const LatticeExprNode &expr)
Initialize as a LatticeExprNode if expression&#39;s shape is unknown.
WCLELMask & operator=(const WCLELMask &other)
Assignment (copy semantics)
virtual String type() const
Return region type.
LatticeExpr< Bool > * itsLattExpr
Definition: WCLELMask.h:183
virtual ~WCLELMask()
Destructor.
LatticeExprNode * itsLattNode
Definition: WCLELMask.h:184
static WCLELMask * fromRecord(const TableRecord &rec, const String &tableName)
Convert to a WCLELMask from a record.
Hold mathematical expressions involving ImageInterface objects.
Definition: WCLELMask.h:46
void processCommand()
Process the command.
Class to define a mask as a LEL expression.
Definition: WCLELMask.h:92
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual WCRegion * cloneRegion() const
Clone a WCLELMask object.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
virtual Bool canExtend() const
WCLELMask cannot extend a region.
ImageExpr< Bool > * itsImageExpr
Definition: WCLELMask.h:182
Bridging class to allow C++ expressions involving lattices.
static String className()
Returns WCLELMask.
Base class to define world coordinate regions of interest in an image.
Definition: WCRegion.h:95
String: the storage and methods of handling collections of characters.
Definition: String.h:223
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.
Class to allow C++ expressions involving lattices.
Definition: LatticeExpr.h:142
const ImageExpr< Bool > * getImageExpr() const
Definition: WCLELMask.h:169
virtual LCRegion * toLCRegion(const CoordinateSystem &cSys, const IPosition &latticeShape) const
Convert to an LCRegion using the given new coordinate system and shape.
Interconvert pixel and world coordinates.
unsigned int uInt
Definition: aipstype.h:51
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42