casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
28 
29 #ifndef IMAGES_REGIONMANAGER_H
30 #define IMAGES_REGIONMANAGER_H
31 
32 #include <casacore/casa/aips.h>
37 
38 
39 namespace casacore {
40 
50  class LogIO;
51  class String;
52  class Record;
53  template<class T> class Vector;
54  class WCRegion;
55  class WCBox;
56  template<class T> class PtrBlock;
57  class ImageRegion;
58 
60  {
61 
62 
63  public:
64 
65  //blank constructor
66  RegionManager();
67  RegionManager(const CoordinateSystem& csys);
68  virtual ~RegionManager();
69  String absreltype(const Int absrelval=0);
70 
71  //Some little but useful tidbits.
72  static Bool isPixelRegion(const ImageRegion& reg);
73  static Bool isWorldRegion(const ImageRegion& reg);
74  void setcoordsys(const CoordinateSystem& csys);
75  const CoordinateSystem& getcoordsys() const ;
76 
77  //LCSlicer box
78  Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
79  const Vector<Double>& inc, const String& absrel,
80  const Bool frac, const String& comment="");
81  //LCBox box
82  static Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
83  const Vector<Int>& shape, const String& comment="");
84  Record* wbox(const Vector<Quantity>& blc,
85  const Vector<Quantity>& trc,
86  const Vector<Int>& pixelaxes,
87  const CoordinateSystem& csys,
88  const String& absrel, const String& comment);
89  Record* wbox(const Vector<String>& blc,
90  const Vector<String>& trc,
91  const Vector<Int>& pixelaxes,
92  const CoordinateSystem& csys,
93  const String& absrel, const String& comment);
94  Record* wbox(const Vector<Quantity>& blc,
95  const Vector<Quantity>& trc,
96  const Vector<Int>& pixelaxes,
97  const String& absrel, const String& comment);
98  Record* wbox(const Vector<String>& blc,
99  const Vector<String>& trc,
100  const Vector<Int>& pixelaxes,
101  const String& absrel, const String& comment);
102  ImageRegion* wbox(const Vector<Quantity>& blc,
103  const Vector<Quantity>& trc,
104  const Vector<Int>& pixelaxes,
105  const CoordinateSystem& csys,
106  const String& absrel="abs" );
107  //Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed
108  //to be 0,1,...
110  const Vector<Quantity>& y,
111  const Vector<Int>& pixelaxes,
112  const CoordinateSystem& csys,
113  const String& absrel);
114  //wpolygon version without csys...throws an exception if
115  //setcoordsys is not run
117  const Vector<Quantity>& y,
118  const Vector<Int>& pixelaxes,
119  const String& absrel);
120 
121  static ImageRegion* wellipse(
122  const Quantity& xc,
123  const Quantity& yc,
124  const Quantity& a,
125  const Quantity& b,
126  const Quantity& pa,
127  const uInt pixelAxis0,
128  const uInt pixelAxis1,
129  const CoordinateSystem& csys,
130  const String& absrel
131  );
132 
133  //wellipse version without csys...throws an exception if
134  //setcoordsys is not run
136  const Quantity& xc,
137  const Quantity& yc,
138  const Quantity& a,
139  const Quantity& b,
140  const Quantity& pa,
141  const uInt pixelAxis0,
142  const uInt pixelAxis1,
143  const String& absrel
144  ) const;
145 
146  static ImageRegion* wsphere(
147  const Vector<Quantity>& center,
148  const Quantity& radius,
149  const Vector<Int>& pixelaxes,
150  const CoordinateSystem& csys,
151  const String& absrel
152  );
153  //wsphere version without csys...throws an exception if
154  //setcoordsys is not run
156  const Vector<Quantity>& center,
157  const Quantity& radius,
158  const Vector<Int>& pixelaxes,
159  const String& absrel
160  ) const;
161 
162  static ImageRegion* wellipsoid(
163  const Vector<Quantity>& center,
164  const Vector<Quantity>& radii,
165  const Vector<Int>& pixelaxes,
166  const CoordinateSystem& csys,
167  const String& absrel
168  );
169 
171  const Vector<Quantity>& center,
172  const Vector<Quantity>& radii,
173  const Vector<Int>& pixelaxes,
174  const String& absrel
175  ) const;
176 
177  static ImageRegion* wshell(
178  const Vector<Quantity>& center,
179  const Vector<Quantity>& innerRadii,
180  const Vector<Quantity>& outerRadii,
181  const Vector<Int>& pixelaxes,
182  const CoordinateSystem& csys,
183  const String& absrel
184  );
185 
187  const Vector<Quantity>& center,
188  const Vector<Quantity>& innerRadii,
189  const Vector<Quantity>& outerRadii,
190  const Vector<Int>& pixelaxes,
191  const String& absrel
192  ) const;
193 
194  static ImageRegion* wmask(const String& command);
195 
196 
197  /**************************************************************
198  ** Routines for combining regions **
199  ** **
200  ** Note: Many of the WCXxx classes which are used to do the **
201  ** work can take multiple regions at once, why not **
202  ** accept a ptr block of Image Regions then? **
203  **************************************************************/
204 
205  //Various versions of creating a complement region
206  ImageRegion* doComplement(const WCRegion& reg1);
208  ImageRegion* doComplement(const ImageRegion& reg1);
209 
210  //Various versions of concatenating a region onto another.
211  ImageRegion* doConcatenation(const WCRegion& region, const WCBox& box);
212  ImageRegion* doconcatenation(const PtrBlock<const WCRegion*>& regions, const WCBox& box);
214  ImageRegion* doConcatenation(const Record& regions, const TableRecord& box);
215 
216 
217  //Various versions of handling the difference of regions
218  ImageRegion* doDifference(const WCRegion& reg1, const WCRegion& reg2);
220  ImageRegion* doDifference(const ImageRegion& reg1, const ImageRegion& reg2);
221 
222  //Different versions of intersecting regions
223  ImageRegion* doIntersection(const WCRegion& reg1, const WCRegion& reg2);
225  ImageRegion* doIntersection(const ImageRegion& reg1, const ImageRegion& reg2);
226 
227  //Different versions of unioning regions
228  ImageRegion* doUnion(const WCRegion& reg1, const WCRegion& reg2);
230  ImageRegion* doUnion(const ImageRegion& reg1, const ImageRegion& reg2) const;
231 
232 
233  /**************************************************************
234  ** Routines for reading/writing regions **
235  **************************************************************/
236 
237  //Reading of a file containing an ImageRegion in the AipsIO format dump
238  static Record* readImageFile( String filename, String regionname );
239  //Writing a file of the AipsIO dump of the record representation of the region
240  static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
241 
242 
243  //save region into a table (image, blank table or any other such)
244  String imageRegionToTable(const String& tabName,
245  const ImageRegion& imreg,
246  const String& regName, Bool asmask=False);
247 
248  String recordToTable(const String& tabName, const RecordInterface& rec,
249  const String& regName="", Bool asmask=False);
250  //recover region from table
251  Record* tableToRecord(const String& tabName, const String& regname);
252 
253  //names of regions in table
254  Vector<String> namesInTable(const String& tabName);
255 
256  //Remove a region from table...refuse is regionname is ""
257  Bool removeRegionInTable(const String& tabName, const String& regName);
258 
259 
260  protected:
261  inline LogIO* _getLog() const { return itsLog; }
262 
263  private:
265  std::unique_ptr<CoordinateSystem> itsCSys;
266  // Function to return the internal Table object to the RegionHandler.
267  static Table& getTable (void* ptr, Bool writable);
268  //Convert a string to Quantity
269  void toQuantity(Quantity& out, const String& in);
271 
272  };
273 
274 
275 } // casa namespace
276 #endif
277 
static ImageRegion * wmask(const String &command)
int Int
Definition: aipstype.h:50
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)
std::vector< double > Vector
Definition: ds9context.h:24
static Record * readImageFile(String filename, String regionname)
Reading of a file containing an ImageRegion in the AipsIO format dump.
Main interface class to a read/write table.
Definition: Table.h:153
ImageRegion * doDifference(const WCRegion &reg1, const WCRegion &reg2)
Various versions of handling the difference of regions.
String absreltype(const Int absrelval=0)
ImageRegion * doUnion(const WCRegion &reg1, const WCRegion &reg2)
Different versions of unioning regions.
Bool removeRegionInTable(const String &tabName, const String &regName)
Remove a region from table...refuse is regionname is &quot;&quot;.
LogIO * _getLog() const
ostream-like interface to creating log messages.
Definition: LogIO.h:167
std::unique_ptr< CoordinateSystem > itsCSys
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,...
static Bool isPixelRegion(const ImageRegion &reg)
Some little but useful tidbits.
void toQuantity(Quantity &out, const String &in)
Convert a string to Quantity.
Record * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
static ImageRegion * wsphere(const Vector< Quantity > &center, const Quantity &radius, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
Vector< String > namesInTable(const String &tabName)
names of regions in table
static Bool isWorldRegion(const ImageRegion &reg)
ImageRegion * doIntersection(const WCRegion &reg1, const WCRegion &reg2)
Different versions of intersecting regions.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const CoordinateSystem & getcoordsys() const
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 ImageRegion * wellipsoid(const Vector< Quantity > &center, const Vector< Quantity > &radii, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
const Bool False
Definition: aipstype.h:44
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
ImageRegion * doconcatenation(const PtrBlock< const WCRegion * > &regions, const WCBox &box)
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
Record * tableToRecord(const String &tabName, const String &regname)
recover region from table
ImageRegion * doConcatenation(const WCRegion &region, const WCBox &box)
Various versions of concatenating a region onto another.
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.
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)
Base class to define world coordinate regions of interest in an image.
Definition: WCRegion.h:95
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Abstract base class for Record classes.
String recordToTable(const String &tabName, const RecordInterface &rec, const String &regName="", Bool asmask=False)
ImageRegion * doComplement(const WCRegion &reg1)
Various versions of creating a complement region.
RegionManager()
blank constructor
Class to define a world coordinate box region of interest in an image.
Definition: WCBox.h:292
static Table & getTable(void *ptr, Bool writable)
Function to return the internal Table object to the RegionHandler.
void setcoordsys(const CoordinateSystem &csys)
Interconvert pixel and world coordinates.
unsigned int uInt
Definition: aipstype.h:51
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.
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42