VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes
DtTriangulator Class Reference

Triangulates all the polygons with more than three vertices of a gdb terrain database. More...

Static Public Member Functions

static bool triangulateTerrain (DtTerrainDatabase *db)
 Converts all the polygon indirect nodes of db into triangle indirect nodes by applying a triangulation algorithm to each polygon node.
static DtTriangulationResult triangulatePolygon (DtTerrainDatabase *db, DtPolygonIndirect *node, DtGroup *const parent)
 Triangulates the polygon defined by node.

Static Protected Member Functions

static double kross (const DtVertexManager *mgr, int a, int b, int c)
 Returns the value of the z component of the cross product between the segments defined by the indexes ab and ac.
static bool collinear (const DtVertexManager *mgr, int a, int b, int c)
 Determines whether the points at indexes a, b, and c are all collinear.
static bool segmentInCone (const DtVertexManager *mgr, int v0, int v1, int vm, int vp)
 Checks whether the segment v0v1 is contained in the cone with vertex v0 and edges with directions (vm - vi) and (vp - vi)
static bool between (const DtVertexManager *mgr, int a, int b, int c)
 Determines whether the point vb is between va and vc.
static bool properIntersect (const DtVertexManager *mgr, int a, int b, int c, int d)
 Checks whether the segment va-vb properly intersects the segment vc-vd: They share a point interior to both segments.
static bool intersect (const DtVertexManager *mgr, int a, int b, int c, int d)
 Checks whether the segment va-vb intersects with segment vc-vd: They intersect properly or one endpoint of one segment lies between the two endpoints of the other segment.
static bool isDiagonal (const DtVertexManager *mgr, int numberOfVertices, std::vector< DtVertexID > &vertIds, int i0, int i1)
 Determines whether the segment defined by vi0 and vi1 is contained by the polygon vertIDs and does not fully intersect any of its edges.
static bool isValidPoly (const DtPolygonIndirect *poly)
 Determines whether poly has a non-zero normal.
static bool isFlatSurface (const DtPolygonIndirect *poly)
 Determines whether all the vertices inside poly are coplanar.
static void printVerts (std::vector< DtVertexID > lst)
 Prints the contents of the list lst.
static void triangulatePolygon (DtTerrainDatabase *db, DtSurfaceID sid, const DtVertexManager *mgr, DtGroup *const parent, std::vector< DtVertexID > &vertIds)
 Triangulates the polygon defined by vertIds.
static bool alignPolygonToXYPlane (DtPolygonIndirect *poly, DtHomogeneousTransformMatrix &aMatrix)
 Projects the polygon poly onto the xy plane by aligning its normal with the z axis.
static void transformPolygon (DtPolygonIndirect *poly, DtHomogeneousTransformMatrix &aMatrix)
 Applies the transformation aMatrix to the polygon node poly.

Static Protected Attributes

static const double theErrorMargin

Detailed Description

Triangulates all the polygons with more than three vertices of a gdb terrain database.

The algorithmic used in this class is based on the theory presented in Computational Geometry in C (Joseph O'Rourke) - Chapter 1 Geometric Tools for Computer Graphics (Schneider) - Section 13.9 Computer Graphics (Foley & Van Dam) - p. 222 Notation: vi = vertex located at position i inside the vertex manager

Member Function Documentation

static bool DtTriangulator::triangulateTerrain ( DtTerrainDatabase db)
static

Converts all the polygon indirect nodes of db into triangle indirect nodes by applying a triangulation algorithm to each polygon node.

The polygon node is removed from the database and transformed into 2+ triangle indirect nodes.

Parameters
db- Terrain database to be triangulated
static DtTriangulationResult DtTriangulator::triangulatePolygon ( DtTerrainDatabase db,
DtPolygonIndirect node,
DtGroup *const  parent 
)
static

Triangulates the polygon defined by node.

It creates an exact copy of the polygon but with triangles. This method creates and adds TRIANGLE_INDIRECT nodes into the terrain database. Each triangle is created with the surface Id sid.

Parameters
db- (in) Terrain database where the nodes will be added
node- (in) Polygon to be triangulated parent - (in) Parent of the node
Returns
DtPolygonTye indicating whether the polygon was successfully triangulated or not
static double DtTriangulator::kross ( const DtVertexManager mgr,
int  a,
int  b,
int  c 
)
staticprotected

Returns the value of the z component of the cross product between the segments defined by the indexes ab and ac.

Parameters
mgr- (in) Vertex manager containing the actual vertices
a,b,c- (in) Indexes of the vertices inside mgr, defining the segment
Returns
(abxac).z()
static bool DtTriangulator::collinear ( const DtVertexManager mgr,
int  a,
int  b,
int  c 
)
staticprotected

Determines whether the points at indexes a, b, and c are all collinear.

Parameters
mgr- (in) Vertex manager containing the actual vertices
a,b,c- (in) Indexes of the vertices inside the vertex manager
Returns
True if va, vb, and vc are collinear. False otherwise.
static bool DtTriangulator::segmentInCone ( const DtVertexManager mgr,
int  v0,
int  v1,
int  vm,
int  vp 
)
staticprotected

Checks whether the segment v0v1 is contained in the cone with vertex v0 and edges with directions (vm - vi) and (vp - vi)

Parameters
mgr- (in) Vertex manager containing the actual vertices
v0,v1- (in) Indexes of the segment
vm- (in) Index of the vertex located immediately before v0
vp- (in) Index of the vertex located immediately after v0
Returns
True if the segment vov1 is within the cone.
static bool DtTriangulator::between ( const DtVertexManager mgr,
int  a,
int  b,
int  c 
)
staticprotected

Determines whether the point vb is between va and vc.

Parameters
mgr- (in) Vertex manager containing the actual vertices
a,b,c- (in) Indexes of the vertices to be tested for collinearity
Returns
False if the vertices are not collinear or if vb is not between va and vc.
static bool DtTriangulator::properIntersect ( const DtVertexManager mgr,
int  a,
int  b,
int  c,
int  d 
)
staticprotected

Checks whether the segment va-vb properly intersects the segment vc-vd: They share a point interior to both segments.

Parameters
mgr- (in) Vertex manager containing the actual vertices
a,b,c,d- (in) Indexes of the vertices defining the segments to be tested
Returns
True if there is proper intersection between the segments.
static bool DtTriangulator::intersect ( const DtVertexManager mgr,
int  a,
int  b,
int  c,
int  d 
)
staticprotected

Checks whether the segment va-vb intersects with segment vc-vd: They intersect properly or one endpoint of one segment lies between the two endpoints of the other segment.

Parameters
mgr- (in) Vertex manager containing the actual vertices
a,b,c,d- (in) Indexes of the vertices defining the segments to be tested
Returns
True if there
static bool DtTriangulator::isDiagonal ( const DtVertexManager mgr,
int  numberOfVertices,
std::vector< DtVertexID > &  vertIds,
int  i0,
int  i1 
)
staticprotected

Determines whether the segment defined by vi0 and vi1 is contained by the polygon vertIDs and does not fully intersect any of its edges.

Parameters
mgr- (in) Vertex manager containing the actual vertices
numberOfVertices- (in) Size of vertIds
i0,i1- (in) Indexes of the vertices defining the segment to be tested
static bool DtTriangulator::isValidPoly ( const DtPolygonIndirect poly)
staticprotected

Determines whether poly has a non-zero normal.

Parameters
poly- (in) Polygon to be tested
Returns
True if poly has a non zero normal.
static bool DtTriangulator::isFlatSurface ( const DtPolygonIndirect poly)
staticprotected

Determines whether all the vertices inside poly are coplanar.

Parameters
poly- (in) Polygon to be tested
Returns
True if all the vertices of the polygon are on the same plane.
static void DtTriangulator::printVerts ( std::vector< DtVertexID lst)
staticprotected

Prints the contents of the list lst.

Parameters
lst- (in) List of vertices to be printed
static void DtTriangulator::triangulatePolygon ( DtTerrainDatabase db,
DtSurfaceID  sid,
const DtVertexManager mgr,
DtGroup *const  parent,
std::vector< DtVertexID > &  vertIds 
)
staticprotected

Triangulates the polygon defined by vertIds.

It creates an exact copy of the polygon but with triangles. This method creates and adds TRIANGLE_INDIRECT nodes into the terrain database. Each triangle is created with the surface Id sid.

Parameters
db- (in) Terrain database where the nodes will be added
sid- (in) Surface id of the new nodes
mgr- (in) Vertex manager containing the actual vertices
vertIds- (in) Vector containing the indexes that define the
parent- (in) Parent associated with the polygon being triangulated polygon to be triangulated
static bool DtTriangulator::alignPolygonToXYPlane ( DtPolygonIndirect poly,
DtHomogeneousTransformMatrix aMatrix 
)
staticprotected

Projects the polygon poly onto the xy plane by aligning its normal with the z axis.

Parameters
poly- (in) Polygon to align
aMatrix- (out) Transformation matrix used to project the polygon
Returns
True if aMatrix is different from the identity matrix.
static void DtTriangulator::transformPolygon ( DtPolygonIndirect poly,
DtHomogeneousTransformMatrix aMatrix 
)
staticprotected

Applies the transformation aMatrix to the polygon node poly.

Parameters
poly- (in) Polygon to transform
aMatrix- (in) Transformation matrix to apply on the polygon

Member Data Documentation

const double DtTriangulator::theErrorMargin
staticprotected

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

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)