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 Member Functions | Private Attributes
casa::LCPolygon Class Reference

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

#include <LCPolygon.h>

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

List of all members.

Public Member Functions

 LCPolygon ()
 LCPolygon (const Vector< Float > &x, const Vector< Float > &y, const IPosition &latticeShape)
 Construct from the given x and y values.
 LCPolygon (const Vector< Double > &x, const Vector< Double > &y, const IPosition &latticeShape)
 LCPolygon (const LCPolygon &other)
 Copy constructor (reference semantics).
virtual ~LCPolygon ()
LCPolygonoperator= (const LCPolygon &other)
 Assignment (copy semantics).
virtual Bool operator== (const LCRegion &other) const
 Comparison.
virtual LCRegioncloneRegion () const
 Make a copy of the derived object.
const Vector< Float > & x () const
 Get the X-values.
const Vector< Float > & y () const
 Get the Y-values.
virtual String type () const
 Get the region type.
virtual TableRecord toRecord (const String &tableName) const
 Convert the (derived) object to a record.

Static Public Member Functions

static String className ()
 Get the class name (to store in the record).
static LCPolygonfromRecord (const TableRecord &, const String &tablename)
 Convert correct object from a record.

Protected Member Functions

virtual LCRegiondoTranslate (const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
 Construct another LCPolygon (for e.g.

Private Member Functions

void defineBox ()
 Make the bounding box.
void defineMask ()
 Define the mask to indicate which elements are inside the polygon.
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.
Int truncateStart (Float v)
 Truncate a start value to a pixel point.
Int truncateEnd (Float v, Int maxEnd)
 Truncate an end value to a pixel point.

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 points can be equal to the first one. If not, an extra point gets added to get 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. At least one point of the polygon must be within the lattice space. Points may be outside the lattice meaining that only part of the polygon surface is actually used.

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 105 of file LCPolygon.h.


Constructor & Destructor Documentation

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

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

Copy constructor (reference semantics).

virtual casa::LCPolygon::~LCPolygon ( ) [virtual]

Member Function Documentation

static String casa::LCPolygon::className ( ) [static]

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

virtual LCRegion* casa::LCPolygon::cloneRegion ( ) const [virtual]

Make a copy of the derived object.

Implements casa::LCRegion.

void casa::LCPolygon::defineBox ( ) [private]

Make the bounding box.

void casa::LCPolygon::defineMask ( ) [private]

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

virtual LCRegion* casa::LCPolygon::doTranslate ( const Vector< Float > &  translateVector,
const IPosition newLatticeShape 
) const [protected, virtual]

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 casa::LCRegion.

void casa::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* casa::LCPolygon::fromRecord ( const TableRecord ,
const String tablename 
) [static]

Convert correct object from a record.

Reimplemented from casa::LCRegion.

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

Assignment (copy semantics).

virtual Bool casa::LCPolygon::operator== ( const LCRegion other) const [virtual]

Comparison.

Reimplemented from casa::LCRegionFixed.

virtual TableRecord casa::LCPolygon::toRecord ( const String tableName) const [virtual]

Convert the (derived) object to a record.

Implements casa::LCRegion.

Int casa::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.

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 casa::LCPolygon::type ( ) const [virtual]

Get the region type.

Returns className()

Implements casa::LCRegion.

const Vector< Float > & casa::LCPolygon::x ( ) const [inline]

Get the X-values.

Definition at line 188 of file LCPolygon.h.

References itsX.

const Vector< Float > & casa::LCPolygon::y ( ) const [inline]

Get the Y-values.

Definition at line 192 of file LCPolygon.h.

References itsY.


Member Data Documentation

Definition at line 183 of file LCPolygon.h.

Referenced by x().

Definition at line 184 of file LCPolygon.h.

Referenced by y().


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