casacore
Loading...
Searching...
No Matches
RegionManager.h
Go to the documentation of this file.
1//# RegionManager.h: framework independent class that provides
2//# functionality to tool of same name
3//# Copyright (C) 2007
4//# Associated Universities, Inc. Washington DC, USA.
5//#
6//# This program is free software; you can redistribute it and/or modify it
7//# under the terms of the GNU General Public License as published by the Free
8//# Software Foundation; either version 2 of the License, or (at your option)
9//# any later version.
10//#
11//# This program is distributed in the hope that it will be useful, but WITHOUT
12//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14//# more details.
15//#
16//# You should have received a copy of the GNU General Public License along
17//# with this program; if not, write to the Free Software Foundation, Inc.,
18//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19//#
20//# Correspondence concerning AIPS++ should be addressed as follows:
21//# Internet email: casa-feedback@nrao.edu.
22//# Postal address: AIPS++ Project Office
23//# National Radio Astronomy Observatory
24//# 520 Edgemont Road
25//# Charlottesville, VA 22903-2475 USA
26
27#ifndef IMAGES_REGIONMANAGER_H
28#define IMAGES_REGIONMANAGER_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Quanta/Quantum.h>
32#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
33#include <casacore/lattices/LRegions/RegionType.h>
34#include <casacore/tables/Tables/Table.h>
35#include <casacore/casa/Arrays/ArrayFwd.h>
36
37namespace casacore {
38
48 class LogIO;
49 class String;
50 class Record;
51 class WCRegion;
52 class WCBox;
53 template<class T> class PtrBlock;
54 class ImageRegion;
55
57 {
58
59
60 public:
61
62 //blank constructor
65 virtual ~RegionManager();
66 String absreltype(const Int absrelval=0);
67
68 //Some little but useful tidbits.
69 static Bool isPixelRegion(const ImageRegion& reg);
70 static Bool isWorldRegion(const ImageRegion& reg);
71 void setcoordsys(const CoordinateSystem& csys);
73
74 //LCSlicer box
75 Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
76 const Vector<Double>& inc, const String& absrel,
77 const Bool frac, const String& comment="");
78 //LCBox box
79 static Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
80 const Vector<Int>& shape, const String& comment="");
82 const Vector<Quantity>& trc,
83 const Vector<Int>& pixelaxes,
84 const CoordinateSystem& csys,
85 const String& absrel, const String& comment);
87 const Vector<String>& trc,
88 const Vector<Int>& pixelaxes,
89 const CoordinateSystem& csys,
90 const String& absrel, const String& comment);
92 const Vector<Quantity>& trc,
93 const Vector<Int>& pixelaxes,
94 const String& absrel, const String& comment);
96 const Vector<String>& trc,
97 const Vector<Int>& pixelaxes,
98 const String& absrel, const String& comment);
100 const Vector<Quantity>& trc,
101 const Vector<Int>& pixelaxes,
102 const CoordinateSystem& csys,
103 const String& absrel="abs" );
104 //Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed
105 //to be 0,1,...
107 const Vector<Quantity>& y,
108 const Vector<Int>& pixelaxes,
109 const CoordinateSystem& csys,
110 const String& absrel);
111 //wpolygon version without csys...throws an exception if
112 //setcoordsys is not run
114 const Vector<Quantity>& y,
115 const Vector<Int>& pixelaxes,
116 const String& absrel);
117
119 const Quantity& xc,
120 const Quantity& yc,
121 const Quantity& a,
122 const Quantity& b,
123 const Quantity& pa,
124 const uInt pixelAxis0,
125 const uInt pixelAxis1,
126 const CoordinateSystem& csys,
127 const String& absrel
128 );
129
130 //wellipse version without csys...throws an exception if
131 //setcoordsys is not run
133 const Quantity& xc,
134 const Quantity& yc,
135 const Quantity& a,
136 const Quantity& b,
137 const Quantity& pa,
138 const uInt pixelAxis0,
139 const uInt pixelAxis1,
140 const String& absrel
141 ) const;
142
144 const Vector<Quantity>& center,
145 const Quantity& radius,
146 const Vector<Int>& pixelaxes,
147 const CoordinateSystem& csys,
148 const String& absrel
149 );
150 //wsphere version without csys...throws an exception if
151 //setcoordsys is not run
153 const Vector<Quantity>& center,
154 const Quantity& radius,
155 const Vector<Int>& pixelaxes,
156 const String& absrel
157 ) const;
158
160 const Vector<Quantity>& center,
161 const Vector<Quantity>& radii,
162 const Vector<Int>& pixelaxes,
163 const CoordinateSystem& csys,
164 const String& absrel
165 );
166
168 const Vector<Quantity>& center,
169 const Vector<Quantity>& radii,
170 const Vector<Int>& pixelaxes,
171 const String& absrel
172 ) const;
173
175 const Vector<Quantity>& center,
176 const Vector<Quantity>& innerRadii,
177 const Vector<Quantity>& outerRadii,
178 const Vector<Int>& pixelaxes,
179 const CoordinateSystem& csys,
180 const String& absrel
181 );
182
184 const Vector<Quantity>& center,
185 const Vector<Quantity>& innerRadii,
186 const Vector<Quantity>& outerRadii,
187 const Vector<Int>& pixelaxes,
188 const String& absrel
189 ) const;
190
191 static ImageRegion* wmask(const String& command);
192
193
194 /**************************************************************
195 ** Routines for combining regions **
196 ** **
197 ** Note: Many of the WCXxx classes which are used to do the **
198 ** work can take multiple regions at once, why not **
199 ** accept a ptr block of Image Regions then? **
200 **************************************************************/
201
202 //Various versions of creating a complement region
206
207 //Various versions of concatenating a region onto another.
212
213
214 //Various versions of handling the difference of regions
215 ImageRegion* doDifference(const WCRegion& reg1, const WCRegion& reg2);
218
219 //Different versions of intersecting regions
220 ImageRegion* doIntersection(const WCRegion& reg1, const WCRegion& reg2);
223
224 //Different versions of unioning regions
225 ImageRegion* doUnion(const WCRegion& reg1, const WCRegion& reg2);
227 ImageRegion* doUnion(const ImageRegion& reg1, const ImageRegion& reg2) const;
228
229
230 /**************************************************************
231 ** Routines for reading/writing regions **
232 **************************************************************/
233
234 //Reading of a file containing an ImageRegion in the AipsIO format dump
235 static Record* readImageFile( String filename, String regionname );
236 //Writing a file of the AipsIO dump of the record representation of the region
237 static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
238
239
240 //save region into a table (image, blank table or any other such)
242 const ImageRegion& imreg,
243 const String& regName, Bool asmask=False);
244
245 String recordToTable(const String& tabName, const RecordInterface& rec,
246 const String& regName="", Bool asmask=False);
247 //recover region from table
248 Record* tableToRecord(const String& tabName, const String& regname);
249
250 //names of regions in table
252
253 //Remove a region from table...refuse is regionname is ""
254 Bool removeRegionInTable(const String& tabName, const String& regName);
255
256
257 protected:
258 inline LogIO* _getLog() const { return itsLog; }
259
260 private:
262 std::unique_ptr<CoordinateSystem> itsCSys;
263 // Function to return the internal Table object to the RegionHandler.
264 static Table& getTable (void* ptr, Bool writable);
265 //Convert a string to Quantity
266 void toQuantity(Quantity& out, const String& in);
268
269 };
270
271
272} // casa namespace
273#endif
274
A drop-in replacement for Block<T*>.
Definition Block.h:812
std::unique_ptr< CoordinateSystem > itsCSys
ImageRegion * doconcatenation(const PtrBlock< const WCRegion * > &regions, const WCBox &box)
ImageRegion * wellipse(const Quantity &xc, const Quantity &yc, const Quantity &a, const Quantity &b, const Quantity &pa, const uInt pixelAxis0, const uInt pixelAxis1, const String &absrel) const
wellipse version without csys...throws an exception if setcoordsys is not run
ImageRegion * doUnion(const WCRegion &reg1, const WCRegion &reg2)
Different versions of unioning regions.
Record * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const String &absrel, const String &comment)
Vector< String > namesInTable(const String &tabName)
names of regions in table
static ImageRegion * wellipsoid(const Vector< Quantity > &center, const Vector< Quantity > &radii, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
ImageRegion * doComplement(const WCRegion &reg1)
Various versions of creating a complement region.
ImageRegion * wellipsoid(const Vector< Quantity > &center, const Vector< Quantity > &radii, const Vector< Int > &pixelaxes, const String &absrel) const
ImageRegion * doDifference(const PtrBlock< const WCRegion * > &reg1)
ImageRegion * doIntersection(const ImageRegion &reg1, const ImageRegion &reg2)
static ImageRegion * wshell(const Vector< Quantity > &center, const Vector< Quantity > &innerRadii, const Vector< Quantity > &outerRadii, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
static Bool isWorldRegion(const ImageRegion &reg)
static Record * box(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Int > &shape, const String &comment="")
LCBox box.
static ImageRegion * wellipse(const Quantity &xc, const Quantity &yc, const Quantity &a, const Quantity &b, const Quantity &pa, const uInt pixelAxis0, const uInt pixelAxis1, const CoordinateSystem &csys, const String &absrel)
static Bool writeImageFile(const String &file, const String &regionname, const Record &regionRecord)
Writing a file of the AipsIO dump of the record representation of the region.
Record * wbox(const Vector< String > &blc, const Vector< String > &trc, const Vector< Int > &pixelaxes, const String &absrel, const String &comment)
String absreltype(const Int absrelval=0)
ImageRegion * wpolygon(const Vector< Quantity > &x, const Vector< Quantity > &y, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed to be 0,1,...
void setcoordsys(const CoordinateSystem &csys)
ImageRegion * doComplement(const ImageRegion &reg1)
String imageRegionToTable(const String &tabName, const ImageRegion &imreg, const String &regName, Bool asmask=False)
save region into a table (image, blank table or any other such)
ImageRegion * doComplement(const PtrBlock< const WCRegion * > &reg1)
String recordToTable(const String &tabName, const RecordInterface &rec, const String &regName="", Bool asmask=False)
ImageRegion * wshell(const Vector< Quantity > &center, const Vector< Quantity > &innerRadii, const Vector< Quantity > &outerRadii, const Vector< Int > &pixelaxes, const String &absrel) const
static ImageRegion * wsphere(const Vector< Quantity > &center, const Quantity &radius, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
Record * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
ImageRegion * doIntersection(const WCRegion &reg1, const WCRegion &reg2)
Different versions of intersecting regions.
static Record * readImageFile(String filename, String regionname)
Reading of a file containing an ImageRegion in the AipsIO format dump.
ImageRegion * doConcatenation(const Record &regions, const TableRecord &box)
LogIO * _getLog() const
static Table & getTable(void *ptr, Bool writable)
Function to return the internal Table object to the RegionHandler.
ImageRegion * doUnion(const PtrBlock< const WCRegion * > &reg1)
Record * wbox(const Vector< String > &blc, const Vector< String > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
static Bool isPixelRegion(const ImageRegion &reg)
Some little but useful tidbits.
ImageRegion * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel="abs")
Record * tableToRecord(const String &tabName, const String &regname)
recover region from table
const CoordinateSystem & getcoordsys() const
void toQuantity(Quantity &out, const String &in)
Convert a string to Quantity.
ImageRegion * doConcatenation(const PtrBlock< const ImageRegion * > &regions, const TableRecord &box)
static ImageRegion * wmask(const String &command)
ImageRegion * doUnion(const ImageRegion &reg1, const ImageRegion &reg2) const
RegionManager()
blank constructor
ImageRegion * doDifference(const ImageRegion &reg1, const ImageRegion &reg2)
Bool removeRegionInTable(const String &tabName, const String &regName)
Remove a region from table...refuse is regionname is "".
ImageRegion * wpolygon(const Vector< Quantity > &x, const Vector< Quantity > &y, const Vector< Int > &pixelaxes, const String &absrel)
wpolygon version without csys...throws an exception if setcoordsys is not run
ImageRegion * doDifference(const WCRegion &reg1, const WCRegion &reg2)
Various versions of handling the difference of regions.
ImageRegion * doIntersection(const PtrBlock< const WCRegion * > &reg1)
ImageRegion * wsphere(const Vector< Quantity > &center, const Quantity &radius, const Vector< Int > &pixelaxes, const String &absrel) const
wsphere version without csys...throws an exception if setcoordsys is not run
Record * box(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Double > &inc, const String &absrel, const Bool frac, const String &comment="")
LCSlicer box.
ImageRegion * doConcatenation(const WCRegion &region, const WCBox &box)
Various versions of concatenating a region onto another.
RegionManager(const CoordinateSystem &csys)
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40