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
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
A generic mesh with index-based vertex access.
Mesh sampling algorithms.
std::map< unsigned long long, unsigned > EdgeUsageMap
Map used to count the number of triangles using each edge.
VertexFlags
Flags used by the MeshSamplingTools::flagMeshVerticesByType method.
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
::ccPointCloud PointCloud
Definition: PointCloud.h:19
Generic file read and write utility for python interface.
Statistics on the edges connectivty of a mesh.
unsigned edgesSharedByTwo
Edges shared by exactly two triangles.
unsigned edgesNotShared
Edges not shared (i.e. used by only one triangle)
unsigned edgesSharedByMore
Edges shared by more than two triangles.