CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
CCCoreLib::Delaunay2dMesh Class Reference

A class to compute and handle a Delaunay 2D mesh on a subset of points. More...

#include <Delaunay2dMesh.h>

Inheritance diagram for CCCoreLib::Delaunay2dMesh:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::Delaunay2dMesh:
Collaboration graph
[legend]

Public Member Functions

 Delaunay2dMesh ()
 Delaunay2dMesh constructor.
 
 ~Delaunay2dMesh () override
 Delaunay2dMesh destructor.
 
virtual void linkMeshWith (GenericIndexedCloud *aCloud, bool passOwnership=false)
 Associate this mesh to a point cloud. More...
 
virtual bool buildMesh (const std::vector< CCVector2 > &points2D, std::size_t pointCountToUse, std::string &outputErrorStr)
 Build the Delaunay mesh on top a set of 2D points. More...
 
virtual bool buildMesh (const std::vector< CCVector2 > &points2D, const std::vector< int > &segments2D, std::string &outputErrorStr)
 Build the Delaunay mesh from a set of 2D polylines. More...
 
virtual bool removeOuterTriangles (const std::vector< CCVector2 > &vertices2D, const std::vector< CCVector2 > &polygon2D, bool removeOutside=true)
 Removes the triangles falling outside of a given (2D) polygon. More...
 
unsigned size () const override
 Returns the number of triangles. More...
 
void forEach (genericTriangleAction action) override
 Fast iteration mechanism. More...
 
void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax) override
 Returns the mesh bounding-box. More...
 
void placeIteratorAtBeginning () override
 Places the mesh iterator at the beginning. More...
 
GenericTriangle_getNextTriangle () override
 Returns the next triangle (relatively to the global iterator position) More...
 
GenericTriangle_getTriangle (unsigned triangleIndex) override
 Returns the ith triangle. More...
 
VerticesIndexesgetNextTriangleVertIndexes () override
 Returns the indexes of the vertices of the next triangle (relatively to the global iterator position) More...
 
VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex) override
 Returns the indexes of the vertices of a given triangle. More...
 
void getTriangleVertices (unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const override
 Returns the vertices of a given triangle. More...
 
int * getTriangleVertIndexesArray ()
 Returns triangles indexes array (pointer to) More...
 
bool removeTrianglesWithEdgesLongerThan (PointCoordinateType maxEdgeLength)
 Filters out the triangles based on their edge length. More...
 
GenericIndexedCloudgetAssociatedCloud ()
 Returns associated cloud.
 
- Public Member Functions inherited from CCCoreLib::GenericIndexedMesh
 ~GenericIndexedMesh () override=default
 Default destructor.
 
virtual GenericTriangle_getTriangle (unsigned triangleIndex)=0
 Returns the ith triangle. More...
 
virtual VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex)=0
 Returns the indexes of the vertices of a given triangle. More...
 
virtual void getTriangleVertices (unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const =0
 Returns the vertices of a given triangle. More...
 
virtual VerticesIndexesgetNextTriangleVertIndexes ()=0
 Returns the indexes of the vertices of the next triangle (relatively to the global iterator position) More...
 
virtual bool normalsAvailable () const
 Returns whether normals are available. More...
 
virtual bool interpolateNormals (unsigned triIndex, const CCVector3 &P, CCVector3 &N)
 Interpolates normal(s) inside a given triangle. More...
 
- Public Member Functions inherited from CCCoreLib::GenericMesh
virtual ~GenericMesh ()=default
 Default destructor.
 
virtual unsigned size () const =0
 Returns the number of triangles. More...
 
virtual void forEach (genericTriangleAction action)=0
 Fast iteration mechanism. More...
 
virtual void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax)=0
 Returns the mesh bounding-box. More...
 
virtual void placeIteratorAtBeginning ()=0
 Places the mesh iterator at the beginning. More...
 
virtual GenericTriangle_getNextTriangle ()=0
 Returns the next triangle (relatively to the global iterator position) More...
 

Static Public Member Functions

static bool Available ()
 Returns whether 2D Delaunay triangulation is supported or not. More...
 
static Delaunay2dMeshTesselateContour (const std::vector< CCVector2 > &contourPoints)
 Tesselates a 2D polyline (shortcut to buildMesh and removeOuterTriangles)
 
static Delaunay2dMeshTesselateContour (GenericIndexedCloudPersist *contourPoints, int flatDimension=-1)
 Tesselates a 2D polyline (not necessarily axis-aligned)
 

Static Public Attributes

static constexpr int USE_ALL_POINTS = 0
 

Protected Attributes

GenericIndexedCloudm_associatedCloud
 Associated point cloud.
 
int * m_triIndexes
 Triangle vertex indexes.
 
int * m_globalIterator
 Iterator on the list of triangle vertex indexes.
 
int * m_globalIteratorEnd
 End position of global iterator.
 
unsigned m_numberOfTriangles
 The number of triangles.
 
bool m_cloudIsOwnedByMesh
 Specifies if the associated cloud should be deleted when the mesh is deleted.
 
SimpleTriangle m_dumpTriangle
 Dump triangle structure to transmit temporary data.
 
VerticesIndexes m_dumpTriangleIndexes
 Dump triangle index structure to transmit temporary data.
 

Additional Inherited Members

- Public Types inherited from CCCoreLib::GenericMesh
using genericTriangleAction = std::function< void(GenericTriangle &)>
 Generic function to apply to a triangle (used by foreach)
 

Detailed Description

A class to compute and handle a Delaunay 2D mesh on a subset of points.

Member Function Documentation

◆ _getNextTriangle()

GenericTriangle * Delaunay2dMesh::_getNextTriangle ( )
overridevirtual

Returns the next triangle (relatively to the global iterator position)

Virtual method to handle the mesh global iterator. Global iterator position should be increased each time this method is called. The returned object can be temporary.

Returns
a triangle

Implements CCCoreLib::GenericMesh.

◆ _getTriangle()

GenericTriangle * Delaunay2dMesh::_getTriangle ( unsigned  triangleIndex)
overridevirtual

Returns the ith triangle.

Virtual method to request a triangle with a specific index. The returned object can be temporary.

Parameters
triangleIndexof the requested triangle (between 0 and the mesh size-1)
Returns
the requested triangle, or 0 if index value is not valid

Implements CCCoreLib::GenericIndexedMesh.

◆ Available()

bool Delaunay2dMesh::Available ( )
static

Returns whether 2D Delaunay triangulation is supported or not.

2D Delaunay triangulation requires the CGAL library.

◆ buildMesh() [1/2]

bool Delaunay2dMesh::buildMesh ( const std::vector< CCVector2 > &  points2D,
const std::vector< int > &  segments2D,
std::string &  outputErrorStr 
)
virtual

Build the Delaunay mesh from a set of 2D polylines.

Parameters
points2Da set of 2D points
segments2Dconstraining segments (as 2 indexes per segment)
outputErrorStrerror string as output by the CGAL lib. (if any)
Returns
success

◆ buildMesh() [2/2]

bool Delaunay2dMesh::buildMesh ( const std::vector< CCVector2 > &  points2D,
std::size_t  pointCountToUse,
std::string &  outputErrorStr 
)
virtual

Build the Delaunay mesh on top a set of 2D points.

Parameters
points2Da set of 2D points
pointCountToUsenumber of points to use from the input set (USE_ALL_POINTS = all)
outputErrorStrerror string as output by the CGAL lib. (if any)
Returns
success

◆ forEach()

void Delaunay2dMesh::forEach ( genericTriangleAction  action)
overridevirtual

Fast iteration mechanism.

Virtual method to apply a function to the whole mesh

Parameters
actionfunction to apply (see GenericMesh::genericTriangleAction)

Implements CCCoreLib::GenericMesh.

◆ getBoundingBox()

void Delaunay2dMesh::getBoundingBox ( CCVector3 bbMin,
CCVector3 bbMax 
)
overridevirtual

Returns the mesh bounding-box.

Virtual method to request the mesh bounding-box limits. It is equivalent to the bounding-box of the cloud composed of the mesh vertexes.

Parameters
bbMinlower bounding-box limits (Xmin,Ymin,Zmin)
bbMaxhigher bounding-box limits (Xmax,Ymax,Zmax)

Implements CCCoreLib::GenericMesh.

◆ getNextTriangleVertIndexes()

VerticesIndexes * Delaunay2dMesh::getNextTriangleVertIndexes ( )
overridevirtual

Returns the indexes of the vertices of the next triangle (relatively to the global iterator position)

Returns
the triangle indexes (or 0 if the global iterator is out of bounds)

Implements CCCoreLib::GenericIndexedMesh.

◆ getTriangleVertices()

void Delaunay2dMesh::getTriangleVertices ( unsigned  triangleIndex,
CCVector3 A,
CCVector3 B,
CCVector3 C 
) const
overridevirtual

Returns the vertices of a given triangle.

Parameters
[in]triangleIndexindex of the triangle (between 0 and the size(mesh)-1)
[out]Afirst vertex
[out]Bsecond vertex
[out]Cthird vertex

Implements CCCoreLib::GenericIndexedMesh.

◆ getTriangleVertIndexes()

VerticesIndexes * Delaunay2dMesh::getTriangleVertIndexes ( unsigned  triangleIndex)
overridevirtual

Returns the indexes of the vertices of a given triangle.

Parameters
triangleIndexindex of the triangle (between 0 and size(mesh)-1)
Returns
the triangle indexes (or 0 if index value is not valid)

Implements CCCoreLib::GenericIndexedMesh.

◆ getTriangleVertIndexesArray()

int * CCCoreLib::Delaunay2dMesh::getTriangleVertIndexesArray ( )
inline

Returns triangles indexes array (pointer to)

Handle with care!

◆ linkMeshWith()

void Delaunay2dMesh::linkMeshWith ( GenericIndexedCloud aCloud,
bool  passOwnership = false 
)
virtual

Associate this mesh to a point cloud.

This particular mesh structure deals with point indexes instead of points. Therefore, it is possible to change the associated point cloud (if the new cloud has the same size). For example, it can be useful to compute the mesh on 2D points corresponding to 3D points that have been projected on a plane and then to link this structure with the 3D original points.

Parameters
aClouda point cloud
passOwnershipif true the Delaunay2dMesh destructor will delete the cloud as well

◆ placeIteratorAtBeginning()

void Delaunay2dMesh::placeIteratorAtBeginning ( )
overridevirtual

Places the mesh iterator at the beginning.

Virtual method to handle the mesh global iterator

Implements CCCoreLib::GenericMesh.

◆ removeOuterTriangles()

bool Delaunay2dMesh::removeOuterTriangles ( const std::vector< CCVector2 > &  vertices2D,
const std::vector< CCVector2 > &  polygon2D,
bool  removeOutside = true 
)
virtual

Removes the triangles falling outside of a given (2D) polygon.

Parameters
vertices2Dvertices of the mesh as 2D points (typically the one used to triangulate the mesh!)
polygon2Dvertices of the 2D boundary polygon (ordered)
removeOutsidewhether to remove triangles outside (default) or inside
Returns
success

◆ removeTrianglesWithEdgesLongerThan()

bool Delaunay2dMesh::removeTrianglesWithEdgesLongerThan ( PointCoordinateType  maxEdgeLength)

Filters out the triangles based on their edge length.

Warning: may remove ALL triangles! Check the resulting size afterwards.

◆ size()

unsigned CCCoreLib::Delaunay2dMesh::size ( ) const
inlineoverridevirtual

Returns the number of triangles.

Virtual method to request the mesh size

Returns
the mesh size

Implements CCCoreLib::GenericMesh.


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