casacore
LattRegionHolder.h
Go to the documentation of this file.
1 //# LattRegionHolder.h: Class to hold a region of interest in an image
2 //# Copyright (C) 1999,2001
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_LATTREGIONHOLDER_H
29 #define LATTICES_LATTREGIONHOLDER_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/lattices/LRegions/LatticeRegion.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class CoordinateSystem;
39 class IPosition;
40 class LCRegion;
41 class LCSlicer;
42 class WCRegion;
43 class String;
44 class TableRecord;
45 
46 
47 // <summary>
48 // Class to hold a region of interest in an image.
49 // </summary>
50 
51 // <use visibility=export>
52 
53 // <reviewed reviewer="" date="" tests="">
54 // </reviewed>
55 
56 // <prerequisite>
57 // <li> <linkto class=LCSlicer>LCSlicer</linkto>
58 // <li> <linkto class=WCRegion>LCRegion</linkto>
59 // </prerequisite>
60 
61 // <synopsis>
62 // The only purpose of LattRegionHolder is to have a single object for
63 // the various kinds of regions. It can hold a
64 // <linkto class=LCRegion>LCRegion</linkto>, and
65 // <linkto class=LCSlicer>LCSlicer</linkto>.
66 // </synopsis>
67 
68 // <example>
69 // <srcblock>
70 // </srcblock>
71 // </example>
72 
73 // <motivation>
74 // It was felt that making an abstract base class LatticeRegion for
75 // LCRegion and WCRegion would create undesirable dependencies of
76 // module Lattices on module Coordinates. E.g. it would be impossible
77 // to have a function toWCRegion.
78 // Therefore the container class LattRegionHolder is chosen, from which
79 // the container <linkto class=ImageRegion>ImageRegion</linkto> is derived.
80 // </motivation>
81 
82 //# <todo asof="1997/11/11">
83 //# <li>
84 //# </todo>
85 
86 
88 {
89 public:
90  // Construct from a region based on lattice coordinates.
92 
93  // Construct from a slicer based on lattice coordinates.
95 
96  // Similar constructors as above, but using a pointer.
97  // It takes over the pointer, so the user should not delete the
98  // object. It is deleted by the LattRegionHolder destructor.
99  // <group>
102  // </group>
103 
104  // Copy constructor (copy semantics).
106 
107  virtual ~LattRegionHolder();
108 
109  // Assignment (copy semantics).
111 
112  // Clone the object.
113  virtual LattRegionHolder* clone() const;
114 
115  // Comparison
116  // <group>
117  virtual Bool operator==(const LattRegionHolder& other) const;
118  Bool operator!=(const LattRegionHolder& other) const;
119  // </group>
120 
121  // Test if the underlying region is an LCRegion, etc.
122  // <group>
123  Bool isLCRegion() const;
124  Bool isLCSlicer() const;
125  virtual Bool isWCRegion() const;
126  // </group>
127 
128  // Get the region as a pointer to a LCRegion, LCSlicer, or WCRegion.
129  // An exception is thrown if the region is not the correct type.
130  // Functions <src>isWCRegion()</src>, etc. can be used to test the type.
131  // <group>
132  const LCRegion* asLCRegionPtr() const;
133  const LCSlicer* asLCSlicerPtr() const;
134  virtual const WCRegion* asWCRegionPtr() const;
135  // </group>
136 
137  // Get the dimensionality.
138  uInt ndim() const;
139 
140  // Convert to a LatticeRegion using the given shape.
142 
143  // Convert to a LatticeRegion using the given coordinate system
144  // (with reference pixel) and shape.
145  // It will also make the region complete (absolute and non-fractional).
147  const IPosition& shape) const;
148 
149  // Form a compound from this and the other region.
150  // <group>
151  virtual LattRegionHolder* makeUnion (const LattRegionHolder& other) const;
153  (const LattRegionHolder& other) const;
155  (const LattRegionHolder& other) const;
157  // </group>
158 
159 protected:
160  // Construct for the given dimensionality (for derived classes).
162 
163 private:
167 };
168 
169 
171 {
172  return (itsLC != 0);
173 }
175 {
176  return (itsSlicer != 0);
177 }
179 {
180  return (! operator== (other));
181 }
183 {
184  return itsNdim;
185 }
186 
187 
188 
189 } //# NAMESPACE CASACORE - END
190 
191 #endif
virtual const WCRegion * asWCRegionPtr() const
virtual LattRegionHolder * makeDifference(const LattRegionHolder &other) const
LattRegionHolder(const LCRegion &)
Construct from a region based on lattice coordinates.
virtual Bool isWCRegion() 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 LattRegionHolder * makeIntersection(const LattRegionHolder &other) const
const LCSlicer * asLCSlicerPtr() const
virtual Bool operator==(const LattRegionHolder &other) const
Comparison.
LattRegionHolder(const LCSlicer &)
Construct from a slicer based on lattice coordinates.
Bool operator!=(const LattRegionHolder &other) const
virtual LattRegionHolder * clone() const
Clone the object.
uInt ndim() const
Get the dimensionality.
virtual LattRegionHolder * makeUnion(const LattRegionHolder &other) const
Form a compound from this and the other region.
LatticeRegion toLatticeRegion(const IPosition &shape) const
Convert to a LatticeRegion using the given shape.
Bool isLCRegion() const
Test if the underlying region is an LCRegion, etc.
LattRegionHolder(LCRegion *)
Similar constructors as above, but using a pointer.
LattRegionHolder(uInt ndim)
Construct for the given dimensionality (for derived classes).
LattRegionHolder(const LattRegionHolder &other)
Copy constructor (copy semantics).
const LCRegion * asLCRegionPtr() const
Get the region as a pointer to a LCRegion, LCSlicer, or WCRegion.
LattRegionHolder & operator=(const LattRegionHolder &other)
Assignment (copy semantics).
virtual LattRegionHolder * makeComplement() const
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42