CCCoreLib 31 May 2022
CloudCompare Core algorithms
|
A class to compute and handle a Delaunay 2D mesh on a subset of points. More...
#include <Delaunay2dMesh.h>
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... | |
VerticesIndexes * | getNextTriangleVertIndexes () override |
Returns the indexes of the vertices of the next triangle (relatively to the global iterator position) More... | |
VerticesIndexes * | getTriangleVertIndexes (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... | |
GenericIndexedCloud * | getAssociatedCloud () |
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 VerticesIndexes * | getTriangleVertIndexes (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 VerticesIndexes * | getNextTriangleVertIndexes ()=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 Delaunay2dMesh * | TesselateContour (const std::vector< CCVector2 > &contourPoints) |
Tesselates a 2D polyline (shortcut to buildMesh and removeOuterTriangles) | |
static Delaunay2dMesh * | TesselateContour (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 | |
GenericIndexedCloud * | m_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) | |
A class to compute and handle a Delaunay 2D mesh on a subset of points.
|
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.
Implements CCCoreLib::GenericMesh.
|
overridevirtual |
Returns the ith triangle.
Virtual method to request a triangle with a specific index. The returned object can be temporary.
triangleIndex | of the requested triangle (between 0 and the mesh size-1) |
Implements CCCoreLib::GenericIndexedMesh.
|
static |
Returns whether 2D Delaunay triangulation is supported or not.
2D Delaunay triangulation requires the CGAL library.
|
virtual |
Build the Delaunay mesh from a set of 2D polylines.
points2D | a set of 2D points |
segments2D | constraining segments (as 2 indexes per segment) |
outputErrorStr | error string as output by the CGAL lib. (if any) |
|
virtual |
Build the Delaunay mesh on top a set of 2D points.
points2D | a set of 2D points |
pointCountToUse | number of points to use from the input set (USE_ALL_POINTS = all) |
outputErrorStr | error string as output by the CGAL lib. (if any) |
|
overridevirtual |
Fast iteration mechanism.
Virtual method to apply a function to the whole mesh
action | function to apply (see GenericMesh::genericTriangleAction) |
Implements CCCoreLib::GenericMesh.
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.
bbMin | lower bounding-box limits (Xmin,Ymin,Zmin) |
bbMax | higher bounding-box limits (Xmax,Ymax,Zmax) |
Implements CCCoreLib::GenericMesh.
|
overridevirtual |
Returns the indexes of the vertices of the next triangle (relatively to the global iterator position)
Implements CCCoreLib::GenericIndexedMesh.
|
overridevirtual |
Returns the vertices of a given triangle.
[in] | triangleIndex | index of the triangle (between 0 and the size(mesh)-1) |
[out] | A | first vertex |
[out] | B | second vertex |
[out] | C | third vertex |
Implements CCCoreLib::GenericIndexedMesh.
|
overridevirtual |
Returns the indexes of the vertices of a given triangle.
triangleIndex | index of the triangle (between 0 and size(mesh)-1) |
Implements CCCoreLib::GenericIndexedMesh.
|
inline |
Returns triangles indexes array (pointer to)
Handle with care!
|
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.
aCloud | a point cloud |
passOwnership | if true the Delaunay2dMesh destructor will delete the cloud as well |
|
overridevirtual |
Places the mesh iterator at the beginning.
Virtual method to handle the mesh global iterator
Implements CCCoreLib::GenericMesh.
|
virtual |
Removes the triangles falling outside of a given (2D) polygon.
vertices2D | vertices of the mesh as 2D points (typically the one used to triangulate the mesh!) |
polygon2D | vertices of the 2D boundary polygon (ordered) |
removeOutside | whether to remove triangles outside (default) or inside |
bool Delaunay2dMesh::removeTrianglesWithEdgesLongerThan | ( | PointCoordinateType | maxEdgeLength | ) |
Filters out the triangles based on their edge length.
Warning: may remove ALL triangles! Check the resulting size afterwards.
|
inlineoverridevirtual |
Returns the number of triangles.
Virtual method to request the mesh size
Implements CCCoreLib::GenericMesh.