Loading...
Searching...
No Matches
RegionManager.h
Go to the documentation of this file.
//# RegionManager.h: framework independent class that provides
//# functionality to tool of same name
//# Copyright (C) 2007
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This program is free software; you can redistribute it and/or modify it
//# under the terms of the GNU General Public License as published by the Free
//# Software Foundation; either version 2 of the License, or (at your option)
//# any later version.
//#
//# This program is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
//# more details.
//#
//# You should have received a copy of the GNU General Public License along
//# with this program; if not, write to the Free Software Foundation, Inc.,
//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef IMAGES_REGIONMANAGER_H
#define IMAGES_REGIONMANAGER_H
#include <casacore/casa/aips.h>
#include <casacore/casa/Quanta/Quantum.h>
#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
#include <casacore/lattices/LRegions/RegionType.h>
#include <casacore/tables/Tables/Table.h>
#include <casacore/casa/Arrays/ArrayFwd.h>
namespace casacore {
class LogIO;
class String;
class Record;
class WCRegion;
class WCBox;
template<class T> class PtrBlock;
class ImageRegion;
class RegionManager
{
public:
//blank constructor
RegionManager();
RegionManager(const CoordinateSystem& csys);
virtual ~RegionManager();
String absreltype(const Int absrelval=0);
//Some little but useful tidbits.
static Bool isPixelRegion(const ImageRegion& reg);
static Bool isWorldRegion(const ImageRegion& reg);
void setcoordsys(const CoordinateSystem& csys);
const CoordinateSystem& getcoordsys() const ;
//LCSlicer box
Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
const Vector<Double>& inc, const String& absrel,
const Bool frac, const String& comment="");
//LCBox box
static Record* box(const Vector<Double>& blc, const Vector<Double>& trc,
const Vector<Int>& shape, const String& comment="");
Record* wbox(const Vector<Quantity>& blc,
const Vector<Quantity>& trc,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel, const String& comment);
Record* wbox(const Vector<String>& blc,
const Vector<String>& trc,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel, const String& comment);
Record* wbox(const Vector<Quantity>& blc,
const Vector<Quantity>& trc,
const Vector<Int>& pixelaxes,
const String& absrel, const String& comment);
Record* wbox(const Vector<String>& blc,
const Vector<String>& trc,
const Vector<Int>& pixelaxes,
const String& absrel, const String& comment);
ImageRegion* wbox(const Vector<Quantity>& blc,
const Vector<Quantity>& trc,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel="abs" );
//Wpolygon with coordsys and if pixelaxes[0] is -1 then its assumed
//to be 0,1,...
ImageRegion* wpolygon(const Vector<Quantity>& x,
const Vector<Quantity>& y,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel);
//wpolygon version without csys...throws an exception if
//setcoordsys is not run
ImageRegion* wpolygon(const Vector<Quantity>& x,
const Vector<Quantity>& y,
const Vector<Int>& pixelaxes,
const String& absrel);
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
);
//wellipse version without csys...throws an exception if
//setcoordsys is not run
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;
static ImageRegion* wsphere(
const Vector<Quantity>& center,
const Quantity& radius,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel
);
//wsphere version without csys...throws an exception if
//setcoordsys is not run
ImageRegion* wsphere(
const Vector<Quantity>& center,
const Quantity& radius,
const Vector<Int>& pixelaxes,
const String& absrel
) const;
static ImageRegion* wellipsoid(
const Vector<Quantity>& center,
const Vector<Quantity>& radii,
const Vector<Int>& pixelaxes,
const CoordinateSystem& csys,
const String& absrel
);
ImageRegion* wellipsoid(
const Vector<Quantity>& center,
const Vector<Quantity>& radii,
const Vector<Int>& pixelaxes,
const String& absrel
) 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
);
ImageRegion* wshell(
const Vector<Quantity>& center,
const Vector<Quantity>& innerRadii,
const Vector<Quantity>& outerRadii,
const Vector<Int>& pixelaxes,
const String& absrel
) const;
static ImageRegion* wmask(const String& command);
/**************************************************************
** Routines for combining regions **
** **
** Note: Many of the WCXxx classes which are used to do the **
** work can take multiple regions at once, why not **
** accept a ptr block of Image Regions then? **
**************************************************************/
//Various versions of creating a complement region
ImageRegion* doComplement(const WCRegion& reg1);
ImageRegion* doComplement(const PtrBlock<const WCRegion*>& reg1);
ImageRegion* doComplement(const ImageRegion& reg1);
//Various versions of concatenating a region onto another.
ImageRegion* doConcatenation(const WCRegion& region, const WCBox& box);
ImageRegion* doconcatenation(const PtrBlock<const WCRegion*>& regions, const WCBox& box);
ImageRegion* doConcatenation(const PtrBlock<const ImageRegion*>& regions, const TableRecord& box);
ImageRegion* doConcatenation(const Record& regions, const TableRecord& box);
//Various versions of handling the difference of regions
ImageRegion* doDifference(const WCRegion& reg1, const WCRegion& reg2);
ImageRegion* doDifference(const PtrBlock<const WCRegion*>& reg1);
ImageRegion* doDifference(const ImageRegion& reg1, const ImageRegion& reg2);
//Different versions of intersecting regions
ImageRegion* doIntersection(const WCRegion& reg1, const WCRegion& reg2);
ImageRegion* doIntersection(const PtrBlock<const WCRegion*>& reg1);
ImageRegion* doIntersection(const ImageRegion& reg1, const ImageRegion& reg2);
//Different versions of unioning regions
ImageRegion* doUnion(const WCRegion& reg1, const WCRegion& reg2);
ImageRegion* doUnion(const PtrBlock<const WCRegion*>& reg1);
ImageRegion* doUnion(const ImageRegion& reg1, const ImageRegion& reg2) const;
/**************************************************************
** Routines for reading/writing regions **
**************************************************************/
//Reading of a file containing an ImageRegion in the AipsIO format dump
static Record* readImageFile( String filename, String regionname );
//Writing a file of the AipsIO dump of the record representation of the region
static Bool writeImageFile(const String& file, const String& regionname, const Record& regionRecord);
//save region into a table (image, blank table or any other such)
String imageRegionToTable(const String& tabName,
const ImageRegion& imreg,
const String& regName, Bool asmask=False);
String recordToTable(const String& tabName, const RecordInterface& rec,
const String& regName="", Bool asmask=False);
//recover region from table
Record* tableToRecord(const String& tabName, const String& regname);
//names of regions in table
Vector<String> namesInTable(const String& tabName);
//Remove a region from table...refuse is regionname is ""
Bool removeRegionInTable(const String& tabName, const String& regName);
protected:
inline LogIO* _getLog() const { return itsLog; }
private:
LogIO *itsLog;
std::unique_ptr<CoordinateSystem> itsCSys;
// Function to return the internal Table object to the RegionHandler.
static Table& getTable (void* ptr, Bool writable);
//Convert a string to Quantity
void toQuantity(Quantity& out, const String& in);
Table tab_p;
};
} // casa namespace
#endif
casacore::CoordinateSystem
Definition CoordinateSystem.h:215
casacore::ImageRegion
Definition ImageRegion.h:85
casacore::LogIO
Definition LogIO.h:165
casacore::PtrBlock
A drop-in replacement for Block<T*>.
Definition Block.h:812
casacore::RegionManager::itsCSys
std::unique_ptr< CoordinateSystem > itsCSys
Definition RegionManager.h:262
casacore::RegionManager::doconcatenation
ImageRegion * doconcatenation(const PtrBlock< const WCRegion * > &regions, const WCBox &box)
casacore::RegionManager::wellipse
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
casacore::RegionManager::doUnion
ImageRegion * doUnion(const WCRegion &reg1, const WCRegion &reg2)
Different versions of unioning regions.
casacore::RegionManager::wbox
Record * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const String &absrel, const String &comment)
casacore::RegionManager::namesInTable
Vector< String > namesInTable(const String &tabName)
names of regions in table
casacore::RegionManager::wellipsoid
static ImageRegion * wellipsoid(const Vector< Quantity > &center, const Vector< Quantity > &radii, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
casacore::RegionManager::doComplement
ImageRegion * doComplement(const WCRegion &reg1)
Various versions of creating a complement region.
casacore::RegionManager::wellipsoid
ImageRegion * wellipsoid(const Vector< Quantity > &center, const Vector< Quantity > &radii, const Vector< Int > &pixelaxes, const String &absrel) const
casacore::RegionManager::doDifference
ImageRegion * doDifference(const PtrBlock< const WCRegion * > &reg1)
casacore::RegionManager::doIntersection
ImageRegion * doIntersection(const ImageRegion &reg1, const ImageRegion &reg2)
casacore::RegionManager::wshell
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)
casacore::RegionManager::isWorldRegion
static Bool isWorldRegion(const ImageRegion &reg)
casacore::RegionManager::box
static Record * box(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Int > &shape, const String &comment="")
LCBox box.
casacore::RegionManager::wellipse
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)
casacore::RegionManager::writeImageFile
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.
casacore::RegionManager::wbox
Record * wbox(const Vector< String > &blc, const Vector< String > &trc, const Vector< Int > &pixelaxes, const String &absrel, const String &comment)
casacore::RegionManager::absreltype
String absreltype(const Int absrelval=0)
casacore::RegionManager::wpolygon
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,...
casacore::RegionManager::setcoordsys
void setcoordsys(const CoordinateSystem &csys)
casacore::RegionManager::doComplement
ImageRegion * doComplement(const ImageRegion &reg1)
casacore::RegionManager::imageRegionToTable
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)
casacore::RegionManager::doComplement
ImageRegion * doComplement(const PtrBlock< const WCRegion * > &reg1)
casacore::RegionManager::recordToTable
String recordToTable(const String &tabName, const RecordInterface &rec, const String &regName="", Bool asmask=False)
casacore::RegionManager::wshell
ImageRegion * wshell(const Vector< Quantity > &center, const Vector< Quantity > &innerRadii, const Vector< Quantity > &outerRadii, const Vector< Int > &pixelaxes, const String &absrel) const
casacore::RegionManager::wsphere
static ImageRegion * wsphere(const Vector< Quantity > &center, const Quantity &radius, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel)
casacore::RegionManager::wbox
Record * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
casacore::RegionManager::doIntersection
ImageRegion * doIntersection(const WCRegion &reg1, const WCRegion &reg2)
Different versions of intersecting regions.
casacore::RegionManager::readImageFile
static Record * readImageFile(String filename, String regionname)
Reading of a file containing an ImageRegion in the AipsIO format dump.
casacore::RegionManager::doConcatenation
ImageRegion * doConcatenation(const Record &regions, const TableRecord &box)
casacore::RegionManager::_getLog
LogIO * _getLog() const
Definition RegionManager.h:258
casacore::RegionManager::~RegionManager
virtual ~RegionManager()
casacore::RegionManager::getTable
static Table & getTable(void *ptr, Bool writable)
Function to return the internal Table object to the RegionHandler.
casacore::RegionManager::doUnion
ImageRegion * doUnion(const PtrBlock< const WCRegion * > &reg1)
casacore::RegionManager::wbox
Record * wbox(const Vector< String > &blc, const Vector< String > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel, const String &comment)
casacore::RegionManager::itsLog
LogIO * itsLog
Definition RegionManager.h:261
casacore::RegionManager::isPixelRegion
static Bool isPixelRegion(const ImageRegion &reg)
Some little but useful tidbits.
casacore::RegionManager::wbox
ImageRegion * wbox(const Vector< Quantity > &blc, const Vector< Quantity > &trc, const Vector< Int > &pixelaxes, const CoordinateSystem &csys, const String &absrel="abs")
casacore::RegionManager::tableToRecord
Record * tableToRecord(const String &tabName, const String &regname)
recover region from table
casacore::RegionManager::getcoordsys
const CoordinateSystem & getcoordsys() const
casacore::RegionManager::toQuantity
void toQuantity(Quantity &out, const String &in)
Convert a string to Quantity.
casacore::RegionManager::doConcatenation
ImageRegion * doConcatenation(const PtrBlock< const ImageRegion * > &regions, const TableRecord &box)
casacore::RegionManager::wmask
static ImageRegion * wmask(const String &command)
casacore::RegionManager::doUnion
ImageRegion * doUnion(const ImageRegion &reg1, const ImageRegion &reg2) const
casacore::RegionManager::RegionManager
RegionManager()
blank constructor
casacore::RegionManager::doDifference
ImageRegion * doDifference(const ImageRegion &reg1, const ImageRegion &reg2)
casacore::RegionManager::removeRegionInTable
Bool removeRegionInTable(const String &tabName, const String &regName)
Remove a region from table...refuse is regionname is "".
casacore::RegionManager::wpolygon
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
casacore::RegionManager::doDifference
ImageRegion * doDifference(const WCRegion &reg1, const WCRegion &reg2)
Various versions of handling the difference of regions.
casacore::RegionManager::doIntersection
ImageRegion * doIntersection(const PtrBlock< const WCRegion * > &reg1)
casacore::RegionManager::wsphere
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
casacore::RegionManager::box
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.
casacore::RegionManager::doConcatenation
ImageRegion * doConcatenation(const WCRegion &region, const WCBox &box)
Various versions of concatenating a region onto another.
casacore::RegionManager::RegionManager
RegionManager(const CoordinateSystem &csys)
casacore::RegionManager::tab_p
Table tab_p
Definition RegionManager.h:267
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::TableRecord
Definition TableRecord.h:183
casacore::Table
Definition Table.h:157
casacore::Vector
Definition Vector.h:82
casacore::WCBox
Definition WCBox.h:292
casacore::WCRegion
Definition WCRegion.h:94
casacore::Record
Record()
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::pa
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
casacore::False
const Bool False
Definition aipstype.h:42
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::shape
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
casacore::comment
const String & comment(const RecordFieldId &) const override
Get the comment for this field.
casacore::RecordInterface
RecordInterface()
The default constructor creates an empty record with a variable structure.
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::Quantity
Quantum< Double > Quantity
Definition Quantum.h:39