casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
casacore::WCPolygon Class Reference

Class to define a 2-D polygonal world coordinate region in an image. More...

#include <WCPolygon.h>

Inheritance diagram for casacore::WCPolygon:
casacore::WCRegion

Public Member Functions

 WCPolygon ()
 
 WCPolygon (const Quantum< Vector< Double > > &x, const Quantum< Vector< Double > > &y, const IPosition &pixelAxes, const CoordinateSystem &cSys, const RegionType::AbsRelType absRel=RegionType::Abs)
 Construct from two vectors of world coordinates defining the polygon vertices. More...
 
 WCPolygon (const LCPolygon &polygon, const IPosition &pixelAxes, const CoordinateSystem &cSys)
 Construct from an LCPolygon. More...
 
 WCPolygon (const WCPolygon &other)
 Copy constructor (reference semantics). More...
 
virtual ~WCPolygon ()
 Destructor. More...
 
WCPolygonoperator= (const WCPolygon &other)
 Assignment (copy semantics) More...
 
virtual Bool operator== (const WCRegion &other) const
 Comparison. More...
 
virtual WCRegioncloneRegion () const
 Clone a WCPolygon object. More...
 
virtual Bool canExtend () const
 WCPolygon cannot extend a region. More...
 
virtual LCRegiondoToLCRegion (const CoordinateSystem &cSys, const IPosition &latticeShape, const IPosition &pixelAxesMap, const IPosition &outOrder) const
 Convert to an LCRegion using the given coordinate system. More...
 
virtual TableRecord toRecord (const String &tableName) const
 Convert the WCPolygon object to a record. More...
 
virtual String type () const
 Return region type. More...
 
- Public Member Functions inherited from casacore::WCRegion
 WCRegion ()
 
 WCRegion (const WCRegion &other)
 Copy constructor (copy semantics). More...
 
virtual ~WCRegion ()
 Destructor. More...
 
Bool operator!= (const WCRegion &other) const
 
virtual uInt ndim () const
 Get the dimensionality (i.e. More...
 
const RecordgetAxesDesc () const
 Get the description of all axes. More...
 
const RecordgetAxisDesc (uInt axis) const
 Get the description of the given axis. More...
 
Int axisNr (const Record &desc, const Record &axesDesc) const
 Return the axis number of the description of an axis in the full axes description. More...
 
Bool isAxisDescEqual (const Record &desc1, const Record &desc2) const
 Are both axis descriptions equal? More...
 
const Stringcomment () const
 Get or set the comment. More...
 
void setComment (const String &comment)
 
virtual LCRegiontoLCRegion (const CoordinateSystem &cSys, const IPosition &shape) const
 Convert to an LCRegion using the given new coordinate system and shape. More...
 
LCRegiontoLCRegionAxes (const CoordinateSystem &cSys, const IPosition &shape, const IPosition &pixelAxesMap, const IPosition &outOrder) const
 Convert to an LCRegion using the given coordinate system and shape. More...
 
void defineRecordFields (RecordInterface &record, const String &className) const
 Define the type and class name in the record. More...
 

Static Public Member Functions

static WCPolygonfromRecord (const TableRecord &rec, const String &tableName)
 Convert to a WCPolygon from a record. More...
 
static String className ()
 Returns "WCPolygon". More...
 
- Static Public Member Functions inherited from casacore::WCRegion
static WCRegionfromRecord (const TableRecord &rec, const String &tableName)
 Convert correct object from a record. More...
 

Protected Attributes

Quantum< Vector< Double > > itsX
 
Quantum< Vector< Double > > itsY
 
IPosition itsPixelAxes
 
CoordinateSystem itsCSys
 
RegionType::AbsRelType itsAbsRel
 
Bool itsNull
 

Additional Inherited Members

- Protected Member Functions inherited from casacore::WCRegion
WCRegionoperator= (const WCRegion &other)
 Assignment (copy semantics) makes only sense for a derived class. More...
 
void addAxisDesc (const Record &axisDesc)
 Add an axis with its description. More...
 
Record makeAxisDesc (const CoordinateSystem &cSys, uInt pixelAxis) const
 Make a description of a pixel axis in the coordinate system. More...
 
Record makeAxesDesc (const CoordinateSystem &cSys) const
 Make a description of all pixel axes in the coordinate system (in pixel axes order). More...
 
void makeWorldAbsolute (Vector< Double > &world, const Vector< Int > &absRel, const CoordinateSystem &cSys, const IPosition &shape) const
 Convert relative to absolute world as needed. More...
 
void checkAxes (const IPosition &pixelAxes, const CoordinateSystem &cSys, const Vector< String > &quantityUnits) const
 
- Static Protected Member Functions inherited from casacore::WCRegion
static void unitInit ()
 
static void convertPixel (Double &pixel, const Double &value, const String &unit, const Int absRel, const Double refPix, const Int shape)
 

Detailed Description

Class to define a 2-D polygonal world coordinate region in an image.

Intended use:

Public interface

Prerequisite

Synopsis

The corners of the 2-D polygon are given by world coordinates. The vertices are connected by straight lines in lattice coordinates.

All this class does, apart from constructing itself, is know how to save itself to a Record and how to convert itself to an LCRegion. The conversion allows you to apply a WCPolygon constructed with one CoordinateSystem to another CoordinateSystem. That is, you can apply a WCPolygon from this image to that image.

At construction, it is assumed that the units of the world coordinates are the same as those encapsulated in the construction CoordinateSystem. You must tell the constructor, which world axes the x and vectors are associated with. Make sure you account for reordering. For example, if you reordered [ra,dec] to be [dec,ra] with the CoordinateSystem::transpose(,) fuction and wished the x vector to be ra, and the y vector to be dec, then worldAxes=[1,0].

The CoordinateSystem supplied to the toLCRegion (which returns a pointer to an LCPolygongon object) function does not have to be identical in structure to that with which the WCPolygon was constructed. However, each world axis given in the worldAxes vector at construction must be present somewhere (order is unimportant) in the supplied CoordinateSystem.

The supplied lattice shape must be 2-D and corresponds to the pixel axes of the two world axes of the supplied CoordinateSystem which match those of the construction CoordinateSystem.

Example

Let us give some examples with pseudo-code. cSys is the construction CoordinateSystem and cSys2 is the supplied CoordinateSystem. We list their world axes in the square brackets. The construction polygon values don't matter. Similarly, the values of shape don't matter as long as there are 2 of them.

cSys = [ra, dec, freq];
cSys2 = [ra, dec];
axes=[0,1];
shape = [,];
WCPolygon poly(x, y, axes, cSys);
LCRegion* pR = poly.toLCRegion(cSys2, shape);

The resultant LCPolygon will have vertices converted with the [ra, dec] axes from cSys2

Example

cSys = [ra, dec, freq];
cSys2 = [ra, dec];
axes=[0,2];
shape = [,];
WCPolygon poly(x, y, axes, cSys);
LCRegion* pR = poly.toLCRegion(cSys2, shape);

This will throw an exception because the [freq] axis is missing in cSys2

Example

In this example we make it a bit harder by reordering the pixel axes too. The new order of the pixel axes in terms of the original order [0,1,2...] is given after the world axes

cSys = [ra, dec, freq];
cSys2 = [stokes, freq, ra, dec], [3,2,1,0];
axes=[1,2];
shape = [,];
WCPolygon poly(x, y, axes, cSys);
LCRegion* pR = poly.toLCRegion(cSys2, shape);

The resultant LCPolygon will have vertices converted with the [ra, dec] axes from cSys2. The fact that the pixel axes of cSys2 were reordered is accounted for internally, but does not extrude further.

Example

In this example we make it a bit harder by remove a pixel axis.

cSys = [ra, dec, freq];
cSys2 = [stokes, freq, ra, dec];
cSys2.removePixelAxis(1, cSys2.referencePixel()(1));
axes=[1,2];
shape = [,];
WCPolygon poly(x, y, axes, cSys);
LCRegion* pR = poly.toLCRegion(cSys2, shape);

This will throw an exception because the removed pixel axis, pixel axis number 1, corresponds to the [freq] world axis in cSys2, and the [freq] axis is one of those specified at construction. Although the world axis is still present, it is not possible to convert to a pixel coordinate if the pixel axis is not there.

Motivation

Users must be able to specify regions in world as well as lattice coordinates.


Note: In all the constructors, you have to specifiy which plane the polygon lies in; You do this by specifying the PIXEL AXES (not the world axes) as this is the natural thing the user will want to specify;


Note: For the constructors specifying the world values as simple doubles, it is ASSUMED that the units of those doubles are the same as the native units of the CoordinateSystem for each axis;


Note: World coordinates may be specified as absolute or offset; If the latter, they are offset with respect to the reference pixel of the CoordinateSystem;

To Do

Definition at line 205 of file WCPolygon.h.

Constructor & Destructor Documentation

casacore::WCPolygon::WCPolygon ( )
casacore::WCPolygon::WCPolygon ( const Quantum< Vector< Double > > &  x,
const Quantum< Vector< Double > > &  y,
const IPosition pixelAxes,
const CoordinateSystem cSys,
const RegionType::AbsRelType  absRel = RegionType::Abs 
)

Construct from two vectors of world coordinates defining the polygon vertices.

casacore::WCPolygon::WCPolygon ( const LCPolygon polygon,
const IPosition pixelAxes,
const CoordinateSystem cSys 
)

Construct from an LCPolygon.

casacore::WCPolygon::WCPolygon ( const WCPolygon other)

Copy constructor (reference semantics).

virtual casacore::WCPolygon::~WCPolygon ( )
virtual

Destructor.

Member Function Documentation

virtual Bool casacore::WCPolygon::canExtend ( ) const
virtual

WCPolygon cannot extend a region.

Reimplemented from casacore::WCRegion.

static String casacore::WCPolygon::className ( )
static

Returns "WCPolygon".

virtual WCRegion* casacore::WCPolygon::cloneRegion ( ) const
virtual

Clone a WCPolygon object.

Implements casacore::WCRegion.

virtual LCRegion* casacore::WCPolygon::doToLCRegion ( const CoordinateSystem cSys,
const IPosition latticeShape,
const IPosition pixelAxesMap,
const IPosition outOrder 
) const
virtual

Convert to an LCRegion using the given coordinate system.

Implements casacore::WCRegion.

static WCPolygon* casacore::WCPolygon::fromRecord ( const TableRecord rec,
const String tableName 
)
static

Convert to a WCPolygon from a record.

WCPolygon& casacore::WCPolygon::operator= ( const WCPolygon other)

Assignment (copy semantics)

virtual Bool casacore::WCPolygon::operator== ( const WCRegion other) const
virtual

Comparison.

Reimplemented from casacore::WCRegion.

virtual TableRecord casacore::WCPolygon::toRecord ( const String tableName) const
virtual

Convert the WCPolygon object to a record.

The record can be used to make the object persistent. The tableName argument can be used by derived classes (e.g. LCPagedMask) to put very large objects.

Implements casacore::WCRegion.

virtual String casacore::WCPolygon::type ( ) const
virtual

Return region type.

Returns the class name

Implements casacore::WCRegion.

Member Data Documentation

RegionType::AbsRelType casacore::WCPolygon::itsAbsRel
protected

Definition at line 271 of file WCPolygon.h.

CoordinateSystem casacore::WCPolygon::itsCSys
protected

Definition at line 270 of file WCPolygon.h.

Bool casacore::WCPolygon::itsNull
protected

Definition at line 272 of file WCPolygon.h.

IPosition casacore::WCPolygon::itsPixelAxes
protected

Definition at line 269 of file WCPolygon.h.

Quantum<Vector<Double> > casacore::WCPolygon::itsX
protected

Definition at line 267 of file WCPolygon.h.

Quantum<Vector<Double> > casacore::WCPolygon::itsY
protected

Definition at line 268 of file WCPolygon.h.


The documentation for this class was generated from the following file: