casacore::LCRegion Class Reference

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

#include <LCRegion.h>

Inheritance diagram for casacore::LCRegion:
casacore::Lattice< Bool > casacore::LatticeBase casacore::LCRegionMulti casacore::LCRegionSingle casacore::LCComplement casacore::LCConcatenation casacore::LCDifference casacore::LCExtension casacore::LCIntersection casacore::LCStretch casacore::LCUnion casacore::LCHDF5Mask casacore::LCLELMask casacore::LCMask casacore::LCPagedMask casacore::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)
 Assignment (copy semantics) is only useful for derived classes.
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 87 of file LCRegion.h.


Constructor & Destructor Documentation

casacore::LCRegion::LCRegion (  ) 
casacore::LCRegion::LCRegion ( const IPosition latticeShape  ) 

Construct with the lattice shape only.

casacore::LCRegion::LCRegion ( const LCRegion other  ) 

Copy constructor (copy semantics).

virtual casacore::LCRegion::~LCRegion (  )  [virtual]

Member Function Documentation

virtual void casacore::LCRegion::apply ( const Functional< Bool, Bool > &  function  )  [virtual]

Reimplemented from casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

virtual void casacore::LCRegion::apply ( Bool(*)(const Bool &)  function  )  [virtual]

Reimplemented from casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

virtual void casacore::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 casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

const Slicer & casacore::LCRegion::boundingBox (  )  const [inline]

Give the bounding box.

Definition at line 227 of file LCRegion.h.

References itsBoundingBox.

virtual Lattice<Bool>* casacore::LCRegion::clone (  )  const [virtual]

Make a copy of the derived object.

Implements casacore::Lattice< Bool >.

virtual LCRegion* casacore::LCRegion::cloneRegion (  )  const [pure virtual]
const String & casacore::LCRegion::comment (  )  const [inline]

Get or set the comment.

Definition at line 244 of file LCRegion.h.

References itsComment.

virtual void casacore::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 casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

void casacore::LCRegion::defineRecordFields ( RecordInterface record,
const String className 
) const [protected]

Define the type and class name in the record.

virtual void casacore::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 casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

virtual LCRegion* casacore::LCRegion::doTranslate ( const Vector< Float > &  translateVector,
const IPosition newLatticeShape 
) const [protected, pure virtual]
IPosition casacore::LCRegion::expand ( const IPosition index  )  const
Slicer casacore::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.

static LCRegion* casacore::LCRegion::fromRecord ( const TableRecord ,
const String tableName 
) [static]
virtual void casacore::LCRegion::handleDelete (  )  [virtual]

Handle deletion of the region by deleting possible tables.

The default implementation does nothing.

Reimplemented in casacore::LCPagedMask.

virtual void casacore::LCRegion::handleRename ( const String newName,
Bool  overwrite 
) [virtual]

Handle renaming the region by renaming possible tables.

The default implementation does nothing.

Reimplemented in casacore::LCPagedMask.

virtual Bool casacore::LCRegion::hasMask (  )  const [pure virtual]

Does the region have a mask?

Implemented in casacore::LCRegionMulti, and casacore::LCRegionSingle.

virtual Bool casacore::LCRegion::isWritable (  )  const [virtual]

Usually the lattice (i.e.

the region mask) is not writable.

Reimplemented from casacore::LatticeBase.

Reimplemented in casacore::LCHDF5Mask, casacore::LCMask, and casacore::LCPagedMask.

const IPosition & casacore::LCRegion::latticeShape (  )  const [inline]

Give the full lattice shape.

Definition at line 231 of file LCRegion.h.

References itsShape.

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

Return the dimensionality of the region.

Reimplemented from casacore::LatticeBase.

Bool casacore::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 253 of file LCRegion.h.

LCRegion& casacore::LCRegion::operator= ( const LCRegion other  )  [protected]
virtual Bool casacore::LCRegion::operator== ( const LCRegion other  )  const [virtual]

Equality.

virtual void casacore::LCRegion::putAt ( const Bool value,
const IPosition where 
) [virtual]

Put the value of a single element.


The default implementation uses putSlice.

Reimplemented from casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

virtual void casacore::LCRegion::set ( const Bool value  )  [virtual]

Set all elements in the Lattice to the given value.

Reimplemented from casacore::Lattice< Bool >.

Reimplemented in casacore::LCRegionSingle.

void casacore::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 casacore::LCRegion::setComment ( const String comment  )  [inline]

Definition at line 248 of file LCRegion.h.

References itsComment.

void casacore::LCRegion::setShapeAndBoundingBox ( const IPosition latticeShape,
const Slicer boundingBox 
) [protected]
virtual IPosition casacore::LCRegion::shape (  )  const [virtual]

Return the shape of the region (i.e.

of its bounding box).

Implements casacore::LatticeBase.

virtual TableRecord casacore::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 casacore::LCBox, casacore::LCComplement, casacore::LCConcatenation, casacore::LCDifference, casacore::LCEllipsoid, casacore::LCExtension, casacore::LCHDF5Mask, casacore::LCIntersection, casacore::LCLELMask, casacore::LCMask, casacore::LCPagedMask, casacore::LCPixelSet, casacore::LCPolygon, casacore::LCStretch, and casacore::LCUnion.

LCRegion* casacore::LCRegion::translate ( const Vector< Float > &  translateVector,
const IPosition newLatticeShape 
) const
LCRegion * casacore::LCRegion::translate ( const Vector< Float > &  translateVector  )  const [inline]

Definition at line 239 of file LCRegion.h.

References itsShape, and translate().

LCRegion* casacore::LCRegion::translate ( const IPosition translateVector,
const IPosition newLatticeShape 
) const
LCRegion * casacore::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 235 of file LCRegion.h.

References itsShape.

Referenced by translate().

virtual String casacore::LCRegion::type (  )  const [pure virtual]

Member Data Documentation

Definition at line 222 of file LCRegion.h.

Referenced by boundingBox().

Definition at line 223 of file LCRegion.h.

Referenced by comment(), and setComment().

Definition at line 221 of file LCRegion.h.

Referenced by latticeShape(), and translate().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1