casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnnPolygon.h
Go to the documentation of this file.
1 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
3 //# License for more details.
4 //#
5 //# You should have received a copy of the GNU Library General Public License
6 //# along with this library; if not, write to the Free Software Foundation,
7 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
8 //#
9 //# Correspondence concerning AIPS++ should be addressed as follows:
10 //# Internet email: aips2-request@nrao.edu.
11 //# Postal address: AIPS++ Project Office
12 //# National Radio Astronomy Observatory
13 //# 520 Edgemont Road
14 //# Charlottesville, VA 22903-2475 USA
15 //#
16 
17 #ifndef ANNOTATIONS_ANNPOLYGON_H
18 #define ANNOTATIONS_ANNPOLYGON_H
19 
20 #include <casa/aips.h>
22 
23 namespace casa {
24 
25 // <summary>
26 // This class represents a single polygon (in position coordinates) annotation specified
27 // in an ascii region file as proposed in CAS-2285
28 // </summary>
29 // <author>Dave Mehringer</author>
30 // <use visibility=export>
31 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
32 // </reviewed>
33 // <prerequisite>
34 
35 // </prerequisite>
36 
37 // <etymology>
38 // Holds the specification of a polygon annotation.
39 // </etymology>
40 
41 // <synopsis>
42 // This class represents a polygon annotation.
43 // </synopsis>
44 
45 
46 class AnnPolygon: public AnnRegion {
47 
48 public:
49 
50  AnnPolygon(
51  const casacore::Vector<casacore::Quantity>& xPositions,
52  const casacore::Vector<casacore::Quantity>& yPositions,
53  const casacore::String& dirRefFrameString,
54  const casacore::CoordinateSystem& csys,
55  const casacore::IPosition& imShape,
56  const casacore::Quantity& beginFreq,
57  const casacore::Quantity& endFreq,
58  const casacore::String& freqRefFrameString,
59  const casacore::String& dopplerString,
60  const casacore::Quantity& restfreq,
62  const casacore::Bool annotationOnly,
63  const casacore::Bool requireImageRegion=true
64  );
65 
66  // Simplified constructor.
67  // all frequencies are used (these can be set after construction).
68  // xPositions and yPositions
69  // must be in the same frame as the csys direction coordinate.
70  // is a region (not just an annotation), although this value can be changed after
71  // construction.
72  AnnPolygon(
73  const casacore::Vector<casacore::Quantity>& xPositions,
74  const casacore::Vector<casacore::Quantity>& yPositions,
75  const casacore::CoordinateSystem& csys,
76  const casacore::IPosition& imShape,
78  const casacore::Bool requireImageRegion=true
79  );
80 
81  // implicit copy constructor and destructor are fine
82 
83  AnnPolygon& operator=(const AnnPolygon& other);
84 
85  // get the vertices converted to the coordinate system used at construction.
87 
88  // get the world coordinates of the polygon vertices
89  void worldVertices(std::vector<casacore::Quantity>& x, std::vector<casacore::Quantity>& y) const;
90 
91  // get the pixel coordinates of the polygon vertices
92  void pixelVertices(std::vector<casacore::Double>& x, std::vector<casacore::Double>& y) const;
93 
94 
95  virtual std::ostream& print(std::ostream &os) const;
96 
97 protected:
98  // for rectangle subclasses
99  AnnPolygon(
101  const casacore::Quantity& blcx,
102  const casacore::Quantity& blcy,
103  const casacore::Quantity& trcx,
104  const casacore::Quantity& trcy,
105  const casacore::String& dirRefFrameString,
106  const casacore::CoordinateSystem& csys,
107  const casacore::IPosition& imShape,
108  const casacore::Quantity& beginFreq,
109  const casacore::Quantity& endFreq,
110  const casacore::String& freqRefFrameString,
111  const casacore::String& dopplerString,
112  const casacore::Quantity& restfreq,
114  const casacore::Bool annotationOnly,
115  const casacore::Bool requireImageRegion=true
116  );
117 
118  // Simplified constructor.
119  // all frequencies are used (these can be set after construction).
120  // blcx, blcy, trcx, and trcy
121  // must be in the same frame as the csys direction coordinate.
122  // is a region (not just an annotation), although this value can be changed after
123  // construction.
124  AnnPolygon(
125  AnnotationBase::Type shape,
126  const casacore::Quantity& blcx,
127  const casacore::Quantity& blcy,
128  const casacore::Quantity& trcx,
129  const casacore::Quantity& trcy,
130  const casacore::CoordinateSystem& csys,
131  const casacore::IPosition& imShape,
133  const casacore::Bool requireImageRegion=true
134  );
135 
136  // For centered rectangles
137  AnnPolygon(
138  AnnotationBase::Type shape,
139  const casacore::Quantity& centerx,
140  const casacore::Quantity& centery,
141  const casacore::Quantity& widthx,
142  const casacore::Quantity& widthy,
143  const casacore::Quantity& positionAngle,
144  const casacore::String& dirRefFrameString,
145  const casacore::CoordinateSystem& csys,
146  const casacore::IPosition& imShape,
147  const casacore::Quantity& beginFreq,
148  const casacore::Quantity& endFreq,
149  const casacore::String& freqRefFrameString,
150  const casacore::String& dopplerString,
151  const casacore::Quantity& restfreq,
153  const casacore::Bool annotationOnly,
154  const casacore::Bool requireImageRegion=true
155  );
156 
157  // Simplified constructor.
158  // all frequencies are used (these can be set after construction).
159  // centerx and centery
160  // must be in the same frame as the csys direction coordinate.
161  // is a region (not just an annotation), although this value can be changed after
162  // construction.
163  AnnPolygon(
164  AnnotationBase::Type shape,
165  const casacore::Quantity& centerx,
166  const casacore::Quantity& centery,
167  const casacore::Quantity& widthx,
168  const casacore::Quantity& widthy,
169  const casacore::Quantity& positionAngle,
170  const casacore::CoordinateSystem& csys,
171  const casacore::IPosition& imShape,
173  const casacore::Bool requireImageRegion=true
174  );
175 
176 private:
178 
179  void _init();
180 
181  void _initCorners(
182  const casacore::Quantity& blcx,
183  const casacore::Quantity& blcy,
184  const casacore::Quantity& trcx,
185  const casacore::Quantity& trcy
186  );
187 
188  void _initCorners(
189  const casacore::MDirection& blc,
190  const casacore::MDirection& corner2,
191  const casacore::MDirection& trc,
192  const casacore::MDirection& corner4
193  );
194 
196  const casacore::Quantity& centerx,
197  const casacore::Quantity& centery,
198  const casacore::Quantity& widthx,
199  const casacore::Quantity& widthy,
200  const casacore::Quantity& positionAngle
201  );
202 
203  void _doCorners(const casacore::Quantity& widthx, const casacore::Quantity widthy);
204 
205 };
206 
207 }
208 
209 #endif /* ASCIIPOLYGONREGION_H_ */
casacore::Vector< casacore::Quantity > _origYPos
Definition: AnnPolygon.h:177
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Vector< casacore::MDirection > getCorners() const
get the vertices converted to the coordinate system used at construction.
A Measure: astronomical direction.
Definition: MDirection.h:174
A 1-D Specialization of the Array class.
AnnPolygon(const casacore::Vector< casacore::Quantity > &xPositions, const casacore::Vector< casacore::Quantity > &yPositions, const casacore::String &dirRefFrameString, const casacore::CoordinateSystem &csys, const casacore::IPosition &imShape, const casacore::Quantity &beginFreq, const casacore::Quantity &endFreq, const casacore::String &freqRefFrameString, const casacore::String &dopplerString, const casacore::Quantity &restfreq, const casacore::Vector< casacore::Stokes::StokesTypes > stokes, const casacore::Bool annotationOnly, const casacore::Bool requireImageRegion=true)
void _doCorners(const casacore::Quantity &widthx, const casacore::Quantity widthy)
virtual std::ostream & print(std::ostream &os) const
void _initCenterRectCorners(const casacore::Quantity &centerx, const casacore::Quantity &centery, const casacore::Quantity &widthx, const casacore::Quantity &widthy, const casacore::Quantity &positionAngle)
This class represents a annotation referring to a region specified in an ascii region file as propose...
Definition: AnnRegion.h:53
void pixelVertices(std::vector< casacore::Double > &x, std::vector< casacore::Double > &y) const
get the pixel coordinates of the polygon vertices
This class represents a single polygon (in position coordinates) annotation specified in an ascii reg...
Definition: AnnPolygon.h:46
void worldVertices(std::vector< casacore::Quantity > &x, std::vector< casacore::Quantity > &y) const
get the world coordinates of the polygon vertices
void _initCorners(const casacore::Quantity &blcx, const casacore::Quantity &blcy, const casacore::Quantity &trcx, const casacore::Quantity &trcy)
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:1944
AnnPolygon & operator=(const AnnPolygon &other)
implicit copy constructor and destructor are fine
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Interconvert pixel and world coordinates.
casacore::Vector< casacore::Quantity > _origXPos
Definition: AnnPolygon.h:177