Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ACG::Triangulator Class Reference

Classes

struct  RingVertex
 

Public Member Functions

 Triangulator (const std::vector< Vec3f > &_pos)
 Execute the triangulation algorithm on a polygon. More...
 
virtual ~Triangulator ()
 Destructor.
 
int numTriangles () const
 Get number of triangles. More...
 
int index (int _i) const
 Get local vertex index. More...
 
const std::vector< int > & indices () const
 Get local index buffer. More...
 
bool convex () const
 Is the polygon convex? More...
 
int numReflexVertices () const
 Get number of reflex vertices. More...
 
bool isReflexVertex (int _i) const
 Check if a vertex is reflex. More...
 
bool success () const
 Check if the triangulation was successful. More...
 

Private Member Functions

void initVertexList ()
 
int earClippingN2 ()
 
int earClippingN3 ()
 
Triangulatoroperator= (const Triangulator &)
 
float triangleAreaSign (const Vec2f &v0, const Vec2f &v1, const Vec2f &v2) const
 
float distancePointToSegmentSq (const Vec2f &v0, const Vec2f &v1, const Vec2f &pt) const
 
bool isReflexVertex (const Vec2f &v0, const Vec2f &v1, const Vec2f &v2) const
 
bool pointInTriangle (const Vec2f &v0, const Vec2f &v1, const Vec2f &v2, const Vec2f &pt) const
 
bool updateReflexVertex (RingVertex *v)
 
void addEar (RingVertex *_earTip)
 

Private Attributes

const int polySize_
 
int numRemaningVertices_
 
int numTris_
 
int numReflexVertices_
 
int status_
 
bool convex_
 
std::vector< Vec2fpos_
 
std::vector< RingVertexvertices_
 
std::list< RingVertex * > reflexVertices_
 
std::vector< int > tris_
 

Detailed Description

Definition at line 67 of file Triangulator.hh.

Constructor & Destructor Documentation

ACG::Triangulator::Triangulator ( const std::vector< Vec3f > &  _pos)

Execute the triangulation algorithm on a polygon.

Parameters
_pospolygon vertex positions (ccw)

Definition at line 61 of file Triangulator.cc.

Member Function Documentation

bool ACG::Triangulator::convex ( ) const
inline

Is the polygon convex?

Returns
convex true or false

Definition at line 102 of file Triangulator.hh.

int ACG::Triangulator::index ( int  _i) const
inline

Get local vertex index.

Parameters
_iindex to index buffer in range [0, .., numTris*3 - 1]
Returns
vertex index in range [0, .., _pos.size()-1], where _pos is the input vector of positions as passed to the constructor

Definition at line 90 of file Triangulator.hh.

const std::vector<int>& ACG::Triangulator::indices ( ) const
inline

Get local index buffer.

Returns
index buffer

Definition at line 96 of file Triangulator.hh.

bool ACG::Triangulator::isReflexVertex ( int  _i) const

Check if a vertex is reflex.

A reflex vertex is a vertex with an inner angle larger than 180 deg.

Parameters
_ilocal vertex index in range [0, .., _pos.size()-1]
Returns
reflex vertex true or false

Definition at line 197 of file Triangulator.cc.

int ACG::Triangulator::numReflexVertices ( ) const
inline

Get number of reflex vertices.

A reflex vertex is a vertex with an inner angle larger than 180 deg.

Returns
number of reflex vertices

Definition at line 109 of file Triangulator.hh.

int ACG::Triangulator::numTriangles ( ) const
inline

Get number of triangles.

Returns
number of triangles after triangulation

Definition at line 83 of file Triangulator.hh.

bool ACG::Triangulator::success ( ) const
inline

Check if the triangulation was successful.

Returns
success true or false

Definition at line 123 of file Triangulator.hh.


The documentation for this class was generated from the following files: