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
37class IPosition;
38class LCRegion;
39class LCSlicer;
40class WCRegion;
41class String;
42class TableRecord;
43
44// <summary>
45// Class to hold a region of interest in an image.
46// </summary>
47
48// <use visibility=export>
49
50// <reviewed reviewer="" date="" tests="">
51// </reviewed>
52
53// <prerequisite>
54// <li> <linkto class=LCSlicer>LCSlicer</linkto>
55// <li> <linkto class=WCRegion>WCRegion</linkto>
56// </prerequisite>
57
58// <synopsis>
59// The only purpose of ImageRegion is to have a single object for
60// the various kinds of regions. It can hold a
61// <linkto class=LCRegion>LCRegion</linkto>,
62// <linkto class=LCSlicer>LCSlicer</linkto>, and
63// <linkto class=WCRegion>WCRegion</linkto>.
64// </synopsis>
65
66// <example>
67// <srcblock>
68// </srcblock>
69// </example>
70
71// <motivation>
72// It was felt that making an abstract base class LatticeRegion for
73// LCRegion and WCRegion would create undesirable dependencies of
74// module Lattices on module Coordinates. E.g. it would be impossible
75// to have a function toWCRegion.
76// Therefore the container class ImageRegion is chosen.
77// </motivation>
78
79// # <todo asof="1997/11/11">
80// # <li>
81// # </todo>
82
84 public:
85 // Default constructor (has no region at all).
87
88 // Construct from a region based on lattice coordinates.
90
91 // Construct from a slicer based on lattice coordinates.
93
94 // Construct from a region based on world coordinates.
96
97 // Similar constructors as above, but using a pointer.
98 // It takes over the pointer, so the user should not delete the
99 // object. It is deleted by the ImageRegion destructor.
100 // <group>
104 // </group>
105
106 // Copy constructor (copy semantics).
108
109 virtual ~ImageRegion();
110
111 // Assignment (copy semantics).
113
114 // Clone the object.
115 virtual ImageRegion* clone() const;
116
117 // Comparison
118 virtual Bool operator==(const LattRegionHolder& other) const;
119
120 // Create an ImageRegion from a lattice expression. Returned pointer
121 // is created via new(); it is the caller's responsibility to delete it.
122 static ImageRegion* fromLatticeExpression(const String& latticeExpression);
123
124 // Create an ImageRegion from a record. The returned pointer is created via
125 // new(). It's the callers responsibility to delete it.
126 // If a null pointer is passed in for <src>logger</src> no logging is done,
127 // otherwise informational messages regarding bounding boxes are emitted
128 // to the <src>logger</src> object.
129 static ImageRegion* fromRecord(LogIO* logger, const CoordinateSystem& coords,
130 const IPosition& imShape, const Record& regionRecord);
131
132 // Test if the underlying region is an WCRegion.
133 virtual Bool isWCRegion() const;
134
135 // Get the region as a pointer to WCRegion.
136 // An exception is thrown if the region is not the correct type.
137 // Functions <src>isWCRegion()</src> can be used to test the type.
138 virtual const WCRegion* asWCRegionPtr() const;
139
140 // Get the region as an LCSlicer or WCRegion.
141 // An exception is thrown if the region is not the correct type.
142 // Functions <src>isWCRegion()</src>, etc. can be used to test the type.
143 // <group>
144 const LCRegion& asLCRegion() const;
145 const LCSlicer& asLCSlicer() const;
146 const WCRegion& asWCRegion() const;
147 // </group>
148
149 // Get the region as a writable mask.
150 // It throws an exception if the region is not an LCRegion or if
151 // its mask is not writable.
153
154 // Convert to a LatticeRegion using the given coordinate system
155 // (with reference pixel) and shape.
156 // It will also make the region complete (absolute and non-fractional).
158
159 // Convert to an LCRegion using the given coordinate system
160 // (with reference pixel) and shape.
161 // It will also make the region complete (absolute and non-fractional).
162 // An exception is thrown if the region type is a LCSlicer.
163 // The axes argument tells which axes to use from the coordinate
164 // system and shape.
166
167 // Convert the (derived) object to a record.
168 // The record can be used to make the object persistent.
169 TableRecord toRecord(const String& tableName) const;
170
171 // Convert correct object from a record.
172 static ImageRegion* fromRecord(const TableRecord&, const String& tableName);
173
174 // Form a compound from this and the other region.
175 // <group>
176 virtual LattRegionHolder* makeUnion(const LattRegionHolder& other) const;
180 // </group>
181
182 private:
184};
185
186inline const LCRegion& ImageRegion::asLCRegion() const { return *asLCRegionPtr(); }
187
188inline const LCSlicer& ImageRegion::asLCSlicer() const { return *asLCSlicerPtr(); }
189
190inline const WCRegion& ImageRegion::asWCRegion() const { return *asWCRegionPtr(); }
191
192} // namespace casacore
193
194#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.
LattRegionHolder(const LCRegion &)
Construct from a region based on lattice coordinates.
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40