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 class ImageRegion;
54
56 {
57
58
59 public:
60
61 //blank constructor
64 virtual ~RegionManager();
65 String absreltype(const Int absrelval=0);
66
67 //Some little but useful tidbits.
68 static Bool isPixelRegion(const ImageRegion& reg);
69 static Bool isWorldRegion(const ImageRegion& reg);
70 void setcoordsys(const CoordinateSystem& csys);
72
73 //LCSlicer box
74 Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
75 const Vector<Double>& inc, const String& absrel,
76 const Bool frac, const String& comment="");
77 //LCBox box
78 static Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
79 const Vector<Int>& shape, const String& comment="");
81 const Vector<Quantity>& trc,
82 const Vector<Int>& pixelaxes,
83 const CoordinateSystem& csys,
84 const String& absrel, const String& comment);
86 const Vector<String>& trc,
87 const Vector<Int>& pixelaxes,
88 const CoordinateSystem& csys,
89 const String& absrel, const String& comment);
91 const Vector<Quantity>& trc,
92 const Vector<Int>& pixelaxes,
93 const String& absrel, const String& comment);
95 const Vector<String>& trc,
96 const Vector<Int>& pixelaxes,
97 const String& absrel, const String& comment);
99 const Vector<Quantity>& trc,
100 const Vector<Int>& pixelaxes,
101 const CoordinateSystem& csys,
102 const String& absrel="abs" );
103 //Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed
104 //to be 0,1,...
106 const Vector<Quantity>& y,
107 const Vector<Int>& pixelaxes,
108 const CoordinateSystem& csys,
109 const String& absrel);
110 //wpolygon version without csys...throws an exception if
111 //setcoordsys is not run
113 const Vector<Quantity>& y,
114 const Vector<Int>& pixelaxes,
115 const String& absrel);
116
118 const Quantity& xc,
119 const Quantity& yc,
120 const Quantity& a,
121 const Quantity& b,
122 const Quantity& pa,
123 const uInt pixelAxis0,
124 const uInt pixelAxis1,
125 const CoordinateSystem& csys,
126 const String& absrel
127 );
128
129 //wellipse version without csys...throws an exception if
130 //setcoordsys is not run
132 const Quantity& xc,
133 const Quantity& yc,
134 const Quantity& a,
135 const Quantity& b,
136 const Quantity& pa,
137 const uInt pixelAxis0,
138 const uInt pixelAxis1,
139 const String& absrel
140 ) const;
141
143 const Vector<Quantity>& center,
144 const Quantity& radius,
145 const Vector<Int>& pixelaxes,
146 const CoordinateSystem& csys,
147 const String& absrel
148 );
149 //wsphere version without csys...throws an exception if
150 //setcoordsys is not run
152 const Vector<Quantity>& center,
153 const Quantity& radius,
154 const Vector<Int>& pixelaxes,
155 const String& absrel
156 ) const;
157
159 const Vector<Quantity>& center,
160 const Vector<Quantity>& radii,
161 const Vector<Int>& pixelaxes,
162 const CoordinateSystem& csys,
163 const String& absrel
164 );
165
167 const Vector<Quantity>& center,
168 const Vector<Quantity>& radii,
169 const Vector<Int>& pixelaxes,
170 const String& absrel
171 ) const;
172
174 const Vector<Quantity>& center,
175 const Vector<Quantity>& innerRadii,
176 const Vector<Quantity>& outerRadii,
177 const Vector<Int>& pixelaxes,
178 const CoordinateSystem& csys,
179 const String& absrel
180 );
181
183 const Vector<Quantity>& center,
184 const Vector<Quantity>& innerRadii,
185 const Vector<Quantity>& outerRadii,
186 const Vector<Int>& pixelaxes,
187 const String& absrel
188 ) const;
189
190 static ImageRegion* wmask(const String& command);
191
192
193 /**************************************************************
194 ** Routines for combining regions **
195 ** **
196 ** Note: Many of the WCXxx classes which are used to do the **
197 ** work can take multiple regions at once, why not **
198 ** accept a ptr block of Image Regions then? **
199 **************************************************************/
200
201 //Various versions of creating a complement region
205
206 //Various versions of concatenating a region onto another.
211
212
213 //Various versions of handling the difference of regions
214 ImageRegion* doDifference(const WCRegion& reg1, const WCRegion& reg2);
217
218 //Different versions of intersecting regions
219 ImageRegion* doIntersection(const WCRegion& reg1, const WCRegion& reg2);
222
223 //Different versions of unioning regions
224 ImageRegion* doUnion(const WCRegion& reg1, const WCRegion& reg2);
226 ImageRegion* doUnion(const ImageRegion& reg1, const ImageRegion& reg2) const;
227
228
229 /**************************************************************
230 ** Routines for reading/writing regions **
231 **************************************************************/
232
233 //Reading of a file containing an ImageRegion in the AipsIO format dump
234 static Record* readImageFile( String filename, String regionname );
235 //Writing a file of the AipsIO dump of the record representation of the region
236 static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
237
238
239 //save region into a table (image, blank table or any other such)
241 const ImageRegion& imreg,
242 const String& regName, Bool asmask=False);
243
244 String recordToTable(const String& tabName, const RecordInterface& rec,
245 const String& regName="", Bool asmask=False);
246 //recover region from table
247 Record* tableToRecord(const String& tabName, const String& regname);
248
249 //names of regions in table
251
252 //Remove a region from table...refuse is regionname is ""
253 Bool removeRegionInTable(const String& tabName, const String& regName);
254
255
256 protected:
257 inline LogIO* _getLog() const { return itsLog; }
258
259 private:
261 std::unique_ptr<CoordinateSystem> itsCSys;
262 // Function to return the internal Table object to the RegionHandler.
263 static Table& getTable (void* ptr, Bool writable);
264 //Convert a string to Quantity
265 void toQuantity(Quantity& out, const String& in);
267
268 };
269
270
271} // casa namespace
272#endif
273
std::unique_ptr< CoordinateSystem > itsCSys
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
ImageRegion * doConcatenation(const Block< const ImageRegion * > &regions, const TableRecord &box)
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 * 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)
ImageRegion * doconcatenation(const Block< const WCRegion * > &regions, const WCBox &box)
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)
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.
Record * wbox(const Vector< String > &blc, const Vector< String > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
ImageRegion * doComplement(const Block< const WCRegion * > &reg1)
ImageRegion * doIntersection(const Block< const WCRegion * > &reg1)
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")
ImageRegion * doDifference(const Block< const WCRegion * > &reg1)
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.
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 * doUnion(const Block< 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
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
const String & comment(const RecordFieldId &) const override
Get the comment for this field.
RecordInterface()
The default constructor creates an empty record with a variable structure.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
Quantum< Double > Quantity
Definition Quantum.h:39