LCRegion.h

Classes

LCRegion -- Abstract base class to define a region of interest in lattice coordinates. (full description)

class LCRegion : public Lattice<Bool>

Interface

Public Members
LCRegion()
LCRegion (const IPosition& latticeShape)
LCRegion (const LCRegion& other)
virtual ~LCRegion()
virtual Bool operator== (const LCRegion& other) const
Bool operator!= (const LCRegion& other) const
virtual Lattice<Bool>* clone() const
virtual LCRegion* cloneRegion() const = 0
virtual void handleDelete()
virtual void handleRename (const String& newName, Bool overwrite)
virtual String type() const = 0
const String& comment() const
void setComment (const String& comment)
virtual Bool hasMask() const = 0
LCRegion* translate (const IPosition& translateVector) const
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
const Slicer& boundingBox() const
Slicer expand (const Slicer& slicer) const
IPosition expand (const IPosition& index) const
virtual TableRecord toRecord (const String& tableName) const = 0
static LCRegion* fromRecord (const TableRecord&, const String& tableName)
virtual uInt ndim() const
virtual IPosition shape() const
virtual Bool isWritable() const
virtual void doPutSlice (const Array<Bool>& sourceBuffer, const IPosition& where, const IPosition& stride)
virtual void set (const Bool& value)
virtual void apply (Bool (*function)(Bool))
virtual void apply (Bool (*function)(const Bool&))
virtual void apply (const Functional<Bool,Bool>& function)
virtual void putAt (const Bool& value, const IPosition& where)
virtual void copyData (const Lattice<Bool>& from)
Protected Members
LCRegion& operator= (const LCRegion& other)
void setBoundingBox (const Slicer& boundingBox)
void setShapeAndBoundingBox (const IPosition& latticeShape, const Slicer& boundingBox)
virtual LCRegion* doTranslate (const Vector<Float>& translateVector, const IPosition& newLatticeShape) const = 0
void defineRecordFields (RecordInterface& record, const String& className) const

Description

Prerequisite

Synopsis

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.

Example


 

Motivation

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.

Member Description

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. 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.

virtual Lattice<Bool>* clone() const
virtual LCRegion* cloneRegion() const = 0

Make a copy of the derived object.

virtual void handleDelete()

Handle deletion of the region by deleting possible tables. The default implementation does nothing.

virtual void handleRename (const String& newName, Bool overwrite)

Handle renaming the region by renaming possible tables. The default implementation does nothing.

virtual String type() const = 0

Region type. Returns className() of derived class.

const String& comment() const
void setComment (const String& comment)

Get or set the comment.

virtual Bool hasMask() const = 0

Does the region have a mask?

LCRegion* translate (const IPosition& translateVector) const
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

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".

const IPosition& latticeShape() const

Give the full lattice shape.

const Slicer& boundingBox() const

Give the bounding box.

Slicer expand (const Slicer& slicer) const
IPosition expand (const IPosition& index) 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.

virtual TableRecord toRecord (const String& tableName) const = 0

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.

static LCRegion* fromRecord (const TableRecord&, const String& tableName)

Convert correct object from a record.

virtual uInt ndim() const

Return the dimensionality of the region.

virtual IPosition shape() const

Return the shape of the region (i.e. of its bounding box).

virtual Bool isWritable() const

Usually the lattice (i.e. the region mask) is not writable.

virtual void doPutSlice (const Array<Bool>& sourceBuffer, const IPosition& where, const IPosition& stride)
virtual void set (const Bool& value)
virtual void apply (Bool (*function)(Bool))
virtual void apply (Bool (*function)(const Bool&))
virtual void apply (const Functional<Bool,Bool>& function)
virtual void putAt (const Bool& value, const IPosition& where)
virtual void copyData (const Lattice<Bool>& from)

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.

LCRegion& operator= (const LCRegion& other)

Assignment (copy semantics) is only useful for derived classes.

void setBoundingBox (const Slicer& boundingBox)
void setShapeAndBoundingBox (const IPosition& latticeShape, const Slicer& boundingBox)

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.

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.