RegionManager.h

Go to the documentation of this file.
00001 //# RegionManager.h: framework independent class that provides 
00002 //# functionality to tool of same name
00003 //# Copyright (C) 2007
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This program is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU General Public License as published by the Free
00008 //# Software Foundation; either version 2 of the License, or (at your option)
00009 //# any later version.
00010 //#
00011 //# This program is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00014 //# more details.
00015 //#
00016 //# You should have received a copy of the GNU General Public License along
00017 //# with this program; if not, write to the Free Software Foundation, Inc.,
00018 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 
00029 #ifndef IMAGES_REGIONMANAGER_H
00030 #define IMAGES_REGIONMANAGER_H
00031 
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/Quanta/Quantum.h>
00034 #include <casacore/coordinates/Coordinates/CoordinateSystem.h>
00035 #include <casacore/lattices/LRegions/RegionType.h>
00036 #include <casacore/tables/Tables/Table.h>
00037 
00038 
00039 namespace casacore {
00040 
00050   class LogIO;
00051   class String;
00052   class Record;
00053   template<class T> class Vector;
00054   class WCRegion;
00055   class WCBox;
00056   template<class T> class PtrBlock;
00057   class ImageRegion;
00058 
00059   class RegionManager
00060     {
00061       
00062       
00063     public:
00064 
00065       //blank constructor
00066       RegionManager();
00067       RegionManager(const CoordinateSystem& csys);
00068       virtual ~RegionManager();
00069       String absreltype(const Int absrelval=0);
00070 
00071       //Some little but useful tidbits.
00072       static Bool isPixelRegion(const ImageRegion& reg);
00073       static Bool isWorldRegion(const ImageRegion& reg);
00074       void setcoordsys(const CoordinateSystem& csys);
00075       const CoordinateSystem& getcoordsys() const ;
00076       
00077       //LCSlicer box
00078       Record* box(const Vector<Double>& blc, const Vector<Double>& trc, 
00079                   const Vector<Double>& inc, const String& absrel,
00080                   const Bool frac, const String& comment="");
00081       //LCBox box
00082       static Record* box(const Vector<Double>& blc, const Vector<Double>& trc, 
00083                          const Vector<Int>& shape, const String& comment="");
00084       Record* wbox(const Vector<Quantity>& blc, 
00085                         const Vector<Quantity>& trc, 
00086                         const Vector<Int>& pixelaxes, 
00087                         const CoordinateSystem& csys,
00088                         const String& absrel, const String& comment);
00089       Record* wbox(const Vector<String>& blc, 
00090                         const Vector<String>& trc, 
00091                         const Vector<Int>& pixelaxes, 
00092                         const CoordinateSystem& csys,
00093                         const String& absrel, const String& comment);
00094       Record* wbox(const Vector<Quantity>& blc, 
00095                         const Vector<Quantity>& trc, 
00096                         const Vector<Int>& pixelaxes, 
00097                         const String& absrel, const String& comment);
00098       Record* wbox(const Vector<String>& blc, 
00099                         const Vector<String>& trc, 
00100                         const Vector<Int>& pixelaxes, 
00101                         const String& absrel, const String& comment);
00102       ImageRegion* wbox(const Vector<Quantity>& blc, 
00103                         const Vector<Quantity>& trc, 
00104                         const Vector<Int>& pixelaxes, 
00105                         const CoordinateSystem& csys,
00106                         const String& absrel="abs" );
00107       //Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed
00108       //to be 0,1,...
00109       ImageRegion* wpolygon(const Vector<Quantity>& x, 
00110                             const Vector<Quantity>& y, 
00111                             const Vector<Int>& pixelaxes, 
00112                             const CoordinateSystem& csys, 
00113                             const String& absrel);
00114       //wpolygon version without csys...throws an exception if 
00115       //setcoordsys is not run
00116       ImageRegion* wpolygon(const Vector<Quantity>& x, 
00117                             const Vector<Quantity>& y, 
00118                             const Vector<Int>& pixelaxes,  
00119                             const String& absrel);
00120       
00121      static ImageRegion* wellipse(
00122                   const Quantity& xc,
00123                   const Quantity& yc,
00124                   const Quantity& a,
00125                   const Quantity& b,
00126                   const Quantity& pa,
00127                   const uInt pixelAxis0,
00128                   const uInt pixelAxis1,
00129                   const CoordinateSystem& csys,
00130                   const String& absrel
00131       );
00132 
00133       //wellipse version without csys...throws an exception if
00134       //setcoordsys is not run
00135       ImageRegion* wellipse(
00136                   const Quantity& xc,
00137                   const Quantity& yc,
00138                   const Quantity& a,
00139                   const Quantity& b,
00140                   const Quantity& pa,
00141                   const uInt pixelAxis0,
00142                   const uInt pixelAxis1,
00143                   const String& absrel
00144       ) const;
00145 
00146       static ImageRegion* wsphere(
00147                   const Vector<Quantity>& center,
00148                   const Quantity& radius,
00149                   const Vector<Int>& pixelaxes,
00150                   const CoordinateSystem& csys,
00151                   const String& absrel
00152       );
00153       //wsphere version without csys...throws an exception if
00154       //setcoordsys is not run
00155       ImageRegion* wsphere(
00156                   const Vector<Quantity>& center,
00157                   const Quantity& radius,
00158                   const Vector<Int>& pixelaxes,
00159                   const String& absrel
00160       ) const;
00161 
00162       static ImageRegion* wellipsoid(
00163                   const Vector<Quantity>& center,
00164                   const Vector<Quantity>& radii,
00165                   const Vector<Int>& pixelaxes,
00166                   const CoordinateSystem& csys,
00167                   const String& absrel
00168       );
00169 
00170       ImageRegion* wellipsoid(
00171                   const Vector<Quantity>& center,
00172                   const Vector<Quantity>& radii,
00173                   const Vector<Int>& pixelaxes,
00174                   const String& absrel
00175       ) const;
00176 
00177       static ImageRegion* wshell(
00178                   const Vector<Quantity>& center,
00179                   const Vector<Quantity>& innerRadii,
00180                   const Vector<Quantity>& outerRadii,
00181                   const Vector<Int>& pixelaxes,
00182                   const CoordinateSystem& csys,
00183                   const String& absrel
00184       );
00185 
00186       ImageRegion* wshell(
00187                   const Vector<Quantity>& center,
00188                   const Vector<Quantity>& innerRadii,
00189                   const Vector<Quantity>& outerRadii,
00190                   const Vector<Int>& pixelaxes,
00191                   const String& absrel
00192       ) const;
00193 
00194       static ImageRegion* wmask(const String& command);
00195 
00196 
00197       /**************************************************************
00198        ** Routines for combining regions                           **
00199        **                                                          **
00200        ** Note: Many of the WCXxx classes which are used to do the **
00201        **       work can take multiple regions at once, why not    **
00202        **       accept a ptr block of Image Regions then?          **
00203        **************************************************************/
00204 
00205       //Various versions of creating a complement region
00206       ImageRegion*  doComplement(const WCRegion& reg1);
00207       ImageRegion*  doComplement(const PtrBlock<const WCRegion*>& reg1);
00208       ImageRegion*  doComplement(const ImageRegion& reg1);
00209 
00210       //Various versions of concatenating a region onto another.
00211       ImageRegion*  doConcatenation(const WCRegion& region, const WCBox& box);
00212       ImageRegion*  doconcatenation(const PtrBlock<const WCRegion*>& regions, const WCBox& box);
00213       ImageRegion*  doConcatenation(const PtrBlock<const ImageRegion*>& regions, const TableRecord& box);
00214       ImageRegion*  doConcatenation(const Record& regions, const TableRecord& box);
00215 
00216 
00217       //Various versions of handling the difference of regions
00218       ImageRegion*  doDifference(const WCRegion& reg1, const WCRegion& reg2);
00219       ImageRegion*  doDifference(const PtrBlock<const WCRegion*>& reg1);
00220       ImageRegion*  doDifference(const ImageRegion& reg1, const ImageRegion& reg2);
00221       
00222       //Different versions of intersecting regions
00223       ImageRegion*  doIntersection(const WCRegion& reg1, const WCRegion& reg2);
00224       ImageRegion*  doIntersection(const PtrBlock<const WCRegion*>& reg1);
00225       ImageRegion*  doIntersection(const ImageRegion& reg1, const ImageRegion& reg2);
00226 
00227       //Different versions of unioning regions
00228       ImageRegion*  doUnion(const WCRegion& reg1, const WCRegion& reg2);
00229       ImageRegion*  doUnion(const PtrBlock<const WCRegion*>& reg1);
00230       ImageRegion*  doUnion(const ImageRegion& reg1, const ImageRegion& reg2) const;
00231       
00232 
00233       /**************************************************************
00234        ** Routines for reading/writing regions                     **
00235        **************************************************************/
00236 
00237       //Reading of a file containing an ImageRegion in the AipsIO format dump
00238       static Record* readImageFile( String filename, String regionname );
00239       //Writing a file of the AipsIO dump of the record representation of the region
00240       static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
00241 
00242       
00243       //save region into a table (image, blank table or any other such)
00244       String imageRegionToTable(const String& tabName, 
00245                                 const ImageRegion& imreg,
00246                                 const String& regName, Bool asmask=False); 
00247 
00248       String recordToTable(const String& tabName, const RecordInterface& rec, 
00249                            const String& regName="", Bool asmask=False);
00250       //recover region from table
00251       Record* tableToRecord(const String& tabName,   const String& regname);
00252 
00253       //names of regions in table
00254       Vector<String> namesInTable(const String& tabName);
00255 
00256       //Remove a region from table...refuse is regionname is ""
00257       Bool removeRegionInTable(const String& tabName, const String& regName);
00258 
00259 
00260     protected:
00261       inline LogIO* _getLog() const { return itsLog; }
00262 
00263     private:
00264       LogIO *itsLog;
00265       CoordinateSystem* itsCSys;
00266       // Function to return the internal Table object to the RegionHandler.
00267       static Table& getTable (void* ptr, Bool writable);
00268       //Convert a string to Quantity
00269       void toQuantity(Quantity& out, const String& in);
00270       Table tab_p;
00271 
00272     };
00273 
00274 
00275 } // casa namespace
00276 #endif
00277 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1