casacore
Loading...
Searching...
No Matches
ImageRegion.h
Go to the documentation of this file.
1//# ImageRegion.h: Class to hold a region of interest in an image
2//# Copyright (C) 1998,1999,2000
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 IMAGES_IMAGEREGION_H
27#define IMAGES_IMAGEREGION_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LRegions/LattRegionHolder.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35//# Forward Declarations
36class CoordinateSystem;
37class IPosition;
38class LCRegion;
39class LCSlicer;
40class WCRegion;
41class String;
42class TableRecord;
43
44
45// <summary>
46// Class to hold a region of interest in an image.
47// </summary>
48
49// <use visibility=export>
50
51// <reviewed reviewer="" date="" tests="">
52// </reviewed>
53
54// <prerequisite>
55// <li> <linkto class=LCSlicer>LCSlicer</linkto>
56// <li> <linkto class=WCRegion>WCRegion</linkto>
57// </prerequisite>
58
59// <synopsis>
60// The only purpose of ImageRegion is to have a single object for
61// the various kinds of regions. It can hold a
62// <linkto class=LCRegion>LCRegion</linkto>,
63// <linkto class=LCSlicer>LCSlicer</linkto>, and
64// <linkto class=WCRegion>WCRegion</linkto>.
65// </synopsis>
66
67// <example>
68// <srcblock>
69// </srcblock>
70// </example>
71
72// <motivation>
73// It was felt that making an abstract base class LatticeRegion for
74// LCRegion and WCRegion would create undesirable dependencies of
75// module Lattices on module Coordinates. E.g. it would be impossible
76// to have a function toWCRegion.
77// Therefore the container class ImageRegion is chosen.
78// </motivation>
79
80//# <todo asof="1997/11/11">
81//# <li>
82//# </todo>
83
85{
86public:
87 // Default constructor (has no region at all).
89
90 // Construct from a region based on lattice coordinates.
92
93 // Construct from a slicer based on lattice coordinates.
95
96 // Construct from a region based on world coordinates.
98
99 // Similar constructors as above, but using a pointer.
100 // It takes over the pointer, so the user should not delete the
101 // object. It is deleted by the ImageRegion destructor.
102 // <group>
106 // </group>
107
108 // Copy constructor (copy semantics).
109 ImageRegion (const ImageRegion& other);
110
111 virtual ~ImageRegion();
112
113 // Assignment (copy semantics).
115
116 // Clone the object.
117 virtual ImageRegion* clone() const;
118
119 // Comparison
120 virtual Bool operator==(const LattRegionHolder& other) const;
121
122 // Create an ImageRegion from a lattice expression. Returned pointer
123 // is created via new(); it is the caller's responsibility to delete it.
124 static ImageRegion* fromLatticeExpression(const String& latticeExpression);
125
126 // Create an ImageRegion from a record. The returned pointer is created via
127 // new(). It's the callers responsibility to delete it.
128 // If a null pointer is passed in for <src>logger</src> no logging is done,
129 // otherwise informational messages regarding bounding boxes are emitted
130 // to the <src>logger</src> object.
131 static ImageRegion* fromRecord (LogIO *logger,
132 const CoordinateSystem& coords,
133 const IPosition& imShape,
134 const Record& regionRecord);
135
136 // Test if the underlying region is an WCRegion.
137 virtual Bool isWCRegion() const;
138
139 // Get the region as a pointer to WCRegion.
140 // An exception is thrown if the region is not the correct type.
141 // Functions <src>isWCRegion()</src> can be used to test the type.
142 virtual const WCRegion* asWCRegionPtr() const;
143
144 // Get the region as an LCSlicer or WCRegion.
145 // An exception is thrown if the region is not the correct type.
146 // Functions <src>isWCRegion()</src>, etc. can be used to test the type.
147 // <group>
148 const LCRegion& asLCRegion() const;
149 const LCSlicer& asLCSlicer() const;
150 const WCRegion& asWCRegion() const;
151 // </group>
152
153 // Get the region as a writable mask.
154 // It throws an exception if the region is not an LCRegion or if
155 // its mask is not writable.
157
158 // Convert to a LatticeRegion using the given coordinate system
159 // (with reference pixel) and shape.
160 // It will also make the region complete (absolute and non-fractional).
162 const IPosition& shape) const;
163
164 // Convert to an LCRegion using the given coordinate system
165 // (with reference pixel) and shape.
166 // It will also make the region complete (absolute and non-fractional).
167 // An exception is thrown if the region type is a LCSlicer.
168 // The axes argument tells which axes to use from the coordinate
169 // system and shape.
171 const IPosition& shape) const;
172
173 // Convert the (derived) object to a record.
174 // The record can be used to make the object persistent.
175 TableRecord toRecord (const String& tableName) const;
176
177 // Convert correct object from a record.
179 const String& tableName);
180
181 // Form a compound from this and the other region.
182 // <group>
183 virtual LattRegionHolder* makeUnion (const LattRegionHolder& other) const;
185 (const LattRegionHolder& other) const;
187 (const LattRegionHolder& other) const;
189 // </group>
190
191private:
193};
194
195
197{
198 return *asLCRegionPtr();
199}
200
202{
203 return *asLCSlicerPtr();
204}
205
207{
208 return *asWCRegionPtr();
209}
210
211
212
213} //# NAMESPACE CASACORE - END
214
215#endif
const LCRegion & asLCRegion() const
Get the region as an LCSlicer or WCRegion.
ImageRegion(LCSlicer *)
ImageRegion(const LCSlicer &)
Construct from a slicer based on lattice coordinates.
TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
ImageRegion()
Default constructor (has no region at all).
ImageRegion(const LCRegion &)
Construct from a region based on lattice coordinates.
virtual LattRegionHolder * makeUnion(const LattRegionHolder &other) const
Form a compound from this and the other region.
ImageRegion(LCRegion *)
Similar constructors as above, but using a pointer.
ImageRegion(WCRegion *)
static ImageRegion * fromRecord(const TableRecord &, const String &tableName)
Convert correct object from a record.
ImageRegion(const ImageRegion &other)
Copy constructor (copy semantics).
static ImageRegion * fromRecord(LogIO *logger, const CoordinateSystem &coords, const IPosition &imShape, const Record &regionRecord)
Create an ImageRegion from a record.
const WCRegion & asWCRegion() const
virtual LattRegionHolder * makeComplement() const
virtual LatticeRegion toLatticeRegion(const CoordinateSystem &cSys, const IPosition &shape) const
Convert to a LatticeRegion using the given coordinate system (with reference pixel) and shape.
virtual const WCRegion * asWCRegionPtr() const
Get the region as a pointer to WCRegion.
virtual Bool operator==(const LattRegionHolder &other) const
Comparison.
LCRegion & asMask()
Get the region as a writable mask.
virtual LattRegionHolder * makeIntersection(const LattRegionHolder &other) const
ImageRegion & operator=(const ImageRegion &other)
Assignment (copy semantics).
const LCSlicer & asLCSlicer() const
ImageRegion(const WCRegion &)
Construct from a region based on world coordinates.
static ImageRegion * fromLatticeExpression(const String &latticeExpression)
Create an ImageRegion from a lattice expression.
virtual LattRegionHolder * makeDifference(const LattRegionHolder &other) const
LCRegion * toLCRegion(const CoordinateSystem &cSys, const IPosition &shape) const
Convert to an LCRegion using the given coordinate system (with reference pixel) and shape.
virtual Bool isWCRegion() const
Test if the underlying region is an WCRegion.
virtual ImageRegion * clone() const
Clone the object.
const LCSlicer * asLCSlicerPtr() const
const LCRegion * asLCRegionPtr() const
Get the region as a pointer to a LCRegion, LCSlicer, or WCRegion.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40