Home Hierarchy Members Alphabetical Related Pages

Triangulator Class Template Reference

#include <triangulator.h>

List of all members.

Public Types

typedef P PointType
typedef std::list< Face
>::const_iterator 
face_const_iterator

Public Member Functions

template<class T>
 Triangulator (T first, const T &last)
void process () throw (std::runtime_error)
unsigned int faces_size () const
face_const_iterator faces_begin () const
face_const_iterator faces_end () const

Protected Member Functions

bool snip (const int u, const int v, const int w, const int nv)
int nbPoints () const
const PointTypepoint (const int i) const
void addFace (const int u, const int v, const int w)

Static Protected Member Functions

static bool isInTriangle (const PointType &A, const PointType &B, const PointType &C, const PointType &M)

Classes

class  Face


Detailed Description

template<class P>
class Triangulator< P >

A very useful class to triangulate a sequence a of point forming a simple polygon (without holes).

The code is fully templated which means it can be used with any type of point and any type of sequence.

Here is an exemple of use, where Vec2 is a trivial 2D point type:

 list<Vec2> polygon;
 
 polygon.push_back(Vec2(0.0f,0.0f));
 polygon.push_back(Vec2(1.0f,0.0f));
 polygon.push_back(Vec2(1.0f,1.0f));
 polygon.push_back(Vec2(0.0f,1.0f));
 
 Triangulator<Vec2> triangulator(polygon.begin(),polygon.end());
 triangulator.process();
 for (Triangulator<Vec2>::face_const_iterator fter = triangulator.faces_begin();
 fter != triangulator.faces_end();++fter)
 {
   cout<<"face joining\n"
       <<"  "<<*(fter->vertex(0))
       <<"  "<<*(fter->vertex(1))<<endl;
 }


Member Typedef Documentation

typedef P PointType

typedef std::list<Face>::const_iterator face_const_iterator


Constructor & Destructor Documentation

Triangulator ( first,
const T &  last 
) [inline]


Member Function Documentation

void process (  )  throw (std::runtime_error) [inline]

unsigned int faces_size (  )  const [inline]

Triangulator< P >::face_const_iterator faces_begin (  )  const [inline]

Triangulator< P >::face_const_iterator faces_end (  )  const [inline]

static bool isInTriangle ( const PointType A,
const PointType B,
const PointType C,
const PointType M 
) [inline, static, protected]

bool snip ( const int  u,
const int  v,
const int  w,
const int  nv 
) [inline, protected]

int nbPoints (  )  const [inline, protected]

const P & point ( const int  i  )  const [inline, protected]

void addFace ( const int  u,
const int  v,
const int  w 
) [inline, protected]


Generated on 5 Jan 2007 with doxygen version 1.5.1. Valid HTML 4.0! Valid CSS!