ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
MeshSamplingTools.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CVToolbox.h"
12 
13 // system
14 #include <map>
15 #include <vector>
16 
17 namespace cloudViewer {
18 
19 class GenericProgressCallback;
20 class GenericMesh;
21 class GenericIndexedMesh;
22 class PointCloud;
23 class ScalarField;
24 
27 public:
29 
32  static double computeMeshArea(GenericMesh* mesh);
33 
35 
40  static double computeMeshVolume(GenericMesh* mesh);
41 
45  : edgesCount(0),
46  edgesNotShared(0),
47  edgesSharedByTwo(0),
48  edgesSharedByMore(0) {}
49 
51  unsigned edgesCount;
53  unsigned edgesNotShared;
55  unsigned edgesSharedByTwo;
58  };
59 
61 
69  static bool computeMeshEdgesConnectivity(GenericIndexedMesh* mesh,
70  EdgeConnectivityStats& stats);
71 
73  enum VertexFlags {
74  VERTEX_NORMAL = 0,
75  VERTEX_BORDER = 1,
76  VERTEX_NON_MANIFOLD = 2
77  };
78 
80 
86  static bool flagMeshVerticesByType(GenericIndexedMesh* mesh,
87  ScalarField* flags,
88  EdgeConnectivityStats* stats = nullptr);
89 
91 
109  static PointCloud* samplePointsOnMesh(
110  GenericMesh* mesh,
111  double samplingDensity,
112  GenericProgressCallback* progressCb = nullptr,
113  std::vector<unsigned>* triIndices = nullptr);
114 
116 
126  static PointCloud* samplePointsOnMesh(
127  GenericMesh* mesh,
128  unsigned numberOfPoints,
129  GenericProgressCallback* progressCb = nullptr,
130  std::vector<unsigned>* triIndices = nullptr);
131 
132 protected:
134 
143  static PointCloud* samplePointsOnMesh(
144  GenericMesh* mesh,
145  double samplingDensity,
146  unsigned theoreticNumberOfPoints,
147  GenericProgressCallback* progressCb = nullptr,
148  std::vector<unsigned>* triIndices = nullptr);
149 
151 
153  using EdgeUsageMap = std::map<unsigned long long, unsigned>;
154 
156  static unsigned long long ComputeEdgeKey(unsigned i1, unsigned i2);
158  static void DecodeEdgeKey(unsigned long long key,
159  unsigned& i1,
160  unsigned& i2);
161 
163  static bool buildMeshEdgeUsageMap(GenericIndexedMesh* mesh,
164  EdgeUsageMap& edgeMap);
165 };
166 
167 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::MeshSamplingTools
Mesh sampling algorithms.
Definition: MeshSamplingTools.h:26
cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByMore
unsigned edgesSharedByMore
Edges shared by more than two triangles.
Definition: MeshSamplingTools.h:57
cloudViewer::ScalarField
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
cloudViewer::MeshSamplingTools::VertexFlags
VertexFlags
Flags used by the MeshSamplingTools::flagMeshVerticesByType method.
Definition: MeshSamplingTools.h:73
cloudViewer::GenericProgressCallback
Definition: GenericProgressCallback.h:20
cloudViewer::CVToolbox
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
cloudViewer::MeshSamplingTools::EdgeConnectivityStats
Statistics on the edges connectivty of a mesh.
Definition: MeshSamplingTools.h:43
cloudViewer::PointCloud
Definition: CVPointCloud.h:18
CVToolbox.h
cloudViewer::MeshSamplingTools::EdgeConnectivityStats::EdgeConnectivityStats
EdgeConnectivityStats()
Definition: MeshSamplingTools.h:44
cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesCount
unsigned edgesCount
Total number of edges.
Definition: MeshSamplingTools.h:51
cloudViewer::GenericIndexedMesh
A generic mesh with index-based vertex access.
Definition: GenericIndexedMesh.h:37
cloudViewer::GenericMesh
Definition: GenericMesh.h:21
cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesNotShared
unsigned edgesNotShared
Edges not shared (i.e. used by only one triangle)
Definition: MeshSamplingTools.h:53
cloudViewer::MeshSamplingTools::EdgeConnectivityStats::edgesSharedByTwo
unsigned edgesSharedByTwo
Edges shared by exactly two triangles.
Definition: MeshSamplingTools.h:55
cloudViewer::MeshSamplingTools::EdgeUsageMap
std::map< unsigned long long, unsigned > EdgeUsageMap
Map used to count the number of triangles using each edge.
Definition: MeshSamplingTools.h:153
cloudViewer::geometry::PointCloud
::ccPointCloud PointCloud
Definition: PointCloud.h:19
CV_CORE_LIB_API
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15