casa
$Rev:20696$
|
Abstract base class to define a region of interest in lattice coordinates. More...
#include <LCRegion.h>
Public Member Functions | |
LCRegion () | |
LCRegion (const IPosition &latticeShape) | |
Construct with the lattice shape only. | |
LCRegion (const LCRegion &other) | |
Copy constructor (copy semantics). | |
virtual | ~LCRegion () |
virtual Bool | operator== (const LCRegion &other) const |
Equality. | |
Bool | operator!= (const LCRegion &other) const |
Non-equality. | |
virtual Lattice< Bool > * | clone () const |
Make a copy of the derived object. | |
virtual LCRegion * | cloneRegion () const =0 |
virtual void | handleDelete () |
Handle deletion of the region by deleting possible tables. | |
virtual void | handleRename (const String &newName, Bool overwrite) |
Handle renaming the region by renaming possible tables. | |
virtual String | type () const =0 |
Region type. | |
const String & | comment () const |
Get or set the comment. | |
void | setComment (const String &comment) |
virtual Bool | hasMask () const =0 |
Does the region have a mask? | |
LCRegion * | translate (const IPosition &translateVector) const |
Construct another LCRegion (for e.g. | |
LCRegion * | translate (const IPosition &translateVector, const IPosition &newLatticeShape) const |
LCRegion * | translate (const Vector< Float > &translateVector) const |
LCRegion * | translate (const Vector< Float > &translateVector, const IPosition &newLatticeShape) const |
const IPosition & | latticeShape () const |
Give the full lattice shape. | |
const Slicer & | boundingBox () const |
Give the bounding box. | |
Slicer | expand (const Slicer &slicer) const |
Expand a slicer or position in the region to the full lattice. | |
IPosition | expand (const IPosition &index) const |
virtual TableRecord | toRecord (const String &tableName) const =0 |
Convert the (derived) object to a record. | |
virtual uInt | ndim () const |
Return the dimensionality of the region. | |
virtual IPosition | shape () const |
Return the shape of the region (i.e. | |
virtual Bool | isWritable () const |
Usually the lattice (i.e. | |
virtual void | doPutSlice (const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride) |
Regions can usually not be put; i.e. | |
virtual void | set (const Bool &value) |
Set all elements in the Lattice to the given value. | |
virtual void | apply (Bool(*function)(Bool)) |
Replace every element, x, of the Lattice with the result of f(x). | |
virtual void | apply (Bool(*function)(const Bool &)) |
virtual void | apply (const Functional< Bool, Bool > &function) |
virtual void | putAt (const Bool &value, const IPosition &where) |
Put the value of a single element. | |
virtual void | copyData (const Lattice< Bool > &from) |
Copy the data from the given lattice to this one. | |
Static Public Member Functions | |
static LCRegion * | fromRecord (const TableRecord &, const String &tableName) |
Convert correct object from a record. | |
Protected Member Functions | |
LCRegion & | operator= (const LCRegion &other) |
void | setBoundingBox (const Slicer &boundingBox) |
Sometimes it is inconvenient for a derived class to set the bounding box in the constructor. | |
void | setShapeAndBoundingBox (const IPosition &latticeShape, const Slicer &boundingBox) |
virtual LCRegion * | doTranslate (const Vector< Float > &translateVector, const IPosition &newLatticeShape) const =0 |
Do the actual translate in a derived class. | |
void | defineRecordFields (RecordInterface &record, const String &className) const |
Define the type and class name in the record. | |
Private Attributes | |
IPosition | itsShape |
Slicer | itsBoundingBox |
String | itsComment |
Abstract base class to define a region of interest in lattice coordinates.
Public interface
The LCRegion class is the abstract base class for various types of LCRegion's (e.g. LCEllipsoid , LCBox ). It contains the minimal bounding box of the region and, if needed, a mask with the same shape as the bounding box. A mask element is true if the element is inside the box.
Each LCRegion object must be able to convert itself to and from a record. In that way they can be made persistent (in for example a Table).
The LCRegion can be used in several Lattices and Images classes and functions to limit the area to operate on.
The Slicer class is too limited as a region, because it can only describe a rectangular region. Specialized classes are needed to describe arbitrary regions. They need a base class to combine them.
Definition at line 86 of file LCRegion.h.
casa::LCRegion::LCRegion | ( | const IPosition & | latticeShape | ) |
Construct with the lattice shape only.
casa::LCRegion::LCRegion | ( | const LCRegion & | other | ) |
Copy constructor (copy semantics).
virtual casa::LCRegion::~LCRegion | ( | ) | [virtual] |
virtual void casa::LCRegion::apply | ( | Bool(*)(Bool) | function | ) | [virtual] |
Replace every element, x, of the Lattice with the result of f(x).
You must pass in the address of the function -- so the function must be declared and defined in the scope of your program. All versions of apply require a function that accepts a single argument of type T (the Lattice template type) and return a result of the same type. The first apply expects a function with an argument passed by value; the second expects the argument to be passed by const reference; the third requires an instance of the class Functional<T,T>
. The first form ought to run faster for the built-in types, which may be an issue for large Lattices stored in memory, where disk access is not an issue.
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
virtual void casa::LCRegion::apply | ( | Bool(*)(const Bool &) | function | ) | [virtual] |
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
virtual void casa::LCRegion::apply | ( | const Functional< Bool, Bool > & | function | ) | [virtual] |
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
const Slicer & casa::LCRegion::boundingBox | ( | ) | const [inline] |
virtual Lattice<Bool>* casa::LCRegion::clone | ( | ) | const [virtual] |
Make a copy of the derived object.
Implements casa::Lattice< Bool >.
virtual LCRegion* casa::LCRegion::cloneRegion | ( | ) | const [pure virtual] |
const String & casa::LCRegion::comment | ( | ) | const [inline] |
Get or set the comment.
Definition at line 243 of file LCRegion.h.
References itsComment.
Referenced by setComment().
virtual void casa::LCRegion::copyData | ( | const Lattice< Bool > & | from | ) | [virtual] |
Copy the data from the given lattice to this one.
The default implementation uses function copyDataTo
.
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
void casa::LCRegion::defineRecordFields | ( | RecordInterface & | record, |
const String & | className | ||
) | const [protected] |
Define the type and class name in the record.
virtual void casa::LCRegion::doPutSlice | ( | const Array< Bool > & | sourceBuffer, |
const IPosition & | where, | ||
const IPosition & | stride | ||
) | [virtual] |
Regions can usually not be put; i.e.
no putSlice, etc. can be done on their masks. Hence LCRegion throws by default an exception for the following functions.
Implements casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
virtual LCRegion* casa::LCRegion::doTranslate | ( | const Vector< Float > & | translateVector, |
const IPosition & | newLatticeShape | ||
) | const [protected, pure virtual] |
Do the actual translate in a derived class.
Implemented in casa::LCMask, casa::LCPagedMask, casa::LCEllipsoid, casa::LCPolygon, casa::LCConcatenation, casa::LCLELMask, casa::LCBox, casa::LCExtension, casa::LCStretch, casa::LCUnion, casa::LCHDF5Mask, casa::LCIntersection, casa::LCDifference, casa::LCComplement, and casa::LCPixelSet.
Slicer casa::LCRegion::expand | ( | const Slicer & | slicer | ) | const |
Expand a slicer or position in the region to the full lattice.
This converts the positions in the region to positions in the entire lattice.
IPosition casa::LCRegion::expand | ( | const IPosition & | index | ) | const |
static LCRegion* casa::LCRegion::fromRecord | ( | const TableRecord & | , |
const String & | tableName | ||
) | [static] |
Convert correct object from a record.
Reimplemented in casa::LCPagedMask, casa::LCEllipsoid, casa::LCPolygon, casa::LCConcatenation, casa::LCExtension, casa::LCStretch, casa::LCUnion, casa::LCBox, casa::LCIntersection, casa::LCHDF5Mask, casa::LCDifference, casa::LCComplement, and casa::LCPixelSet.
virtual void casa::LCRegion::handleDelete | ( | ) | [virtual] |
Handle deletion of the region by deleting possible tables.
The default implementation does nothing.
Reimplemented in casa::LCPagedMask.
virtual void casa::LCRegion::handleRename | ( | const String & | newName, |
Bool | overwrite | ||
) | [virtual] |
Handle renaming the region by renaming possible tables.
The default implementation does nothing.
Reimplemented in casa::LCPagedMask.
virtual Bool casa::LCRegion::hasMask | ( | ) | const [pure virtual] |
Does the region have a mask?
Implemented in casa::LCRegionMulti, and casa::LCRegionSingle.
virtual Bool casa::LCRegion::isWritable | ( | ) | const [virtual] |
Usually the lattice (i.e.
the region mask) is not writable.
Reimplemented from casa::LatticeBase.
Reimplemented in casa::LCMask, casa::LCPagedMask, and casa::LCHDF5Mask.
const IPosition & casa::LCRegion::latticeShape | ( | ) | const [inline] |
virtual uInt casa::LCRegion::ndim | ( | ) | const [virtual] |
Return the dimensionality of the region.
Reimplemented from casa::LatticeBase.
Non-equality.
Watch out ! You must not, in the derived class structure, invoke LCRegion::operator!= If you do, you will be stuck in a time warp, as this will just fetch the operator== of the concrete class and you start all over again.
Be careful, do not use this anywhere in the derived class structure. You must use, e.g., if (! LCRegion::operator== (...))
rather than if (LCRegion::operator!= (...))
as the latter will invoke an infinite loop. It is ok to use when applying to a concrete class object.
You must use always use !LCRegionoperator==. It is ok in application code using the concrete class to say if (x != y) where x and y are, say, LCBoxes.
Definition at line 252 of file LCRegion.h.
Assignment (copy semantics) is only useful for derived classes.
Equality.
Reimplemented in casa::LCPolygon, casa::LCEllipsoid, casa::LCConcatenation, casa::LCRegionMulti, casa::LCLELMask, casa::LCMask, casa::LCUnion, casa::LCExtension, casa::LCStretch, casa::LCBox, casa::LCIntersection, casa::LCRegionFixed, casa::LCDifference, casa::LCComplement, casa::LCPagedMask, casa::LCHDF5Mask, and casa::LCPixelSet.
virtual void casa::LCRegion::putAt | ( | const Bool & | value, |
const IPosition & | where | ||
) | [virtual] |
Put the value of a single element.
The default implementation uses putSlice.
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
virtual void casa::LCRegion::set | ( | const Bool & | value | ) | [virtual] |
Set all elements in the Lattice to the given value.
Reimplemented from casa::Lattice< Bool >.
Reimplemented in casa::LCRegionSingle.
void casa::LCRegion::setBoundingBox | ( | const Slicer & | boundingBox | ) | [protected] |
Sometimes it is inconvenient for a derived class to set the bounding box in the constructor.
So it can be set explicitly. It fills in the possibly undefined Slicer values. It may even be needed to set the lattice shape.
void casa::LCRegion::setComment | ( | const String & | comment | ) | [inline] |
Definition at line 247 of file LCRegion.h.
References comment(), and itsComment.
void casa::LCRegion::setShapeAndBoundingBox | ( | const IPosition & | latticeShape, |
const Slicer & | boundingBox | ||
) | [protected] |
virtual IPosition casa::LCRegion::shape | ( | ) | const [virtual] |
virtual TableRecord casa::LCRegion::toRecord | ( | const String & | tableName | ) | const [pure virtual] |
Convert the (derived) 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.
Implemented in casa::LCMask, casa::LCPagedMask, casa::LCEllipsoid, casa::LCPolygon, casa::LCConcatenation, casa::LCLELMask, casa::LCExtension, casa::LCStretch, casa::LCUnion, casa::LCBox, casa::LCIntersection, casa::LCHDF5Mask, casa::LCDifference, casa::LCComplement, and casa::LCPixelSet.
LCRegion * casa::LCRegion::translate | ( | const IPosition & | translateVector | ) | const [inline] |
Construct another LCRegion (for e.g.
another lattice) by moving this one. It recalculates the bounding box and mask. A positive translation value indicates "to right".
Definition at line 234 of file LCRegion.h.
References itsShape.
Referenced by translate().
LCRegion* casa::LCRegion::translate | ( | const IPosition & | translateVector, |
const IPosition & | newLatticeShape | ||
) | const |
LCRegion * casa::LCRegion::translate | ( | const Vector< Float > & | translateVector | ) | const [inline] |
Definition at line 238 of file LCRegion.h.
References itsShape, and translate().
LCRegion* casa::LCRegion::translate | ( | const Vector< Float > & | translateVector, |
const IPosition & | newLatticeShape | ||
) | const |
virtual String casa::LCRegion::type | ( | ) | const [pure virtual] |
Region type.
Returns className() of derived class.
Implemented in casa::LCMask, casa::LCPagedMask, casa::LCEllipsoid, casa::LCPolygon, casa::LCConcatenation, casa::LCLELMask, casa::LCExtension, casa::LCStretch, casa::LCUnion, casa::LCBox, casa::LCIntersection, casa::LCHDF5Mask, casa::LCDifference, casa::LCComplement, and casa::LCPixelSet.
Slicer casa::LCRegion::itsBoundingBox [private] |
Definition at line 221 of file LCRegion.h.
Referenced by boundingBox().
String casa::LCRegion::itsComment [private] |
Definition at line 222 of file LCRegion.h.
Referenced by comment(), and setComment().
IPosition casa::LCRegion::itsShape [private] |
Definition at line 220 of file LCRegion.h.
Referenced by latticeShape(), and translate().