VR-Forces 5.0.3 Developer's Guide
 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. 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.

Static Public Member Functions

static bool triangulateTerrain (DtTerrainDatabase *db)
 
static DtTriangulationResult triangulatePolygon (DtTerrainDatabase *db, DtPolygonIndirect *node, DtGroup *const parent)
 

Static Protected Member Functions

static double kross (const DtVertexManager *mgr, int a, int b, int c)
 
static bool collinear (const DtVertexManager *mgr, int a, int b, int c)
 
static bool segmentInCone (const DtVertexManager *mgr, int v0, int v1, int vm, int vp)
 
static bool between (const DtVertexManager *mgr, int a, int b, int c)
 
static bool properIntersect (const DtVertexManager *mgr, int a, int b, int c, int d)
 
static bool intersect (const DtVertexManager *mgr, int a, int b, int c, int d)
 
static bool isDiagonal (const DtVertexManager *mgr, int numberOfVertices, std::vector< DtVertexID > &vertIds, int i0, int i1)
 
static bool isValidPoly (const DtPolygonIndirect *poly)
 
static bool isFlatSurface (const DtPolygonIndirect *poly)
 
static void printVerts (std::vector< DtVertexID > lst)
 
static void triangulatePolygon (DtTerrainDatabase *db, DtSurfaceID sid, const DtVertexManager *mgr, DtGroup *const parent, std::vector< DtVertexID > &vertIds)
 
static bool alignPolygonToXYPlane (DtPolygonIndirect *poly, DtHomogeneousTransformMatrix &aMatrix)
 
static void transformPolygon (DtPolygonIndirect *poly, DtHomogeneousTransformMatrix &aMatrix)
 

Static Protected Attributes

static const double theErrorMargin
 

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 Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)