ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::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 cloudViewer::Delaunay2dMesh:
Collaboration diagram for cloudViewer::Delaunay2dMesh:

Public Member Functions

 Delaunay2dMesh ()
 Delaunay2dMesh constructor. More...
 
 ~Delaunay2dMesh () override
 Delaunay2dMesh destructor. More...
 
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...
 
virtual 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
 
VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex) override
 Returns the indexes of the vertices of a given triangle. More...
 
virtual void getTriangleVertices (unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const override
 Returns the vertices of a given triangle. More...
 
virtual void getTriangleVertices (unsigned triangleIndex, double A[3], double B[3], double C[3]) const override
 
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. More...
 
- Public Member Functions inherited from cloudViewer::GenericIndexedMesh
 GenericIndexedMesh ()=default
 
 ~GenericIndexedMesh () override=default
 Default destructor. 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 cloudViewer::GenericMesh
 GenericMesh ()=default
 
virtual ~GenericMesh ()=default
 Default destructor. More...
 
virtual bool hasTriangles () const
 

Static Public Member Functions

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

Static Public Attributes

static constexpr int USE_ALL_POINTS = 0
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from cloudViewer::GenericMesh
enum class  SimplificationContraction { Average , Quadric }
 Indicates the method that is used for mesh simplification if multiple vertices are combined to a single one. More...
 
enum class  FilterScope { All , Color , Normal , Vertex }
 Indicates the scope of filter operations. More...
 
enum class  DeformAsRigidAsPossibleEnergy { Spokes , Smoothed }
 
using genericTriangleAction = std::function< void(GenericTriangle &)>
 Generic function to apply to a triangle (used by foreach) More...
 

Detailed Description

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

Definition at line 24 of file Delaunay2dMesh.h.

Constructor & Destructor Documentation

◆ Delaunay2dMesh()

Delaunay2dMesh::Delaunay2dMesh ( )

Delaunay2dMesh constructor.

Definition at line 30 of file Delaunay2dMesh.cpp.

Referenced by TesselateContour().

◆ ~Delaunay2dMesh()

Delaunay2dMesh::~Delaunay2dMesh ( )
override

Delaunay2dMesh destructor.

Definition at line 38 of file Delaunay2dMesh.cpp.

References linkMeshWith(), and m_triIndexes.

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 cloudViewer::GenericMesh.

Definition at line 324 of file Delaunay2dMesh.cpp.

References cloudViewer::SimpleTriangle::A, cloudViewer::SimpleTriangle::B, cloudViewer::SimpleTriangle::C, cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_dumpTriangle, m_globalIterator, and m_globalIteratorEnd.

◆ _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 cloudViewer::GenericIndexedMesh.

Definition at line 347 of file Delaunay2dMesh.cpp.

References cloudViewer::SimpleTriangle::A, cloudViewer::SimpleTriangle::B, cloudViewer::SimpleTriangle::C, cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_dumpTriangle, m_numberOfTriangles, and m_triIndexes.

◆ Available()

bool Delaunay2dMesh::Available ( )
static

Returns whether 2D Delaunay triangulation is supported or not.

2D Delaunay triangulation requires the CGAL library.

Definition at line 44 of file Delaunay2dMesh.cpp.

Referenced by define_Delaunay2dMesh().

◆ 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

Definition at line 63 of file Delaunay2dMesh.cpp.

References face, m_globalIterator, m_globalIteratorEnd, m_numberOfTriangles, m_triIndexes, Vector2Tpl< Type >::x, and Vector2Tpl< Type >::y.

◆ 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

Definition at line 133 of file Delaunay2dMesh.cpp.

References face, m_globalIterator, m_globalIteratorEnd, m_numberOfTriangles, m_triIndexes, Vector2Tpl< Type >::x, and Vector2Tpl< Type >::y.

Referenced by cloudViewer::PointProjectionTools::computeTriangulation(), DistanceMapGenerationTool::CreateMap(), define_Delaunay2dMesh(), TesselateContour(), and cloudViewer::Neighbourhood::triangulateOnPlane().

◆ 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 cloudViewer::GenericMesh.

Definition at line 306 of file Delaunay2dMesh.cpp.

References cloudViewer::SimpleTriangle::A, cloudViewer::SimpleTriangle::B, cloudViewer::SimpleTriangle::C, cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_numberOfTriangles, and m_triIndexes.

◆ getAssociatedCloud()

GenericIndexedCloud* cloudViewer::Delaunay2dMesh::getAssociatedCloud ( )
inline

Returns associated cloud.

Definition at line 111 of file Delaunay2dMesh.h.

Referenced by define_Delaunay2dMesh().

◆ 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 cloudViewer::GenericMesh.

Definition at line 389 of file Delaunay2dMesh.cpp.

References cloudViewer::GenericCloud::getBoundingBox(), and m_associatedCloud.

◆ 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 cloudViewer::GenericIndexedMesh.

Definition at line 335 of file Delaunay2dMesh.cpp.

References cloudViewer::VerticesIndexes::i1, cloudViewer::VerticesIndexes::i2, cloudViewer::VerticesIndexes::i3, m_dumpTriangleIndexes, m_globalIterator, and m_globalIteratorEnd.

Referenced by DistanceMapGenerationTool::CreateMap().

◆ getTriangleVertices() [1/2]

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 cloudViewer::GenericIndexedMesh.

Definition at line 358 of file Delaunay2dMesh.cpp.

References cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_numberOfTriangles, and m_triIndexes.

◆ getTriangleVertices() [2/2]

void Delaunay2dMesh::getTriangleVertices ( unsigned  triangleIndex,
double  A[3],
double  B[3],
double  C[3] 
) const
overridevirtual

◆ 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 cloudViewer::GenericIndexedMesh.

Definition at line 382 of file Delaunay2dMesh.cpp.

References m_numberOfTriangles, and m_triIndexes.

◆ getTriangleVertIndexesArray()

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

Returns triangles indexes array (pointer to)

Handle with care!

Definition at line 102 of file Delaunay2dMesh.h.

Referenced by define_Delaunay2dMesh().

◆ 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

Definition at line 52 of file Delaunay2dMesh.cpp.

References m_associatedCloud, and m_cloudIsOwnedByMesh.

Referenced by cloudViewer::PointProjectionTools::computeTriangulation(), define_Delaunay2dMesh(), cloudViewer::Neighbourhood::triangulateOnPlane(), and ~Delaunay2dMesh().

◆ placeIteratorAtBeginning()

void Delaunay2dMesh::placeIteratorAtBeginning ( )
overridevirtual

Places the mesh iterator at the beginning.

Virtual method to handle the mesh global iterator

Implements cloudViewer::GenericMesh.

Definition at line 320 of file Delaunay2dMesh.cpp.

References m_globalIterator, and m_triIndexes.

Referenced by DistanceMapGenerationTool::CreateMap().

◆ 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

Definition at line 207 of file Delaunay2dMesh.cpp.

References cloudViewer::ManualSegmentationTools::isPointInsidePoly(), m_associatedCloud, m_globalIterator, m_globalIteratorEnd, m_numberOfTriangles, m_triIndexes, and cloudViewer::GenericCloud::size().

Referenced by define_Delaunay2dMesh(), and TesselateContour().

◆ 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.

Definition at line 265 of file Delaunay2dMesh.cpp.

References cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_globalIterator, m_globalIteratorEnd, m_numberOfTriangles, and m_triIndexes.

Referenced by cloudViewer::PointProjectionTools::computeTriangulation(), define_Delaunay2dMesh(), and cloudViewer::Neighbourhood::triangulateOnPlane().

◆ size()

virtual unsigned cloudViewer::Delaunay2dMesh::size ( ) const
inlineoverridevirtual

Returns the number of triangles.

Virtual method to request the mesh size

Returns
the mesh size

Implements cloudViewer::GenericMesh.

Definition at line 82 of file Delaunay2dMesh.h.

Referenced by cloudViewer::PointProjectionTools::computeTriangulation(), DistanceMapGenerationTool::CreateMap(), TesselateContour(), and cloudViewer::Neighbourhood::triangulateOnPlane().

◆ TesselateContour() [1/2]

Delaunay2dMesh * Delaunay2dMesh::TesselateContour ( const std::vector< CCVector2 > &  contourPoints)
static

Tesselates a 2D polyline (shortcut to buildMesh and removeOuterTriangles)

Definition at line 397 of file Delaunay2dMesh.cpp.

References buildMesh(), count, Delaunay2dMesh(), removeOuterTriangles(), and size().

Referenced by define_Delaunay2dMesh(), and TesselateContour().

◆ TesselateContour() [2/2]

Delaunay2dMesh * Delaunay2dMesh::TesselateContour ( GenericIndexedCloudPersist contourPoints,
int  flatDimension = -1 
)
static

Member Data Documentation

◆ m_associatedCloud

GenericIndexedCloud* cloudViewer::Delaunay2dMesh::m_associatedCloud
protected

◆ m_cloudIsOwnedByMesh

bool cloudViewer::Delaunay2dMesh::m_cloudIsOwnedByMesh
protected

Specifies if the associated cloud should be deleted when the mesh is deleted

Definition at line 142 of file Delaunay2dMesh.h.

Referenced by linkMeshWith().

◆ m_dumpTriangle

SimpleTriangle cloudViewer::Delaunay2dMesh::m_dumpTriangle
protected

Dump triangle structure to transmit temporary data.

Definition at line 145 of file Delaunay2dMesh.h.

Referenced by _getNextTriangle(), and _getTriangle().

◆ m_dumpTriangleIndexes

VerticesIndexes cloudViewer::Delaunay2dMesh::m_dumpTriangleIndexes
protected

Dump triangle index structure to transmit temporary data.

Definition at line 148 of file Delaunay2dMesh.h.

Referenced by getNextTriangleVertIndexes().

◆ m_globalIterator

int* cloudViewer::Delaunay2dMesh::m_globalIterator
protected

Iterator on the list of triangle vertex indexes.

Definition at line 132 of file Delaunay2dMesh.h.

Referenced by _getNextTriangle(), buildMesh(), getNextTriangleVertIndexes(), placeIteratorAtBeginning(), removeOuterTriangles(), and removeTrianglesWithEdgesLongerThan().

◆ m_globalIteratorEnd

int* cloudViewer::Delaunay2dMesh::m_globalIteratorEnd
protected

End position of global iterator.

Definition at line 135 of file Delaunay2dMesh.h.

Referenced by _getNextTriangle(), buildMesh(), getNextTriangleVertIndexes(), removeOuterTriangles(), and removeTrianglesWithEdgesLongerThan().

◆ m_numberOfTriangles

unsigned cloudViewer::Delaunay2dMesh::m_numberOfTriangles
protected

◆ m_triIndexes

int* cloudViewer::Delaunay2dMesh::m_triIndexes
protected

◆ USE_ALL_POINTS

constexpr int cloudViewer::Delaunay2dMesh::USE_ALL_POINTS = 0
staticconstexpr

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