Class for a polygon in 2-D. More...
#include <Polygon.h>
Public Types | |
| typedef ads::FixedArray< 2, T > | Point |
| The representation of a point in 2 dimensions. | |
| typedef std::vector< Point > | Container |
| Container of points. | |
| typedef Container::terator | Iterator |
| An iterator over points. | |
| typedef Container::const_iterator | ConstIterator |
| A const Iterator over points. | |
| typedef int | SizeType |
| The size type. | |
Public Member Functions | |
Constructors etc. | |
| Polygon () | |
| Default constructor. Uninitialized memory. | |
| Polygon (SizeType size) | |
| Constructor. Reserve room for size vertices. | |
| Polygon (const Polygon &other) | |
| Copy constructor. | |
| Polygon & | operator= (const Polygon &other) |
| Assignment operator. | |
| ~Polygon () | |
| Trivial destructor. | |
Accesors. | |
| const Container & | getVertices () const |
| Return a const reference to the vector of vertices. | |
Mathematical functions. | |
| void | orderVertices () |
| Order the vertices in a positive orientation. | |
| void | removeDuplicates () |
| Remove adjacent duplicate vertices of an ordered polygon. | |
| int | computeBottomAndTop (T *bottom, T *top) const |
| Find the top and bottom of the polygon. Return bottom vertex index. | |
| template<typename MultiIndexType , typename MultiSizeType > | |
| void | scan_convert (std::vector< MultiIndexType > &indices_vector, MultiSizeType extents) const |
| Scan convert the Polygon in a 2-D grid. | |
| template<typename MultiIndexType , typename MultiSizeType > | |
| void | scan_convert (std::vector< MultiIndexType > &indices_vector, MultiSizeType extents, int z_coord) const |
| Scan convert the Polygon in a 3-D grid. | |
| void | clip (const Line_2< T > &ln) |
| Clip the Polygon against the line. | |
| bool | is_valid () 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 | mathematica_print () const |
| Write a Line[] object that Mathematica can read. | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T > | |
| bool | operator== (const Polygon< T > &a, const Polygon< T > &b) |
| Return true if the polygons have the same points in the same order. | |
| template<typename T > | |
| bool | operator!= (const Polygon< T > &a, const Polygon< 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, Polygon< T > &poly) |
| Read the number of vertices and each vertex. | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &out, const Polygon< T > &poly) |
| Write each vertex. | |
Class for a polygon in 2-D.
| T | is the number type. By default it is double. |
A Polygon is a list of vertices that are ordered in the positive, (counter-clockwise), direction. The edges have outward normals.
| bool Polygon< T >::is_valid | ( | ) | const |
Check if polygon is valid.
Check that the Polygon has at least three vertices and that adjacent vertices are not equal.
| void Polygon< T >::scan_convert | ( | std::vector< MultiIndexType > & | indices_vector, | |
| MultiSizeType | extents, | |||
| int | z_coord | |||
| ) | const [inline] |
Scan convert the Polygon in a 3-D grid.
| indices_vector | is the vector of grid indices. | |
| extents | are the extents of the grid. | |
| z_coord | is the z-coordinate of the slice being scan-converted. |
| void Polygon< T >::scan_convert | ( | std::vector< MultiIndexType > & | indices_vector, | |
| MultiSizeType | extents | |||
| ) | const [inline] |
Scan convert the Polygon in a 2-D grid.
| indices_vector | is the vector of grid indices. | |
| extents | are the extents of the grid. |
Return true if they don't have the same points in the same order.
| std::ostream & operator<< | ( | std::ostream & | out, | |
| const Polygon< T > & | poly | |||
| ) | [related] |
Write each vertex.
Return true if the polygons have the same points in the same order.
| std::istream & operator>> | ( | std::istream & | in, | |
| Polygon< T > & | poly | |||
| ) | [related] |
Read the number of vertices and each vertex.
References Polygon< T >::get().
1.6.3