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

Mesh sampling algorithms. More...

#include <MeshSamplingTools.h>

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

Classes

struct  EdgeConnectivityStats
 Statistics on the edges connectivty of a mesh. More...
 

Public Types

enum  VertexFlags { VERTEX_NORMAL = 0 , VERTEX_BORDER = 1 , VERTEX_NON_MANIFOLD = 2 }
 Flags used by the MeshSamplingTools::flagMeshVerticesByType method. More...
 

Static Public Member Functions

static double computeMeshArea (GenericMesh *mesh)
 Computes the mesh area. More...
 
static double computeMeshVolume (GenericMesh *mesh)
 Computes the mesh volume. More...
 
static bool computeMeshEdgesConnectivity (GenericIndexedMesh *mesh, EdgeConnectivityStats &stats)
 Computes some statistics on the edges connectivty of a mesh. More...
 
static bool flagMeshVerticesByType (GenericIndexedMesh *mesh, ScalarField *flags, EdgeConnectivityStats *stats=nullptr)
 Flags the vertices of a mesh depending on their type. More...
 
static PointCloudsamplePointsOnMesh (GenericMesh *mesh, double samplingDensity, GenericProgressCallback *progressCb=nullptr, std::vector< unsigned > *triIndices=nullptr)
 Samples points on a mesh. More...
 
static PointCloudsamplePointsOnMesh (GenericMesh *mesh, unsigned numberOfPoints, GenericProgressCallback *progressCb=nullptr, std::vector< unsigned > *triIndices=nullptr)
 Samples points on a mesh. More...
 

Protected Types

using EdgeUsageMap = std::map< unsigned long long, unsigned >
 Map used to count the number of triangles using each edge. More...
 

Static Protected Member Functions

static PointCloudsamplePointsOnMesh (GenericMesh *mesh, double samplingDensity, unsigned theoreticNumberOfPoints, GenericProgressCallback *progressCb=nullptr, std::vector< unsigned > *triIndices=nullptr)
 Samples points on a mesh - internal method. More...
 
static unsigned long long ComputeEdgeKey (unsigned i1, unsigned i2)
 Computes the unique key corresponding to an edge.
 
static void DecodeEdgeKey (unsigned long long key, unsigned &i1, unsigned &i2)
 Computes the edge vertex indexes from its unique key.
 
static bool buildMeshEdgeUsageMap (GenericIndexedMesh *mesh, EdgeUsageMap &edgeMap)
 Creates a map to count the number of triangles using each edge.
 

Detailed Description

Mesh sampling algorithms.

Member Typedef Documentation

◆ EdgeUsageMap

using CCCoreLib::MeshSamplingTools::EdgeUsageMap = std::map<unsigned long long, unsigned>
protected

Map used to count the number of triangles using each edge.

Edges are represented by two 32 bits indexes merged as a 64 integer

Member Enumeration Documentation

◆ VertexFlags

Flags used by the MeshSamplingTools::flagMeshVerticesByType method.

Enumerator
VERTEX_NORMAL 

Normal vertex

VERTEX_BORDER 

Vertex on a border/hole

VERTEX_NON_MANIFOLD 

Vertex on a non-manifold edge

Member Function Documentation

◆ computeMeshArea()

double MeshSamplingTools::computeMeshArea ( GenericMesh mesh)
static

Computes the mesh area.

Parameters
meshtriangular mesh
Returns
mesh area

◆ computeMeshEdgesConnectivity()

bool MeshSamplingTools::computeMeshEdgesConnectivity ( GenericIndexedMesh mesh,
EdgeConnectivityStats stats 
)
static

Computes some statistics on the edges connectivty of a mesh.

This methods counts the number of edges shared by 1, 2 or more faces. One or more edges used only by 1 face each indicates the presence of at least one hole. Edges used by more than two faces are non-manifold.

Parameters
[in]meshtriangular mesh
[out]statsoutput statistics
Returns
false if an error occurred (invalid input or not enough memory)

◆ computeMeshVolume()

double MeshSamplingTools::computeMeshVolume ( GenericMesh mesh)
static

Computes the mesh volume.

Warning
Make sure the input mesh is closed! See MeshSamplingTools::computeMeshEdgesConnectivity.
Parameters
meshtriangular mesh (closed!)
Returns
mesh volume

◆ flagMeshVerticesByType()

bool MeshSamplingTools::flagMeshVerticesByType ( GenericIndexedMesh mesh,
ScalarField flags,
EdgeConnectivityStats stats = nullptr 
)
static

Flags the vertices of a mesh depending on their type.

See MeshSamplingTools::VertexFlags.

Parameters
[in]meshtriangular mesh
[in]flagsalready allocated scalar field to store the per-vertex flags
[out]statsoutput statistics (optional)
Returns
false if an error occurred (invalid input or not enough memory)

◆ samplePointsOnMesh() [1/3]

PointCloud * MeshSamplingTools::samplePointsOnMesh ( GenericMesh mesh,
double  samplingDensity,
GenericProgressCallback progressCb = nullptr,
std::vector< unsigned > *  triIndices = nullptr 
)
static

Samples points on a mesh.

The points are sampled on each triangle randomly, by generating two numbers between 0 and 1 (a and b). If a+b > 1, then a = 1-a and b = 1-b. Let ABC be the triangle, then the new point P will be as AP = a.AB+b.AC (AP,AB and AC are vectors here). The number of points sampled on each triangle depends on the triangle's area. Let s be this area, and µ the sampling density, then N = s*µ is the theoretic (floating) number of points to sample. The floating part of N (let's call it Nf, and let Ni be the integer part) is handled by generating another random number between 0 and 1. If this number is less than Nf, then Ni = Ni+1. The number of points sampled on the triangle will simply be Ni.

Parameters
meshthe mesh to be sampled
samplingDensitythe sampling surface density
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
[out]triIndicestriangle index for each samples point (output only - optional)
Returns
the sampled points

◆ samplePointsOnMesh() [2/3]

PointCloud * MeshSamplingTools::samplePointsOnMesh ( GenericMesh mesh,
double  samplingDensity,
unsigned  theoreticNumberOfPoints,
GenericProgressCallback progressCb = nullptr,
std::vector< unsigned > *  triIndices = nullptr 
)
staticprotected

Samples points on a mesh - internal method.

See public methods descriptions

Parameters
meshthe mesh to be sampled
samplingDensitythe sampling surfacical density
theoreticNumberOfPointsthe approximated number of points that will be sampled
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
[out]triIndicestriangle index for each samples point (output only - optional)
Returns
the sampled points

◆ samplePointsOnMesh() [3/3]

PointCloud * MeshSamplingTools::samplePointsOnMesh ( GenericMesh mesh,
unsigned  numberOfPoints,
GenericProgressCallback progressCb = nullptr,
std::vector< unsigned > *  triIndices = nullptr 
)
static

Samples points on a mesh.

See the other version of this method. Instead of specifying a density, it is possible here to specify the total number of points to sample (approximative).

Parameters
meshthe mesh to be sampled
numberOfPointsthe desired number of points on the whole mesh
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
[out]triIndicestriangle index for each samples point (output only - optional)
Returns
the sampled points

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