![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Mesh sampling algorithms. More...
#include <MeshSamplingTools.h>


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 PointCloud * | samplePointsOnMesh (GenericMesh *mesh, double samplingDensity, GenericProgressCallback *progressCb=nullptr, std::vector< unsigned > *triIndices=nullptr) |
| Samples points on a mesh. More... | |
| static PointCloud * | samplePointsOnMesh (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 PointCloud * | samplePointsOnMesh (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. More... | |
| static void | DecodeEdgeKey (unsigned long long key, unsigned &i1, unsigned &i2) |
| Computes the edge vertex indexes from its unique key. More... | |
| static bool | buildMeshEdgeUsageMap (GenericIndexedMesh *mesh, EdgeUsageMap &edgeMap) |
| Creates a map to count the number of triangles using each edge. More... | |
Mesh sampling algorithms.
Definition at line 26 of file MeshSamplingTools.h.
|
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
Definition at line 153 of file MeshSamplingTools.h.
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 |
Definition at line 73 of file MeshSamplingTools.h.
|
staticprotected |
Creates a map to count the number of triangles using each edge.
Definition at line 104 of file MeshSamplingTools.cpp.
References ComputeEdgeKey(), cloudViewer::GenericIndexedMesh::getNextTriangleVertIndexes(), cloudViewer::VerticesIndexes::i, cloudViewer::GenericMesh::placeIteratorAtBeginning(), and cloudViewer::GenericMesh::size().
Referenced by computeMeshEdgesConnectivity(), and flagMeshVerticesByType().
|
staticprotected |
Computes the unique key corresponding to an edge.
Definition at line 90 of file MeshSamplingTools.cpp.
References std::swap().
Referenced by buildMeshEdgeUsageMap().
|
static |
Computes the mesh area.
| mesh | triangular mesh |
Definition at line 23 of file MeshSamplingTools.cpp.
References cloudViewer::GenericTriangle::_getA(), cloudViewer::GenericTriangle::_getB(), cloudViewer::GenericTriangle::_getC(), cloudViewer::GenericMesh::_getNextTriangle(), Vector3Tpl< Type >::cross(), Vector3Tpl< Type >::norm(), cloudViewer::GenericMesh::placeIteratorAtBeginning(), and cloudViewer::GenericMesh::size().
Referenced by ccComparisonDlg::determineBestOctreeLevel(), and samplePointsOnMesh().
|
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 ore 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.
| [in] | mesh | triangular mesh |
| [out] | stats | output statistics |
Definition at line 133 of file MeshSamplingTools.cpp.
References buildMeshEdgeUsageMap(), cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesCount, cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesNotShared, cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByMore, and cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByTwo.
|
static |
Computes the mesh volume.
| mesh | triangular mesh (closed!) |
Definition at line 50 of file MeshSamplingTools.cpp.
References cloudViewer::GenericTriangle::_getA(), cloudViewer::GenericTriangle::_getB(), cloudViewer::GenericTriangle::_getC(), cloudViewer::GenericMesh::_getNextTriangle(), abs(), cloudViewer::GenericMesh::getBoundingBox(), cloudViewer::GenericMesh::placeIteratorAtBeginning(), cloudViewer::GenericMesh::size(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by CommandComputeMeshVolume::process().
|
staticprotected |
Computes the edge vertex indexes from its unique key.
Definition at line 97 of file MeshSamplingTools.cpp.
Referenced by flagMeshVerticesByType().
|
static |
Flags the vertices of a mesh depending on their type.
See MeshSamplingTools::VertexFlags.
| [in] | mesh | triangular mesh |
| [in] | flags | already allocated scalar field to store the per-vertex flags |
| [out] | stats | output statistics (optional) |
Definition at line 160 of file MeshSamplingTools.cpp.
References buildMeshEdgeUsageMap(), cloudViewer::ScalarField::computeMinAndMax(), cloudViewer::ScalarField::currentSize(), DecodeEdgeKey(), cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesCount, cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesNotShared, cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByMore, cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByTwo, cloudViewer::ScalarField::fill(), NAN_VALUE, cloudViewer::ScalarField::setValue(), VERTEX_BORDER, VERTEX_NON_MANIFOLD, and VERTEX_NORMAL.
|
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.
| mesh | the mesh to be sampled | |
| samplingDensity | the sampling surface density | |
| progressCb | the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) | |
| [out] | triIndices | triangle index for each samples point (output only - optional) |
Definition at line 230 of file MeshSamplingTools.cpp.
References cloudViewer::utility::ceil(), and computeMeshArea().
Referenced by ccRegistrationTools::ICP(), and samplePointsOnMesh().
|
staticprotected |
Samples points on a mesh - internal method.
See public methods descriptions
| mesh | the mesh to be sampled | |
| samplingDensity | the sampling surfacical density | |
| theoreticNumberOfPoints | the approximated number of points that will be sampled | |
| progressCb | the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) | |
| [out] | triIndices | triangle index for each samples point (output only - optional) |
Definition at line 247 of file MeshSamplingTools.cpp.
References cloudViewer::GenericTriangle::_getA(), cloudViewer::GenericTriangle::_getB(), cloudViewer::GenericTriangle::_getC(), cloudViewer::GenericMesh::_getNextTriangle(), cloudViewer::PointCloudTpl< T >::addPoint(), Vector3Tpl< Type >::cross(), dist(), Vector3Tpl< Type >::normd(), cloudViewer::NormalizedProgress::oneStep(), cloudViewer::GenericMesh::placeIteratorAtBeginning(), cloudViewer::PointCloudTpl< T >::reserve(), cloudViewer::PointCloud::resize(), cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericProgressCallback::setMethodTitle(), cloudViewer::GenericMesh::size(), cloudViewer::GenericProgressCallback::start(), cloudViewer::GenericProgressCallback::textCanBeEdited(), and cloudViewer::GenericProgressCallback::update().
|
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).
| mesh | the mesh to be sampled | |
| numberOfPoints | the desired number of points on the whole mesh | |
| progressCb | the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) | |
| [out] | triIndices | triangle index for each samples point (output only - optional) |
Definition at line 211 of file MeshSamplingTools.cpp.
References computeMeshArea(), cloudViewer::LessThanEpsilon(), and samplePointsOnMesh().