00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00066 RegionManager();
00067 RegionManager(const CoordinateSystem& csys);
00068 virtual ~RegionManager();
00069 String absreltype(const Int absrelval=0);
00070
00071
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
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
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
00108
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
00115
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
00134
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
00154
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
00199
00200
00201
00202
00203
00204
00205
00206 ImageRegion* doComplement(const WCRegion& reg1);
00207 ImageRegion* doComplement(const PtrBlock<const WCRegion*>& reg1);
00208 ImageRegion* doComplement(const ImageRegion& reg1);
00209
00210
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
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
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
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
00235
00236
00237
00238 static Record* readImageFile( String filename, String regionname );
00239
00240 static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
00241
00242
00243
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
00251 Record* tableToRecord(const String& tabName, const String& regname);
00252
00253
00254 Vector<String> namesInTable(const String& tabName);
00255
00256
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
00267 static Table& getTable (void* ptr, Bool writable);
00268
00269 void toQuantity(Quantity& out, const String& in);
00270 Table tab_p;
00271
00272 };
00273
00274
00275 }
00276 #endif
00277