Thea
|
A polygon in 3-space. More...
#include <Polygon3.hpp>
Public Types | |
typedef Polygon3Internal::IndexedVertex | IndexedVertex |
A vertex plus an index. More... | |
Public Member Functions | |
void | addVertex (Vector3 const &p) |
Add a vertex to the polygon. More... | |
void | addVertex (Vector3 const &p, intx index) |
Add an indexed vertex to the polygon. More... | |
void | clear () |
Delete all vertices from the polygon. More... | |
Real | computeArea () const |
Compute the area of the polygon. More... | |
Vector3 | computeNormal () const |
Compute the unit normal of the polygon. More... | |
AxisAlignedBox3 const & | getBounds () |
Get the bounding box of the polygon. More... | |
IndexedVertex const & | getVertex (intx poly_index) const |
Get the vertex at position poly_index in the sequence of vertices around the polygon boundary. More... | |
intx | numVertices () const |
Get the number of vertices in the polygon. More... | |
Polygon3 () | |
Construct an empty polygon. More... | |
intx | triangulate (Array< intx > &tri_indices, Real epsilon=-1) const |
Triangulate the polygon and return the set of triangle indices (in successive groups of 3). More... | |
Static Public Member Functions | |
template<typename VertexInputIterator > | |
static Real | computeArea (VertexInputIterator vbegin, VertexInputIterator vend) |
Compute the area of an arbitrary polygon (does not require explicit creation of a Polygon3). More... | |
template<typename VertexInputIterator > | |
static Vector3 | computeNormal (VertexInputIterator vbegin, VertexInputIterator vend) |
Compute the unit normal of an arbitrary polygon (does not require explicit creation of a Polygon3). More... | |
template<typename T > | |
static int | triangulateQuad (Vector< 3, T > const &p0, Vector< 3, T > const &p1, Vector< 3, T > const &p2, Vector< 3, T > const &p3, intx &i0, intx &j0, intx &k0, intx &i1, intx &j1, intx &k1, T const &epsilon=-1) |
Utility function to split a (possibly non-convex) quadrilateral into a pair of triangles with the same winding direction. More... | |
A polygon in 3-space.
Original code due to John W. Ratcliff.
Definition at line 93 of file Polygon3.hpp.
A vertex plus an index.
Definition at line 98 of file Polygon3.hpp.
Polygon3 | ( | ) |
Construct an empty polygon.
Definition at line 67 of file Polygon3.cpp.
void addVertex | ( | Vector3 const & | p | ) |
Add a vertex to the polygon.
The vertex is inserted at the end of the current sequence of vertices, and by default is assigned an index that is one more than the maximum index in the polygon so far (or zero if this is the first vertex). For efficiency the polygon is not checked for planarity, the caller should ensure that all vertices are coplanar.
Definition at line 80 of file Polygon3.cpp.
void addVertex | ( | Vector3 const & | p, |
intx | index | ||
) |
Add an indexed vertex to the polygon.
The vertex is inserted at the end of the current sequence of vertices. For efficiency the polygon is not checked for planarity, the caller should ensure that all vertices are coplanar.
Definition at line 86 of file Polygon3.cpp.
void clear | ( | ) |
Delete all vertices from the polygon.
Definition at line 72 of file Polygon3.cpp.
Real computeArea | ( | ) | const |
Compute the area of the polygon.
Definition at line 139 of file Polygon3.hpp.
|
static |
Compute the area of an arbitrary polygon (does not require explicit creation of a Polygon3).
Definition at line 142 of file Polygon3.hpp.
Vector3 computeNormal | ( | ) | const |
Compute the unit normal of the polygon.
Definition at line 173 of file Polygon3.hpp.
|
static |
Compute the unit normal of an arbitrary polygon (does not require explicit creation of a Polygon3).
Returns the zero vector if the polygon is degenerate or too small. PointTraitsN<T, 3> must be defined for the value_type T of the iterator.
Definition at line 180 of file Polygon3.hpp.
AxisAlignedBox3 const& getBounds | ( | ) |
Get the bounding box of the polygon.
Polygon3::IndexedVertex const & getVertex | ( | intx | poly_index | ) | const |
Get the vertex at position poly_index in the sequence of vertices around the polygon boundary.
Definition at line 102 of file Polygon3.cpp.
intx numVertices | ( | ) | const |
Get the number of vertices in the polygon.
Definition at line 96 of file Polygon3.cpp.
Triangulate the polygon and return the set of triangle indices (in successive groups of 3).
All prior data in the supplied array are cleared.
Definition at line 179 of file Polygon3.cpp.
|
static |
Utility function to split a (possibly non-convex) quadrilateral into a pair of triangles with the same winding direction.
The quadrilateral is assumed to be planar. This function guarantees that if two triangles are returned (the non-degenerate case), then (a) the shared diagonal of the parent quad will be the first and third vertices of each triangle (but in opposite orders to preserve orientation), and (b) the vertices of the first triangle will be consecutive vertices of the quad. In other words, the vertices of the original quad, starting at some vertex (not necessarily p0) and in the same winding order, can be recovered as i0, j0, k0, j1. Note that the generic triangulate() does not have any such guarantee.
p0 | Position of the first vertex of the quadrilateral. |
p1 | Position of the second vertex of the quadrilateral. |
p2 | Position of the third vertex of the quadrilateral. |
p3 | Position of the fourth vertex of the quadrilateral. |
i0 | Used to return the index of the first vertex of the first triangle. |
j0 | Used to return the index of the second vertex of the first triangle. This vertex is guaranteed to not be part of the second triangle. |
k0 | Used to return the index of the third vertex of the first triangle. |
i1 | Used to return the index of the first vertex of the second triangle. |
j1 | Used to return the index of the second vertex of the second triangle. This vertex is guaranteed to not be part of the first triangle. |
k1 | Used to return the index of the third vertex of the second triangle. |
epsilon | A tolerance threshold for checking degeneracy, negative for a default value. |
Definition at line 245 of file Polygon3.hpp.