Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Triangulation Class Reference

Detailed Description

Triangular surface.

A triangulation consists of a collection of vertices (accessible in constant time) and connectivity information stored in classes Edge and Face, which use vertex indices as references. Triangulations in GTS format can be read with correct normal vector orientation, according to the convention used in GTS.

Vertex normals are computed on initialization by averaging the face normals of adjacent triangles. Face fold angles (angle between face normals) can be computed with edgeTransAngle(), the solid angle at a vertex (between all adjacent faces) with solidAngle().

See Also
TriMesh, CgMesh

#include <triangulation.h>

Inheritance diagram for Triangulation:
Collaboration diagram for Triangulation:

Public Member Functions

 Triangulation ()
 empty construction
 Triangulation (const Triangulation &tg)
 copy construction: change triangulation pointers in faces
virtual ~Triangulation ()
 virtual destructor
vertex_iterator vertex_begin () const
 iterator access
vertex_iterator vertex_end () const
 iterator access
face_iterator face_begin () const
 iterator access
face_iterator face_end () const
 iterator access
face_iterator nb_face_begin (uint i) const
 iterator to list of face which share vertex i
face_iterator nb_face_end (uint i) const
 iterator to list of face which share vertex i
edge_iterator edge_begin () const
 iterator access
edge_iterator edge_end () const
 iterator access
edge_iterator nb_edge_begin (uint i) const
 iterator to list of edges which share vertex i
edge_iterator nb_edge_end (uint i) const
 iterator to list of edges which share vertex i
uint degree (uint i) const
 number of edges connected to vertex i
void apply ()
 transform vertices
uint nvertices () const
uint nedges () const
uint nfaces () const
const Vct3vertex (uint i) const
 const access
Vct3vertex (uint i)
 mutable access
const PointList< 3 > & vertices () const
 return reference to vertex list
PointList< 3 > & vertices ()
 return reference to vertex list
const Vct3normal (uint i) const
 const access
Vct3normal (uint i)
 mutable access
const PointList< 3 > & normals () const
 return reference to normal list
std::set< uint > nbVertices (uint idx) const
 return neighbour vertices More...
FaceList nbFaces (uint idx) const
 access face map More...
std::set< FacenbFaces (const Edge &e) const
 access face map
const EdgeList & nbEdges (uint idx) const
 access edge map More...
virtual Real solidAngle (uint idx) const
 compute solid angle at vertex idx
Real ridgeCriterion (const Edge &e) const
 compute ridge/valley criterion. More...
Vct3 barycenter (uint i) const
 area center of face neighborhood of vertex i
Real vertexArea (uint i) const
 compute area (of the dual mesh cell) assigned to this vertex
Real edgeAngleTrans (const Edge &e) const
 compute angle between faces containing e
Real edgeAngleLong (const Edge &e) const
 compute angle between edge end vertices
bool onBoundary (const Edge &e) const
 determine if e is on a surface boundary
void triangulate (const PointGrid< 3 > &pg)
 triangulate point matrix
void merge (const Triangulation &tg)
 eat other surface (cleanup yourself)
uint nearest (const Vct3 &p, int pos=-1) const
 find vertex index closest to p (consider hint argument)
Indices nearest (const PointList< 3 > &pts) const
 determine closest vertex for each of the points in pts
BndBox bbox () const
 determine bounding box
uint addVertex (const Vct3 &v)
 add vertex to list, return its index
uint addNormal (const Vct3 &nm)
 add (externally computed) normal vector
void addFace (const Face &f)
 add a new face to triangulation (vertices must exist)
void insertFace (const Face &f)
 insert face in suitable place and update connectivity
void rebuildEdgeList ()
 recreate edge list
void updateNeighbours ()
 update neighbourhood lists
virtual void recompNormals ()
 recompute normal vectors only
void fixate ()
 after adding all faces, recompute neighbours, normals, etc.
std::ostream & check (std::ostream &os) const
 check consistency
void cleanup (Real threshold=gmepsilon, bool bonly=false)
 Remove duplicate vertices. More...
void relax (uint ni)
 geometric relaxation - smoothes out sharp edges
virtual void splitEdge (const Edge &e, bool ipol=true)
 split single edge, add new vertex and normal
virtual void collapseEdge (const Edge &e)
 collapse single edge, delete neighbor faces
Vector intersectingEdges (const Plane &pln, EdgeList &el) const
 find edges which intersect plane and corresponding parameters
Real area () const
 compute total area (sum of face areas)
Real volume () const
 compute the enclosed volume (for manifolds)
Real shortestEdgeLength () const
 return length of shortest edge
Real estimCurvature (uint i, const Vct3 &s) const
 simple estimation of curvature in direction s
void reverse ()
 reverse normal direction of all faces
SpMatrix gradient (uint i) const
 compute gradient matrix using angular averaging
Vct3 gradient (uint i, const Vector &x) const
 evaluate gradient of scalar surface field at i
virtual std::istream & readGTS (std::istream &is)
 read a GTS surface
std::ostream & writeGTS (std::ostream &os) const
 write GTS-compatible output
virtual std::ostream & writeOogl (std::ostream &os) const
 write visualization
virtual std::ostream & writeSTL (std::ostream &os) const
 write STL representation
virtual std::ostream & writeTec (std::ostream &os) const
 write tecplot triangulation
virtual std::ostream & writeObj (std::ostream &os) const
 write in OBJ format (Alias wavefront)
void writeBin (std::ostream &os) const
 write to binary stream
void readBin (std::istream &is)
 read from binary stream
virtual XmlElement toXml () const
 create XML representation
virtual void fromXml (const XmlElement &xe)
 create from XML representation
void clear ()
 delete all vertices and faces
Real megabytes () const
 compute memory requirements
- Public Member Functions inherited from RFrame
 RFrame ()
 default construction
virtual ~RFrame ()
 virtual destructor
void clear ()
 apply should finally call this method to clear transformation matrix
Vct3 getOrigin () const
 return the position of the current frame relative to global origin
void translate (const Vct3 &v)
 move reference frame by translation vector
void translate (Real dx, Real dy, Real dz)
 move reference by (dx,dy,dz)
void rotate (Real betax, Real betay, Real betaz)
 rotate by (betax, bety, betaz) around origin axis
void rotate (const Vct3 &rotax, Real angle)
 rotate by angle around axis
void scale (Real xf, Real yf, Real zf)
 scales in three dimensions by the factors given
void scale (Real f)
 scale in all directions
void mirror (const Vct3 &normal)
 mirror about plane - parameter is mirror plane normal
const SMatrix< 4, 4 > & trafoMatrix () const
 return transformation matrix
void setTrafoMatrix (const SMatrix< 4, 4 > &m)
 set transformation matrix
Vct3 forward (const Vct3 &a) const
 coordinate-transform vector
void forward (const PointList< 4 > &a, PointList< 4 > &b) const
 coordinate-transform vector backwards

Protected Member Functions

bool invalidFace (const Face &f) const
 validity predicate for faces
bool invalidEdge (const Edge &e) const
 validity predicate for edges
void unify (Real threshold, bool bonly)
 make vertex list unique
virtual void rename (const Indices &idx)
 rename indices
void removeFace (const Face &f)
 erase face from lists
void removeEdge (const Edge &e)
 erase edge from lists

Protected Attributes

PointList< 3 > vtx
 collection of vertices and normals
FaceList faces
 compatible faces
EdgeList edges
 polyheder edges
EdgeMap v2e
 maps vertex indices to edges
FaceMap v2f
 maps vertex indices to faces
CrossMap e2f
 maps edges to faces
- Protected Attributes inherited from RFrame
SMatrix< 4, 4 > mat
 transformation matrix


class Edge
class Face

Member Function Documentation

void Triangulation::cleanup ( Real  threshold = gmepsilon,
bool  bonly = false 

Remove duplicate vertices.

Check face validity, rebuild edge list and connectivity. Does only process identical vertices (i.e. where distance < threshold) not connected by an edge.

const EdgeList & Triangulation::nbEdges ( uint  idx) const

access edge map

find edges which contain vertex idx

FaceList Triangulation::nbFaces ( uint  idx) const

access face map

find faces which contain vertex idx

set< uint > Triangulation::nbVertices ( uint  idx) const

return neighbour vertices

find neighbour vertices

Real Triangulation::ridgeCriterion ( const Edge e) const

compute ridge/valley criterion.

Returns the angle between normals of the two faces meeting at e, signed positive if the edge is a 'ridge', i.e. its center lies above the CoG of the neighbor faces, and negative in the opposite case.

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