casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
casacore::LCPolygon Class Reference

Define a 2-dimensional region by a polygon. More...

#include <LCPolygon.h>

Inheritance diagram for casacore::LCPolygon:
casacore::LCRegionFixed casacore::LCRegionSingle casacore::LCRegion casacore::Lattice< Bool > casacore::LatticeBase

Public Member Functions

 LCPolygon ()
 
 LCPolygon (const Vector< Float > &x, const Vector< Float > &y, const IPosition &latticeShape)
 Construct from the given x and y values. More...
 
 LCPolygon (const Vector< Double > &x, const Vector< Double > &y, const IPosition &latticeShape)
 
 LCPolygon (const LCPolygon &other)
 Copy constructor (reference semantics). More...
 
virtual ~LCPolygon ()
 
LCPolygonoperator= (const LCPolygon &other)
 Assignment (copy semantics). More...
 
virtual Bool operator== (const LCRegion &other) const
 Comparison. More...
 
virtual LCRegioncloneRegion () const
 Make a copy of the derived object. More...
 
const Vector< Float > & x () const
 Get the X-values. More...
 
const Vector< Float > & y () const
 Get the Y-values. More...
 
virtual String type () const
 Get the region type. More...
 
virtual TableRecord toRecord (const String &tableName) const
 Convert the (derived) object to a record. More...
 
- Public Member Functions inherited from casacore::LCRegionFixed
 LCRegionFixed ()
 
 LCRegionFixed (const IPosition &latticeShape)
 Construct with the lattice shape only. More...
 
 LCRegionFixed (const LCRegionFixed &other)
 Copy constructor (copy semantics). More...
 
virtual ~LCRegionFixed ()
 Destructor. More...
 
const ArrayLattice< Bool > & getMask () const
 Return the mask. More...
 
- Public Member Functions inherited from casacore::LCRegionSingle
 LCRegionSingle ()
 
 LCRegionSingle (const IPosition &latticeShape)
 Construct with the lattice shape only. More...
 
 LCRegionSingle (const LCRegionSingle &other)
 Copy constructor (copy semantics). More...
 
virtual ~LCRegionSingle ()
 
virtual Bool hasMask () const
 Does the region have a mask? More...
 
const Array< BoolmaskArray () const
 Get the mask (as an array). More...
 
Bool masksEqual (const LCRegion &other) const
 Is the mask of this region the same as the mask of the other. More...
 
virtual void set (const Bool &value)
 The following "put" functions are described in detail in class Lattice. More...
 
virtual void apply (Bool(*function)(Bool))
 Replace every element, x, of the Lattice with the result of f(x). More...
 
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. More...
 
virtual void copyData (const Lattice< Bool > &from)
 Copy the data from the given lattice to this one. More...
 
- Public Member Functions inherited from casacore::LCRegion
 LCRegion ()
 
 LCRegion (const IPosition &latticeShape)
 Construct with the lattice shape only. More...
 
 LCRegion (const LCRegion &other)
 Copy constructor (copy semantics). More...
 
virtual ~LCRegion ()
 
Bool operator!= (const LCRegion &other) const
 Non-equality. More...
 
virtual Lattice< Bool > * clone () const
 Make a copy of the derived object. More...
 
virtual void handleDelete ()
 Handle deletion of the region by deleting possible tables. More...
 
virtual void handleRename (const String &newName, Bool overwrite)
 Handle renaming the region by renaming possible tables. More...
 
const Stringcomment () const
 Get or set the comment. More...
 
void setComment (const String &comment)
 
LCRegiontranslate (const IPosition &translateVector) const
 Construct another LCRegion (for e.g. More...
 
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. More...
 
const SlicerboundingBox () const
 Give the bounding box. More...
 
Slicer expand (const Slicer &slicer) const
 Expand a slicer or position in the region to the full lattice. More...
 
IPosition expand (const IPosition &index) const
 
virtual uInt ndim () const
 Return the dimensionality of the region. More...
 
virtual IPosition shape () const
 Return the shape of the region (i.e. More...
 
virtual Bool isWritable () const
 Usually the lattice (i.e. More...
 
- Public Member Functions inherited from casacore::Lattice< Bool >
virtual ~Lattice ()
 a virtual destructor is needed so that it will use the actual destructor in the derived class More...
 
virtual DataType dataType () const
 Get the data type of the lattice. More...
 
Bool operator() (const IPosition &where) const
 Return the value of the single element located at the argument IPosition. More...
 
virtual Bool getAt (const IPosition &where) const
 
Bool get (COWPtr< Array< Bool > > &buffer, Bool removeDegenerateAxes=False) const
 Functions which extract an Array of values from a Lattice. More...
 
Bool get (Array< Bool > &buffer, Bool removeDegenerateAxes=False)
 
Array< Boolget (Bool removeDegenerateAxes=False) const
 
Bool getSlice (COWPtr< Array< Bool > > &buffer, const Slicer &section, Bool removeDegenerateAxes=False) const
 
Bool getSlice (COWPtr< Array< Bool > > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const
 
Bool getSlice (COWPtr< Array< Bool > > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const
 
Bool getSlice (Array< Bool > &buffer, const Slicer &section, Bool removeDegenerateAxes=False)
 
Bool getSlice (Array< Bool > &buffer, const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False)
 
Bool getSlice (Array< Bool > &buffer, const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False)
 
Array< BoolgetSlice (const Slicer &section, Bool removeDegenerateAxes=False) const
 
Array< BoolgetSlice (const IPosition &start, const IPosition &shape, Bool removeDegenerateAxes=False) const
 
Array< BoolgetSlice (const IPosition &start, const IPosition &shape, const IPosition &stride, Bool removeDegenerateAxes=False) const
 
void putSlice (const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
 A function which places an Array of values within this instance of the Lattice at the location specified by the IPosition "where", incrementing by "stride". More...
 
void putSlice (const Array< Bool > &sourceBuffer, const IPosition &where)
 
void put (const Array< Bool > &sourceBuffer)
 
void operator+= (const Lattice< Bool > &other)
 Add, subtract, multiple, or divide by another Lattice. More...
 
void operator-= (const Lattice< Bool > &other)
 
void operator*= (const Lattice< Bool > &other)
 
void operator/= (const Lattice< Bool > &other)
 
virtual void copyDataTo (Lattice< Bool > &to) const
 Copy the data from this lattice to the given lattice. More...
 
virtual uInt advisedMaxPixels () const
 This function returns the advised maximum number of pixels to include in the cursor of an iterator. More...
 
- Public Member Functions inherited from casacore::LatticeBase
virtual ~LatticeBase ()
 A virtual destructor is needed so that it will use the actual destructor in the derived class. More...
 
virtual String imageType () const
 Get the image type (returns name of derived class). More...
 
virtual Bool isPersistent () const
 Is the lattice persistent and can it be loaded by other processes as well? That is the case for a PagedArray or PagedImage and for an ImageExpr which does not use transient lattices or regions. More...
 
virtual Bool isPaged () const
 Is the lattice paged to disk?
The default implementation returns False. More...
 
virtual Bool canReferenceArray () const
 Can the lattice data be referenced as an array section? That is the case for an ArrayLattice or a Temp/SubLattice using it. More...
 
virtual void save (const String &fileName) const
 Save the image in an AipsIO file with the given name. More...
 
virtual Bool lock (FileLocker::LockType, uInt nattempts)
 It is strongly recommended to use class LatticeLocker to handle lattice locking. More...
 
virtual void unlock ()
 
virtual Bool hasLock (FileLocker::LockType) const
 
virtual void resync ()
 Resynchronize the Lattice object with the lattice file. More...
 
virtual void flush ()
 Flush the data (but do not unlock). More...
 
virtual void tempClose ()
 Temporarily close the lattice. More...
 
virtual void reopen ()
 Explicitly reopen the temporarily closed lattice. More...
 
virtual String name (Bool stripPath=False) const
 Return the name of the current Lattice object. More...
 
virtual size_t nelements () const
 Return the total number of elements in this Lattice. More...
 
size_t size () const
 
Bool conform (const LatticeBase &other) const
 Return a value of "True" if this instance of Lattice and 'other' have the same shape, otherwise returns a value of "False". More...
 
virtual LELCoordinates lelCoordinates () const
 Return the coordinates of the lattice. More...
 
IPosition niceCursorShape (uInt maxPixels) const
 Returns a recommended cursor shape for iterating through all the pixels in the Lattice. More...
 
IPosition niceCursorShape () const
 
virtual Bool ok () const
 Check class internals - used for debugging. More...
 
virtual uInt maximumCacheSize () const
 Maximum cache size - not necessarily all used. More...
 
virtual void setMaximumCacheSize (uInt howManyPixels)
 Set the maximum (allowed) cache size as indicated. More...
 
virtual void setCacheSizeInTiles (uInt howManyTiles)
 Set the actual cache size for this Array to be big enough for the indicated number of tiles. More...
 
virtual void setCacheSizeFromPath (const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
 Set the cache size as to "fit" the indicated path. More...
 
virtual void clearCache ()
 Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSize was called. More...
 
virtual void showCacheStatistics (ostream &os) const
 Report on cache success. More...
 

Static Public Member Functions

static String className ()
 Get the class name (to store in the record). More...
 
static LCPolygonfromRecord (const TableRecord &, const String &tablename)
 Convert correct object from a record. More...
 
- Static Public Member Functions inherited from casacore::LCRegion
static LCRegionfromRecord (const TableRecord &, const String &tableName)
 Convert correct object from a record. More...
 

Protected Member Functions

virtual LCRegiondoTranslate (const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
 Construct another LCPolygon (for e.g. More...
 
- Protected Member Functions inherited from casacore::LCRegionFixed
LCRegionFixedoperator= (const LCRegionFixed &other)
 Assignment (copy semantics) is only useful for derived classes. More...
 
void setMask (const Array< Bool > &mask)
 Set the mask. More...
 
- Protected Member Functions inherited from casacore::LCRegionSingle
LCRegionSingleoperator= (const LCRegionSingle &other)
 Assignment (copy semantics) is only useful for derived classes. More...
 
void setMaskPtr (Lattice< Bool > &mask)
 Set the pointer to the mask in the derived class. More...
 
virtual Bool doGetSlice (Array< Bool > &buffer, const Slicer &section)
 Do the actual getting of the mask. More...
 
virtual void doPutSlice (const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
 Do the actual putting of the mask. More...
 
virtual IPosition doNiceCursorShape (uInt maxPixels) const
 Get the best cursor shape. More...
 
virtual LatticeIterInterface
< Bool > * 
makeIter (const LatticeNavigator &navigator, Bool useRef) const
 Make an iterator. More...
 
- Protected Member Functions inherited from casacore::LCRegion
LCRegionoperator= (const LCRegion &other)
 Assignment (copy semantics) is only useful for derived classes. More...
 
void setBoundingBox (const Slicer &boundingBox)
 Sometimes it is inconvenient for a derived class to set the bounding box in the constructor. More...
 
void setShapeAndBoundingBox (const IPosition &latticeShape, const Slicer &boundingBox)
 
void defineRecordFields (RecordInterface &record, const String &className) const
 Define the type and class name in the record. More...
 
- Protected Member Functions inherited from casacore::Lattice< Bool >
 Lattice ()
 Define default constructor to satisfy compiler. More...
 
 Lattice (const Lattice< Bool > &)
 Copy constructor and assignment can only be used by derived classes. More...
 
virtual void handleMath (const Lattice< Bool > &from, int oper)
 Handle the Math operators (+=, -=, *=, /=). More...
 
virtual void handleMathTo (Lattice< Bool > &to, int oper) const
 
Lattice< Bool > & operator= (const Lattice< Bool > &)
 
- Protected Member Functions inherited from casacore::LatticeBase
 LatticeBase ()
 Define default constructor to be used by derived classes. More...
 
 LatticeBase (const LatticeBase &)
 Copy constructor and assignment can only be used by derived classes. More...
 
LatticeBaseoperator= (const LatticeBase &)
 
void throwBoolMath () const
 Throw an exception for arithmetic on a Bool Lattice. More...
 

Private Member Functions

void defineBox ()
 Make the bounding box. More...
 
void defineMask ()
 Define the mask to indicate which elements are inside the polygon. More...
 
void fillMask (Bool *mask, Int nx, Int ny, Int blcx, Int blcy, const Float *ptrX, const Float *ptrY, uInt nrline)
 Fill the mask from the given points. More...
 
Int truncateStart (Float v)
 Truncate a start value to a pixel point. More...
 
Int truncateEnd (Float v, Int maxEnd)
 Truncate an end value to a pixel point. More...
 

Static Private Member Functions

static Bool _isNear (Float val1, Float val2)
 takes into account when one value is zero and the other is absolutely (as opposed to relatively) near zero. More...
 

Private Attributes

Vector< FloatitsX
 
Vector< FloatitsY
 

Detailed Description

Define a 2-dimensional region by a polygon.

Intended use:

Public interface

Prerequisite

Synopsis

The LCPolygon class is a specialization of class LCRegion. It makes it possible to define a 2-dimensional region by means an ordered collection of points with straight lines connecting adjacent points. The last point can be equal to the first one. If not, an extra point gets added to form the closing line.

The polygon can be as complex as one likes. E.g. it is possible to have a rectangle with an inner rectangle to exclude interior points.

The points defining the polygon do not need to coincide with pixel points. Points may be outside the lattice meaning that only part of the polygon surface is actually used. However, at least some part of the polygon surface has to intersect with the lattice.
A lattice pixel is part of the polygon surface if the center of the pixel is on or inside the polygon. Note that 0 is the beginning ond 1 is the end of the first pixel. Thus 0.5 is its center.

Example

// A simple (tilted) square.
Vector<Float> x(4), y(4);
x(0)=3; y(0)=3;
x(1)=6; y(1)=6;
x(2)=3; y(2)=9;
x(3)=0; y(3)=6;
LCPolygon region(x, y, IPosition(2,128,128));
// A rectangle with an inner region to exclude interior points.
// Note that the last point is equal to the first point, thus
// the last line is given explicitly.
Vector<Float> x(11), y(11);
x(0)=3; y(0)=3;
x(1)=9; y(1)=3;
x(2)=9; y(2)=8;
x(3)=3; y(3)=8;
x(4)=3; y(4)=3;
x(5)=5; y(5)=5;
x(6)=8; y(6)=4;
x(7)=7; y(7)=7;
x(8)=5; y(8)=7;
x(9)=5; y(9)=5;
x(10)=3; y(10)=3;
LCPolygon region(x, y, IPosition(2,128,128));

Definition at line 109 of file LCPolygon.h.

Constructor & Destructor Documentation

casacore::LCPolygon::LCPolygon ( )
casacore::LCPolygon::LCPolygon ( const Vector< Float > &  x,
const Vector< Float > &  y,
const IPosition latticeShape 
)

Construct from the given x and y values.

The latticeShape must define a 2-dimensional lattice.
LCPolygon can be used for an N-dimensional lattice by making another lattice representing any 2 axes from the original lattice.

casacore::LCPolygon::LCPolygon ( const Vector< Double > &  x,
const Vector< Double > &  y,
const IPosition latticeShape 
)
casacore::LCPolygon::LCPolygon ( const LCPolygon other)

Copy constructor (reference semantics).

virtual casacore::LCPolygon::~LCPolygon ( )
virtual

Member Function Documentation

static Bool casacore::LCPolygon::_isNear ( Float  val1,
Float  val2 
)
staticprivate

takes into account when one value is zero and the other is absolutely (as opposed to relatively) near zero.

static String casacore::LCPolygon::className ( )
static

Get the class name (to store in the record).

virtual LCRegion* casacore::LCPolygon::cloneRegion ( ) const
virtual

Make a copy of the derived object.

Implements casacore::LCRegion.

void casacore::LCPolygon::defineBox ( )
private

Make the bounding box.

void casacore::LCPolygon::defineMask ( )
private

Define the mask to indicate which elements are inside the polygon.

virtual LCRegion* casacore::LCPolygon::doTranslate ( const Vector< Float > &  translateVector,
const IPosition newLatticeShape 
) const
protectedvirtual

Construct another LCPolygon (for e.g.

another lattice) by moving this one. It recalculates the bounding box. A positive translation value indicates "to right".

Implements casacore::LCRegion.

void casacore::LCPolygon::fillMask ( Bool mask,
Int  nx,
Int  ny,
Int  blcx,
Int  blcy,
const Float ptrX,
const Float ptrY,
uInt  nrline 
)
private

Fill the mask from the given points.

static LCPolygon* casacore::LCPolygon::fromRecord ( const TableRecord ,
const String tablename 
)
static

Convert correct object from a record.

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

Assignment (copy semantics).

virtual Bool casacore::LCPolygon::operator== ( const LCRegion other) const
virtual

Comparison.

Reimplemented from casacore::LCRegionFixed.

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

Convert the (derived) object to a record.

Implements casacore::LCRegion.

Int casacore::LCPolygon::truncateEnd ( Float  v,
Int  maxEnd 
)
private

Truncate an end value to a pixel point.

A pixel point is taken if near the value, otherwise floor(value). The returned value is never > maxEnd.

Int casacore::LCPolygon::truncateStart ( Float  v)
private

Truncate a start value to a pixel point.

A pixel point is taken if near the value, otherwise floor(value+1). The returned value is never < 0.

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

Get the region type.

Returns className()

Implements casacore::LCRegion.

const Vector< Float > & casacore::LCPolygon::x ( ) const
inline

Get the X-values.

Definition at line 195 of file LCPolygon.h.

References itsX.

const Vector< Float > & casacore::LCPolygon::y ( ) const
inline

Get the Y-values.

Definition at line 199 of file LCPolygon.h.

References itsY.

Member Data Documentation

Vector<Float> casacore::LCPolygon::itsX
private

Definition at line 190 of file LCPolygon.h.

Referenced by x().

Vector<Float> casacore::LCPolygon::itsY
private

Definition at line 191 of file LCPolygon.h.

Referenced by y().


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