PolyTriangulate Class Reference

#include <c4d_baseobject.h>

Detailed Description

Polygon triangulation class.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Public Member Functions

Bool Triangulate (const Vector *pvPoints, Int32 lPointCount, const Int32 *plSegments, Int32 lSegCnt, CPolygon *&pPolys, Int32 &lPolyCount, Int32 lFlags=0, const Int32 *plMap=nullptr, BaseThread *pThread=nullptr, Int32 lConstraints=0, const Int32 *plConstrainedEdges=nullptr)
 
Bool TriangulateRelease (const Vector *pvPoints, Int32 lPointCount, const Int32 *plSegments, Int32 lSegCnt, CPolygon *&pPolys, Int32 &lPolyCount, Int32 lFlags=0, const Int32 *plMap=nullptr, BaseThread *pThread=nullptr, Int32 lConstraints=0, const Int32 *plConstrainedEdges=nullptr)
 
Bool HasIdentical ()
 
void SetPolygonMatrix (Matrix64 *m)
 
UInt32 GetState ()
 

Private Member Functions

 PolyTriangulate ()
 
 ~PolyTriangulate ()
 

Alloc/Free

static PolyTriangulateAlloc ()
 
static void Free (PolyTriangulate *&pTriang)
 

Constructor & Destructor Documentation

◆ PolyTriangulate()

PolyTriangulate ( )
private

◆ ~PolyTriangulate()

~PolyTriangulate ( )
private

Member Function Documentation

◆ Alloc()

static PolyTriangulate* Alloc ( )
static

Allocates a poly triangulate. Destroy the allocated poly triangulate with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated poly triangulate, or nullptr if the allocation failed.

◆ Free()

static void Free ( PolyTriangulate *&  pTriang)
static

Destructs poly triangulates allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]pTriangThe poly triangulate to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Triangulate()

Bool Triangulate ( const Vector pvPoints,
Int32  lPointCount,
const Int32 plSegments,
Int32  lSegCnt,
CPolygon *&  pPolys,
Int32 lPolyCount,
Int32  lFlags = 0,
const Int32 plMap = nullptr,
BaseThread pThread = nullptr,
Int32  lConstraints = 0,
const Int32 plConstrainedEdges = nullptr 
)

Triangulates the points in pvPoints and returns the result in pPolys. The allocated array is freed on the next call to Triangulate() or when the PolyTriangulate instance is freed.

Warning
Do not store pPolys for later use. It will get invalid after the next Triangulate() call or when the class instance is destroyed.
Note
Use TriangulateRelease() to store pPolys for a later use.
Parameters
[in]pvPointsThe points to triangulate. The caller owns the pointed points array.
[in]lPointCountThe number of points in pvPoints array.
[in]plSegmentsThe segments array, or nullptr. The number of segment points is stored in each element. The caller owns the pointed segments array.
[in]lSegCntThe number of segments in plSegments array.
[out]pPolysAssigned a pointer to the triangulated polygons array.
[out]lPolyCountAssigned the number of triangulated polygons in pPolys.
[in]lFlagsThe triangulation flags: POLY_TRIANG
[in]plMapAn optional point map. The caller owns the pointed point map.
plMap allows to choose which vertices should be used in the triangulation.
Imagine a vector array with 100 elements; to triangulate the points 10, 20, 30, 40 and 50, lPointCount would be 5 and plMap = { 10, 20, 30, 40, 50 }.
[in]pThreadA thread for the operation. The caller owns the pointed thread.
[in]lConstraintsReserved for future use.
[in]plConstrainedEdgesReserved for future use.
Returns
true if triangulation was successful, otherwise false.

◆ TriangulateRelease()

Bool TriangulateRelease ( const Vector pvPoints,
Int32  lPointCount,
const Int32 plSegments,
Int32  lSegCnt,
CPolygon *&  pPolys,
Int32 lPolyCount,
Int32  lFlags = 0,
const Int32 plMap = nullptr,
BaseThread pThread = nullptr,
Int32  lConstraints = 0,
const Int32 plConstrainedEdges = nullptr 
)

Triangulates the points in pvPoints and returns the result in pPolys.
Same as Triangulate(), except that the memory is not freed by the PolyTriangulate instance.

Warning
The returned array pPolys needs to be freed with DeleteMem() afterwards.
Parameters
[in]pvPointsThe points to triangulate. The caller owns the pointed points array.
[in]lPointCountThe number of points in pvPoints array.
[in]plSegmentsThe segments array, or nullptr. The number of segment points is stored in each element. The caller owns the pointed segments array.
[in]lSegCntThe number of segments in plSegments array.
[out]pPolysAssigned a pointer to the triangulated polygons array.
[out]lPolyCountAssigned the number of triangulated polygons in pPolys.
[in]lFlagsThe triangulation flags: POLY_TRIANG
[in]plMapAn optional point map. The caller owns the pointed point map.
plMap allows to choose which vertices should be used in the triangulation.
Imagine a vector array with 100 elements; to triangulate the points 10, 20, 30, 40 and 50, lPointCount would be 5 and plMap = { 10, 20, 30, 40, 50 }.
[in]pThreadA thread for the operation. The caller owns the pointed thread.
[in]lConstraintsReserved for future use.
[in]plConstrainedEdgesReserved for future use.
Returns
true if triangulation was successful, otherwise false.

◆ HasIdentical()

Bool HasIdentical ( )

Checks if there were any identical points in the triangulation, i.e. points with a distance less than 0.0001.

Returns
true if there were identical points, otherwise false.

◆ SetPolygonMatrix()

void SetPolygonMatrix ( Matrix64 m)

Sets the matrix for the triangulation.
The triangulation usually calculates the normal of the points set and projects the points into a plane that is described by this normal and the point (0, 0, 0).
To speed up the triangulation use this if the matrix is already calculated.
The vector in m->v3 must be the polygon normal. All vectors must be perpendicular to each other.

Parameters
[in]mThe polygon matrix to use, or nullptr to enable automatic calculation of the polygon normal again.
The pointed matrix must be valid as long as calls to the triangulate methods are made, or until a new matrix or nullptr is set.
The caller owns the pointed matrix.

◆ GetState()

UInt32 GetState ( )

Gets the state of the triangulation engine.

Returns
The error state flags: TRIANGSTATE