casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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.
91  LattRegionHolder (const LCRegion&);
92 
93  // Construct from a slicer based on lattice coordinates.
94  LattRegionHolder (const LCSlicer&);
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>
100  explicit LattRegionHolder (LCRegion*);
101  explicit LattRegionHolder (LCSlicer*);
102  // </group>
103 
104  // Copy constructor (copy semantics).
105  LattRegionHolder (const LattRegionHolder& other);
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).
146  virtual LatticeRegion toLatticeRegion (const CoordinateSystem& cSys,
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;
156  virtual LattRegionHolder* makeComplement() const;
157  // </group>
158 
159 protected:
160  // Construct for the given dimensionality (for derived classes).
161  explicit LattRegionHolder (uInt ndim);
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
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual Bool isWCRegion() const
virtual LattRegionHolder * makeUnion(const LattRegionHolder &other) const
Form a compound from this and the other region.
LattRegionHolder(const LCRegion &)
Construct from a region based on lattice coordinates.
virtual LattRegionHolder * makeDifference(const LattRegionHolder &other) const
uInt ndim() const
Get the dimensionality.
virtual LattRegionHolder * makeIntersection(const LattRegionHolder &other) const
Bool isLCRegion() const
Test if the underlying region is an LCRegion, etc.
virtual LattRegionHolder * makeComplement() const
virtual LattRegionHolder * clone() const
Clone the object.
LattRegionHolder & operator=(const LattRegionHolder &other)
Assignment (copy semantics).
virtual Bool operator==(const LattRegionHolder &other) const
Comparison.
Class to hold a region of interest in an image.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1987
Class to define a rectangular box of interest with strides.
Definition: LCSlicer.h:84
LatticeRegion toLatticeRegion(const IPosition &shape) const
Convert to a LatticeRegion using the given shape.
Base class to define world coordinate regions of interest in an image.
Definition: WCRegion.h:95
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
Bool operator!=(const LattRegionHolder &other) const
const LCSlicer * asLCSlicerPtr() const
Interconvert pixel and world coordinates.
unsigned int uInt
Definition: aipstype.h:51
const LCRegion * asLCRegionPtr() const
Get the region as a pointer to a LCRegion, LCSlicer, or WCRegion.
virtual const WCRegion * asWCRegionPtr() const
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87