casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
casa::LCRegion Class Reference

Abstract base class to define a region of interest in lattice coordinates. More...

#include <LCRegion.h>

Inheritance diagram for casa::LCRegion:
casa::Lattice< Bool > casa::LatticeBase casa::LCRegionMulti casa::LCRegionSingle casa::LCComplement casa::LCConcatenation casa::LCDifference casa::LCExtension casa::LCIntersection casa::LCStretch casa::LCUnion casa::LCHDF5Mask casa::LCLELMask casa::LCMask casa::LCPagedMask casa::LCRegionFixed

List of all members.

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 LCRegioncloneRegion () 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 Stringcomment () const
 Get or set the comment.
void setComment (const String &comment)
virtual Bool hasMask () const =0
 Does the region have a mask?
LCRegiontranslate (const IPosition &translateVector) const
 Construct another LCRegion (for e.g.
LCRegiontranslate (const IPosition &translateVector, const IPosition &newLatticeShape) const
LCRegiontranslate (const Vector< Float > &translateVector) const
LCRegiontranslate (const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
const IPositionlatticeShape () const
 Give the full lattice shape.
const SlicerboundingBox () 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 LCRegionfromRecord (const TableRecord &, const String &tableName)
 Convert correct object from a record.

Protected Member Functions

LCRegionoperator= (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 LCRegiondoTranslate (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

Detailed Description

Abstract base class to define a region of interest in lattice coordinates.

Intended use:

Public interface

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.

Definition at line 86 of file LCRegion.h.


Constructor & Destructor Documentation

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]

Member Function Documentation

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]

Give the bounding box.

Definition at line 226 of file LCRegion.h.

References itsBoundingBox.

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

Give the full lattice shape.

Definition at line 230 of file LCRegion.h.

References itsShape.

virtual uInt casa::LCRegion::ndim ( ) const [virtual]

Return the dimensionality of the region.

Reimplemented from casa::LatticeBase.

Bool casa::LCRegion::operator!= ( const LCRegion other) const [inline]

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.

LCRegion& casa::LCRegion::operator= ( const LCRegion other) [protected]

     

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

virtual Bool casa::LCRegion::operator== ( const LCRegion other) const [virtual]
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]

Return the shape of the region (i.e.

of its bounding box).

Implements casa::LatticeBase.

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]

Member Data Documentation

Definition at line 221 of file LCRegion.h.

Referenced by boundingBox().

Definition at line 222 of file LCRegion.h.

Referenced by comment(), and setComment().

Definition at line 220 of file LCRegion.h.

Referenced by latticeShape(), and translate().


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