w2img::TruthPolygon Class Reference

Inheritance diagram for w2img::TruthPolygon:

w2img::Warning List of all members.

Detailed Description

A TruthPolygon allows you to construct a polygon in any cartesian space, and then verify whether an arbitrary point is inside or outside that polygon.

See also:
TruthPolygon
Author:
Lakshman
Version:
Id
w2img_TruthPolygon.h,v 1.9 2009/06/02 20:17:58 lakshman Exp


Public Member Functions

 TruthPolygon ()
bool contains (float x, float y, float *distance_x=0, float *distance_y=0) const
 Is the given x,y inside this polygon? Optinally, pass in third parameter to get the distance of point from polygon boundary.
void add (const TruthLine &side_of_polygon)
 Construct the polygon one side at a time.
void setName (const std::string &n)
const std::string & getName () const
void closePolygon ()
 Connects up end point of last side with start point of the first side.
float computeArea () const
 The area of the polygon, assuming that the edges are in order.
float getCx () const
 The centroid of the polygon assuming that the edges are in order.
float getCy () const
 The centroid of the polygon assuming that the edges are in order.
float max_x () const
float max_y () const
float min_x () const
float min_y () const

Static Public Member Functions

static void appendFromXML (const code::XML::Element &e, std::vector< TruthPolygon > *result)
 Pass in a polygons element or a polygon element.
static TruthPolygon create (const code::SingleContourData &contour)
 Create polygon from contour data.


Constructor & Destructor Documentation

w2img::TruthPolygon::TruthPolygon (  ) 


Member Function Documentation

void w2img::TruthPolygon::add ( const TruthLine side_of_polygon  )  [inline]

Construct the polygon one side at a time.

If the lines you've added don't automatically close the polygon, remember to call closePolygon() after calling all the add()

static void w2img::TruthPolygon::appendFromXML ( const code::XML::Element &  e,
std::vector< TruthPolygon > *  result 
) [static]

Pass in a polygons element or a polygon element.

We'll parse it and add all the necessary elements.

void w2img::TruthPolygon::closePolygon (  ) 

Connects up end point of last side with start point of the first side.

float w2img::TruthPolygon::computeArea (  )  const

The area of the polygon, assuming that the edges are in order.

bool w2img::TruthPolygon::contains ( float  x,
float  y,
float *  distance_x = 0,
float *  distance_y = 0 
) const

Is the given x,y inside this polygon? Optinally, pass in third parameter to get the distance of point from polygon boundary.

static TruthPolygon w2img::TruthPolygon::create ( const code::SingleContourData &  contour  )  [static]

Create polygon from contour data.

float w2img::TruthPolygon::getCx (  )  const

The centroid of the polygon assuming that the edges are in order.

float w2img::TruthPolygon::getCy (  )  const

The centroid of the polygon assuming that the edges are in order.

const std::string& w2img::TruthPolygon::getName (  )  const [inline]

float w2img::TruthPolygon::max_x (  )  const

float w2img::TruthPolygon::max_y (  )  const

float w2img::TruthPolygon::min_x (  )  const

float w2img::TruthPolygon::min_y (  )  const

void w2img::TruthPolygon::setName ( const std::string &  n  )  [inline]


Generated on Fri May 4 13:40:24 2012 for WDSS-IIw2algs by  doxygen 1.4.7