casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LELRegion.h
Go to the documentation of this file.
1 //# LELRegion.h: Class to hold a region as a LEL node
2 //# Copyright (C) 1999
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_LELREGION_H
29 #define LATTICES_LELREGION_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class LattRegionHolder;
41 
42 
43 // <summary>
44 // Class to hold a region as a LEL node
45 // </summary>
46 
47 // <use visibility=local>
48 
49 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="Lattice"> Lattice</linkto>
54 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
55 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
56 // <li> <linkto class="LELInterface"> LELInterface</linkto>
57 // </prerequisite>
58 
59 // <etymology>
60 // This derived LEL letter class handles regions.
61 // </etymology>
62 
63 // <synopsis>
64 // This LEL letter class is derived from LELInterface. It
65 // is used to construct LEL objects from regions.
66 // The internal region is an <linkto class=ImageRegion>ImageRegion</linkto>
67 // object, thus the region can be of any type.
68 // With operator [] a region is applied to an image (expression).
69 // At that stage possible world coordinates are converted to lattice
70 // coordinates.
71 // <p>
72 // The attributes of a LELRegion object define an empty shape,
73 // because in general the shape of a region is only known after
74 // it is applied to an image.
75 // <p>
76 // A description of the implementation details of the LEL classes can
77 // be found in
78 // <a href="../notes/216.html">Note 216</a>
79 // </synopsis>
80 
81 // <motivation>
82 // We needed to be able to handle regions in a LEL expression.
83 // </motivation>
84 
85 //# <todo asof="1998/01/21">
86 //# </todo>
87 
88 
89 class LELRegion : public LELInterface<Bool>
90 {
91 public:
92 // Constructor.
94 
95 // Constructor. It takes over the pointer.
96  LELRegion (LattRegionHolder* region);
97 
98 // Destructor.
99  ~LELRegion();
100 
101 // Get a pointer to the region object.
102  const LattRegionHolder& region() const
103  { return *region_p; }
104 
105 // Getting region data cannot be done (throws an exception).
106  virtual void eval(LELArray<Bool>&, const Slicer&) const;
107 
108 // Getting region data cannot be done (throws an exception).
109  virtual LELScalar<Bool> getScalar() const;
110 
111 // Do further preparations (e.g. optimization) on the expression.
112  virtual Bool prepareScalarExpr();
113 
114 // Get class name
115  virtual String className() const;
116 
117 // Form a compound from the regions.
118 // <group>
119  static LELRegion* makeUnion (const LELInterface<Bool>& left,
120  const LELInterface<Bool>& right);
121  static LELRegion* makeIntersection (const LELInterface<Bool>& left,
122  const LELInterface<Bool>& right);
123  static LELRegion* makeDifference (const LELInterface<Bool>& left,
124  const LELInterface<Bool>& right);
125  static LELRegion* makeComplement (const LELInterface<Bool>& expr);
126 // </group>
127 
128 private:
129 // Get the LattRegionHolder after checking that the expression is a region.
130  static const LattRegionHolder& region (const LELInterface<Bool>& expr);
131 
132 // Check if both regions have the same type (pixel or world) and if
133 // no LCSlicer type of region is used.
134  static void checkTypes (const LattRegionHolder& left,
135  const LattRegionHolder& right);
136 
137 // Member variables.
139 };
140 
141 
142 
143 
144 // <summary>
145 // Class to convert a region to a boolean node
146 // </summary>
147 
148 // <use visibility=local>
149 
150 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
151 // </reviewed>
152 
153 // <prerequisite>
154 // <li> <linkto class="LELRegion"> Lattice</linkto>
155 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
156 // <li> <linkto class="LELInterface"> LELInterface</linkto>
157 // </prerequisite>
158 
159 // <etymology>
160 // This derived LEL letter class handles a region as a boolean lattice.
161 // </etymology>
162 
163 // <synopsis>
164 // This class makes it possible to handle a region as a true
165 // boolean lattice without the need to apply the region to an image.
166 // It means that it is only possible if the region has absolute
167 // lattice coordinates.
168 // <p>
169 // A description of the implementation details of the LEL classes can
170 // be found in
171 // <a href="../notes/216.html">Note 216</a>
172 // </synopsis>
173 
174 // <motivation>
175 // It is useful to be able to handle a mask as a boolean lattice.
176 // </motivation>
177 
178 //# <todo asof="1998/01/21">
179 //# </todo>
180 
181 
182 class LELRegionAsBool : public LELInterface<Bool>
183 {
184 public:
185 // Constructor.
186  LELRegionAsBool (const LELRegion& region);
187 
188 // Destructor.
190 
191 // Get region data.
192  virtual void eval(LELArray<Bool>& result,
193  const Slicer& section) const;
194 
195 // Getting region data as a scalar cannot be done (throws an exception).
196  virtual LELScalar<Bool> getScalar() const;
197 
198 // Do further preparations (e.g. optimization) on the expression.
199  virtual Bool prepareScalarExpr();
200 
201 // Get class name
202  virtual String className() const;
203 
204 private:
205 // Member variables.
207 };
208 
209 
210 
211 
212 } //# NAMESPACE CASACORE - END
213 
214 #endif
static LELRegion * makeIntersection(const LELInterface< Bool > &left, const LELInterface< Bool > &right)
LatticeRegion region_p
Member variables.
Definition: LELRegion.h:206
LELRegionAsBool(const LELRegion &region)
Constructor.
virtual String className() const
Get class name.
static LELRegion * makeDifference(const LELInterface< Bool > &left, const LELInterface< Bool > &right)
virtual LELScalar< Bool > getScalar() const
Getting region data cannot be done (throws an exception).
Class to hold a region as a LEL node.
Definition: LELRegion.h:89
virtual LELScalar< Bool > getScalar() const
Getting region data as a scalar cannot be done (throws an exception).
LattRegionHolder * region_p
Member variables.
Definition: LELRegion.h:138
~LELRegion()
Destructor.
~LELRegionAsBool()
Destructor.
static void checkTypes(const LattRegionHolder &left, const LattRegionHolder &right)
Check if both regions have the same type (pixel or world) and if no LCSlicer type of region is used...
Class to convert a region to a boolean node.
Definition: LELRegion.h:182
This base class provides the interface for Lattice expressions.
Definition: LELInterface.h:150
LELRegion(const LattRegionHolder &region)
Constructor.
static LELRegion * makeComplement(const LELInterface< Bool > &expr)
Class to hold a region of interest in an image.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
const LattRegionHolder & region() const
Get a pointer to the region object.
Definition: LELRegion.h:102
static LELRegion * makeUnion(const LELInterface< Bool > &left, const LELInterface< Bool > &right)
Form a compound from the regions.
virtual void eval(LELArray< Bool > &result, const Slicer &section) const
Get region data.
virtual String className() const
Get class name.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
virtual void eval(LELArray< Bool > &, const Slicer &) const
Getting region data cannot be done (throws an exception).
This LEL class holds a scalar with a mask.
Definition: LELInterface.h:43
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42