casacore
LCEllipsoid.h
Go to the documentation of this file.
1 //# LCEllipsoid.h: Define an N-dimensional ellipsoidal region of interest
2 //# Copyright (C) 1997,1998
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_LCELLIPSOID_H
29 #define LATTICES_LCELLIPSOID_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/lattices/LRegions/LCRegionFixed.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Define an N-dimensional ellipsoidal region of interest.
41 // </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="" date="" tests="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class=LCRegion>LCRegion</linkto>
50 // </prerequisite>
51 
52 // <synopsis>
53 // The LCEllipsoid class is a specialization of class
54 // <linkto class=LCRegion>LCRegion</linkto>.
55 // It makes it possible to define an N-dimensional ellipsoidal region
56 // of interest, which includes the border. A separate constructor exists
57 // to define the special case of an N-dimensional sphere.
58 // <br>
59 // The center and the radii of the ellipsoid do not need to be pixel aligned.
60 // The center of the ellipsoid may be outside the lattice.
61 // The current implementation only supports ellipsoids with axes parallel
62 // to the lattice axes except in the case of a 2-D ellipse for which a
63 // constructor is provided for specifying the angle between the x-axis
64 // and major axis of the ellipse.
65 // <p>
66 // It can only be used for a lattice of any dimensionality as long as the
67 // dimensionality of the (hyper-)ellipsoid matches the dimensionality of
68 // the lattice.
69 // </synopsis>
70 
71 // <example>
72 // <srcblock>
73 // </srcblock>
74 // </example>
75 
76 // <todo asof="1997/11/11">
77 // <li> Arguments to have ellipsoid axes not parallel to lattice axes for
78 // dimensions greater than 2. This is a nontrivial problem because of the
79 // complexity of the rotation matrices involved.
80 // </todo>
81 
82 
84 {
85 public:
87 
88  // Construct an N-dimensional sphere with the given center and
89  // radius (in pixels). The center is pixel-aligned.
90  LCEllipsoid (const IPosition& center, Float radius,
91  const IPosition& latticeShape);
92 
93  // Construct an N-dimensional sphere with the given center and
94  // radius (in pixels). The center does not need to be pixel-aligned.
95  // <group>
97  const IPosition& latticeShape);
99  const IPosition& latticeShape);
100  // </group>
101 
102  // Construct an N-dimensional ellipsoid with the given center and
103  // radii (in pixels). The center does not need to be pixel-aligned.
104  // (the radii are half the length of the axes of the ellipsoid).
105  // <group>
107  const IPosition& latticeShape);
109  const IPosition& latticeShape);
110  // </group>
111 
112  // Construct a two dimensional ellipse with theta being the angle from
113  // the x-axis to the major axis of the ellipse in radians.
115  const Float xcenter, const Float ycenter,
116  const Float majorAxis, const Float minorAxis,
117  const Float theta, const IPosition& latticeShape
118  );
119 
120  // Copy constructor (reference semantics).
121  LCEllipsoid (const LCEllipsoid& other);
122 
123  virtual ~LCEllipsoid();
124 
125  // Assignment (copy semantics).
127 
128  // Comparison
129  virtual Bool operator== (const LCRegion& other) const;
130 
131  // Make a copy of the derived object.
132  virtual LCRegion* cloneRegion() const;
133 
134  // Get the center.
135  const Vector<Float>& center() const;
136 
137  // Get the radii.
138  const Vector<Float>& radii() const;
139 
140  // Get the angle of the major axis of the ellipse relative to the x-axis
141  // 2-D only, throws exception if ellipse is not 2-D.
142  const Float& theta() const;
143 
144  // Get the class name (to store in the record).
145  static String className();
146 
147  // Get the region type. Returns className()
148  virtual String type() const;
149 
150  // Convert the (derived) object to a record.
151  virtual TableRecord toRecord (const String& tableName) const;
152 
153  // Convert correct object from a record.
155  const String& tableName);
156 
157 protected:
158  // Construct another LCBox (for e.g. another lattice) by moving
159  // this one. It recalculates the bounding box.
160  // A positive translation value indicates "to right".
161  virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
162  const IPosition& newLatticeShape) const;
163 
164 private:
165  // Fill the itsCenter vector from an IPosition.
166  void fillCenter (const IPosition& center);
167 
168  // Make the bounding box from center, radii, and shape.
170  const IPosition& latticeShape);
171 
172  // Define the mask to indicate which elements are inside the ellipsoid.
173  void defineMask();
174 
175  //for 2-D ellipse with non-zero theta. Works for both cases center
176  // inside or outside the lattice.
178 
179  // set the mask in the case the center lies outside the lattice
180  void _doOutside();
181 
184  // small offset to guard against roundoff error
186  // for 2-D case only
188  // is center inside the lattice?
190 };
191 
192 
193 inline const Vector<Float>& LCEllipsoid::center() const
194 {
195  return itsCenter;
196 }
197 inline const Vector<Float>& LCEllipsoid::radii() const
198 {
199  return itsRadii;
200 }
201 
202 
203 
204 } //# NAMESPACE CASACORE - END
205 
206 #endif
static LCEllipsoid * fromRecord(const TableRecord &, const String &tableName)
Convert correct object from a record.
Vector< Float > itsCenter
Definition: LCEllipsoid.h:182
void _doOutside()
set the mask in the case the center lies outside the lattice
LCEllipsoid(const Vector< Float > &center, const Vector< Float > &radii, const IPosition &latticeShape)
Construct an N-dimensional ellipsoid with the given center and radii (in pixels).
const Vector< Float > & center() const
Get the center.
Definition: LCEllipsoid.h:193
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
void defineMask()
Define the mask to indicate which elements are inside the ellipsoid.
void _defineMask2D()
for 2-D ellipse with non-zero theta.
LCEllipsoid & operator=(const LCEllipsoid &other)
Assignment (copy semantics).
const Vector< Float > & radii() const
Get the radii.
Definition: LCEllipsoid.h:197
virtual String type() const
Get the region type.
virtual Bool operator==(const LCRegion &other) const
Comparison.
LCEllipsoid(const Float xcenter, const Float ycenter, const Float majorAxis, const Float minorAxis, const Float theta, const IPosition &latticeShape)
Construct a two dimensional ellipse with theta being the angle from the x-axis to the major axis of t...
LCEllipsoid(const LCEllipsoid &other)
Copy constructor (reference semantics).
Slicer makeBox(const Vector< Float > &radii, const IPosition &latticeShape)
Make the bounding box from center, radii, and shape.
Vector< Float > itsRadii
Definition: LCEllipsoid.h:183
LCEllipsoid(const IPosition &center, Float radius, const IPosition &latticeShape)
Construct an N-dimensional sphere with the given center and radius (in pixels).
LCEllipsoid(const Vector< Double > &center, const Vector< Double > &radii, const IPosition &latticeShape)
Bool _centerIsInside
is center inside the lattice?
Definition: LCEllipsoid.h:189
const Float & theta() const
Get the angle of the major axis of the ellipse relative to the x-axis 2-D only, throws exception if e...
void fillCenter(const IPosition &center)
Fill the itsCenter vector from an IPosition.
Vector< Float > _epsilon
small offset to guard against roundoff error
Definition: LCEllipsoid.h:185
LCEllipsoid(const Vector< Float > &center, Float radius, const IPosition &latticeShape)
Construct an N-dimensional sphere with the given center and radius (in pixels).
Float _theta
for 2-D case only
Definition: LCEllipsoid.h:187
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
LCEllipsoid(const Vector< Double > &center, Double radius, const IPosition &latticeShape)
static String className()
Get the class name (to store in the record).
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCBox (for e.g.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
float Float
Definition: aipstype.h:54
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55