LCPolygon.h

Classes

LCPolygon -- Define a 2-dimensional region by a polygon. (full description)

class LCPolygon: public LCRegionFixed

Interface

Public Members
LCPolygon()
LCPolygon (const Vector<Float>& x, const Vector<Float>& y, const IPosition& latticeShape)
LCPolygon (const Vector<Double>& x, const Vector<Double>& y, const IPosition& latticeShape)
LCPolygon (const LCPolygon& other)
virtual ~LCPolygon()
LCPolygon& operator= (const LCPolygon& other)
virtual Bool operator== (const LCRegion& other) const
virtual LCRegion* cloneRegion() const
const Vector<Float>& x() const
const Vector<Float>& y() const
static String className()
virtual String type() const
virtual TableRecord toRecord (const String& tableName) const
static LCPolygon* fromRecord (const TableRecord&, const String& tablename)
Protected Members
virtual LCRegion* doTranslate (const Vector<Float>& translateVector, const IPosition& newLatticeShape) const
Private Members
void defineBox()
void defineMask()
void fillMask (Bool* mask, Int nx, Int ny, Int blcx, Int blcy, const Float* ptrX, const Float* ptrY, uInt nrline)
void fillLine (Bool* mask, Int nx, Int ny, Int x, Int y1, Int y2)

Description

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));

Member Description

LCPolygon()

LCPolygon (const Vector<Float>& x, const Vector<Float>& y, const IPosition& latticeShape)
LCPolygon (const Vector<Double>& x, const Vector<Double>& 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.

LCPolygon (const LCPolygon& other)

Copy constructor (reference semantics).

virtual ~LCPolygon()

LCPolygon& operator= (const LCPolygon& other)

Assignment (copy semantics).

virtual Bool operator== (const LCRegion& other) const

Comparison

virtual LCRegion* cloneRegion() 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.

static String className()

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

virtual String type() const

Get the region type. Returns className()

virtual TableRecord toRecord (const String& tableName) const

Convert the (derived) object to a record.

static LCPolygon* fromRecord (const TableRecord&, const String& tablename)

Convert correct object from a record.

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

Construct another LCPolygon (for e.g. another lattice) by moving this one. It recalculates the bounding box. A positive translation value indicates "to right".

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.

void fillLine (Bool* mask, Int nx, Int ny, Int x, Int y1, Int y2)

Fill a line in the mask between y1 and y2.