Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxPolyline2d Class Reference

A simple class for storing polylines and polygons. More...

#include <HxPolyline2d.h>

List of all members.

Public Methods

 HxPolyline2d ()
 Construct an empty polyline. More...

 HxPolyline2d (const HxPointSetR2 &v, int close)
 Construct a polyline or polygon (closed) from the given set of points. More...

 HxPolyline2d (double *px, double *py, int np, int close)
 Construct a polyline or polygon (closed) from the given set of coordinates. More...

 ~HxPolyline2d ()
 Destructor. More...

int ident () const
 Get the identifier of this object. More...

HxPointSetR2 getPoints () const
 Get the points of the object. More...

int getClosed () const
 Indicate whether this is a polyline or polygon. More...

int getNrPoints () const
 Get the number of points. More...

HxPointR2 getPoint (int index) const
 Get the points at the given index. More...

void getPoints (double *px, double *py) const
 Fill the given arrays with the coordinates of the points of this object. More...

STD_OSTREAM & put (STD_OSTREAM &) const
 Put this object on the given output stream. More...


Detailed Description

A simple class for storing polylines and polygons.

The difference between a polyline and polygon is the closed parameter. The number of points is the same, i.e. in a polygon the start/end point is NOT repeated in the list of points.


Constructor & Destructor Documentation

HxPolyline2d::HxPolyline2d   [inline]
 

Construct an empty polyline.

00080 {
00081     _ident = _nr++;
00082 }

HxPolyline2d::HxPolyline2d const HxPointSetR2 &    v,
int    close
[inline]
 

Construct a polyline or polygon (closed) from the given set of points.

00085                                                            :
00086     _points(v), _closed(close)
00087 {
00088     _ident = _nr++;
00089 }

HxPolyline2d::HxPolyline2d double *    px,
double *    py,
int    np,
int    close
[inline]
 

Construct a polyline or polygon (closed) from the given set of coordinates.

00093 {
00094     for (int i=0 ; i<np ; i++)
00095         _points.push_back(HxPointR2(*px++, *py++));
00096     _closed = close;
00097     _ident = _nr++;
00098 }

HxPolyline2d::~HxPolyline2d   [inline]
 

Destructor.

00102 {
00103 }


Member Function Documentation

int HxPolyline2d::ident   const [inline]
 

Get the identifier of this object.

00107 {
00108     return _ident;
00109 }

HxPointSetR2 HxPolyline2d::getPoints   const [inline]
 

Get the points of the object.

00113 {
00114     return _points;
00115 }

int HxPolyline2d::getClosed   const [inline]
 

Indicate whether this is a polyline or polygon.

00119 {
00120     return _closed;
00121 }

int HxPolyline2d::getNrPoints   const [inline]
 

Get the number of points.

00125 {
00126     return _points.size();
00127 }

HxPointR2 HxPolyline2d::getPoint int    index const [inline]
 

Get the points at the given index.

00131 {
00132     return _points[index];
00133 }

void HxPolyline2d::getPoints double *    px,
double *    py
const
 

Fill the given arrays with the coordinates of the points of this object.

The size of the araays is assumed to match the number of points.

00018 {
00019     HxPointSetR2::const_iterator it = _points.begin();
00020     while (it != _points.end()) {
00021         *px++ = (*it).x();
00022         *py++ = (*it).y();
00023         it++;
00024     }
00025 }

STD_OSTREAM & HxPolyline2d::put STD_OSTREAM &    os const
 

Put this object on the given output stream.

00029 {
00030     HxPointSetR2::const_iterator it = _points.begin();
00031     while (it != _points.end()) {
00032         os << (*it) << ", ";
00033         it++;
00034     }
00035     return os << "closed: " << _closed << STD_ENDL;
00036 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 14:19:07 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001