Class for a polygon in 2-D. More...
#include <ScanConversionPolygon.h>
Public Types | |
typedef T | Number |
The floating point number type. | |
typedef ads::FixedArray < 2, Number > | Point |
The representation of a point in 2 dimensions. | |
typedef int | SizeType |
The size type. | |
typedef Container::iterator | Iterator |
An iterator over points. | |
typedef Container::const_iterator | ConstIterator |
A const Iterator over points. | |
Public Member Functions | |
Constructors etc. | |
ScanConversionPolygon () | |
Default constructor. Uninitialized memory. | |
ScanConversionPolygon (SizeType size) | |
Constructor. Reserve room for size vertices. | |
ScanConversionPolygon (const ScanConversionPolygon &other) | |
Copy constructor. | |
ScanConversionPolygon & | operator= (const ScanConversionPolygon &other) |
Assignment operator. | |
~ScanConversionPolygon () | |
Trivial destructor. | |
Accesors. | |
SizeType | getVerticesSize () const |
Return the number of vertices. | |
const Point & | getVertex (const int n) const |
Return a const reference to the specified vertex. | |
Manipulators. | |
Iterator | getVerticesBeginning () |
Iterator | getVerticesEnd () |
void | clear () |
Clear the vertices. | |
void | insert (const Point &x) |
Add a vertex. | |
Mathematical functions. | |
void | orderVertices () |
Order the vertices in a positive orientation. | |
void | removeDuplicates () |
Remove adjacent duplicate vertices of an ordered polygon. | |
int | computeBottomAndTop (Number *bottom, Number *top) const |
Find the top and bottom of the polygon. Return bottom vertex index. | |
template<typename IndexOutputIterator > | |
void | scanConvert (IndexOutputIterator coords, const ads::FixedArray< 2, int > &extents) const |
Scan convert the ScanConversionPolygon in a 2-D grid. | |
template<typename IndexOutputIterator > | |
void | scanConvert (IndexOutputIterator coords, const ads::FixedArray< 3, int > &extents, const int zCoordinate) const |
Scan convert the ScanConversionPolygon in a 3-D grid. | |
void | clip (const Line_2< Number > &line) |
Clip the ScanConversionPolygon against the line. | |
bool | isValid () const |
Check if polygon is valid. | |
File I/O. | |
void | get (std::istream &in) |
Read the number of vertices and each vertex. | |
void | put (std::ostream &out) const |
Write each vertex. | |
void | mathematicaPrint (std::ostream &out) const |
Write a Line[] object that Mathematica can read. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
bool | operator== (const ScanConversionPolygon< T > &a, const ScanConversionPolygon< T > &b) |
Return true if the polygons have the same points in the same order. | |
template<typename T > | |
bool | operator!= (const ScanConversionPolygon< T > &a, const ScanConversionPolygon< T > &b) |
Return true if they don't have the same points in the same order. | |
template<typename T > | |
std::istream & | operator>> (std::istream &in, ScanConversionPolygon< T > &x) |
Read the number of vertices and each vertex. | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const ScanConversionPolygon< T > &x) |
Write each vertex. |
Class for a polygon in 2-D.
T | is the number type. By default it is double. |
A ScanConversionPolygon is a list of vertices that are ordered in the positive, (counter-clockwise), direction. The edges have outward normals.
bool ScanConversionPolygon< T >::isValid | ( | ) | const |
Check if polygon is valid.
Check that the ScanConversionPolygon has at least three vertices and that adjacent vertices are not equal.
void ScanConversionPolygon< T >::scanConvert | ( | IndexOutputIterator | coords, | |
const ads::FixedArray< 3, int > & | extents, | |||
const int | zCoordinate | |||
) | const [inline] |
Scan convert the ScanConversionPolygon in a 3-D grid.
coords | is an output Iterator for the set of grid indices. | |
extents | are the extents of the grid. | |
zCoordinate | is the z-coordinate of the slice being scan-converted. |
References ScanConversionPolygon< T >::scanConvert().
void ScanConversionPolygon< T >::scanConvert | ( | IndexOutputIterator | coords, | |
const ads::FixedArray< 2, int > & | extents | |||
) | const [inline] |
Scan convert the ScanConversionPolygon in a 2-D grid.
coords | is an output Iterator for the set of grid indices. | |
extents | are the extents of the grid. |
Referenced by ScanConversionPolygon< T >::scanConvert().
bool operator!= | ( | const ScanConversionPolygon< T > & | a, | |
const ScanConversionPolygon< T > & | b | |||
) | [related] |
Return true if they don't have the same points in the same order.
std::ostream & operator<< | ( | std::ostream & | out, | |
const ScanConversionPolygon< T > & | x | |||
) | [related] |
Write each vertex.
bool operator== | ( | const ScanConversionPolygon< T > & | a, | |
const ScanConversionPolygon< T > & | b | |||
) | [related] |
Return true if the polygons have the same points in the same order.
std::istream & operator>> | ( | std::istream & | in, | |
ScanConversionPolygon< T > & | x | |||
) | [related] |
Read the number of vertices and each vertex.
References ScanConversionPolygon< T >::get().