MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPointCloudTriangulationHelpers.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRPch/MRBindingMacros.h"
4#include "MRVector.h"
5#include "MRId.h"
6#include "MRConstants.h"
7#include "MRBuffer.h"
8#include "MRPointsProject.h"
9#include "MRFewSmallest.h"
10#include <climits>
11#include <optional>
12#include <queue>
13
14namespace MR
15{
22{
23
29MRMESH_API float updateNeighborsRadius( const VertCoords& points, VertId v, VertId boundaryV,
30 const std::vector<VertId>& fan, float baseRadius );
31
36MRMESH_API void findNeighborsInBall( const PointCloud& pointCloud, VertId v, float radius, std::vector<VertId>& neighbors );
37
45MRMESH_API float findNumNeighbors( const PointCloud& pointCloud, VertId v, int numNeis, std::vector<VertId>& neighbors,
46 FewSmallest<PointsProjectionResult> & tmp, float upDistLimitSq = FLT_MAX );
47
52MRMESH_API void filterNeighbors( const VertNormals& orientedNormals, const VertBitSet* untrustedNormals, VertId v, std::vector<VertId>& neighbors );
53
55{
56 float weight{ 0.0f }; // profit of flipping this edge
57 int id{ -1 }; // index
58
59 // needed to remove outdated queue elements
60 int prevId{ -1 }; // id of prev neighbor
61 int nextId{ -1 }; // id of next neighbor
62
63 bool stable{ false }; // if this flag is true, edge cannot be flipped
64 bool operator < ( const FanOptimizerQueueElement& other ) const
65 {
66 if ( stable == other.stable )
67 return weight < other.weight;
68 return stable;
69 }
70 bool operator==( const FanOptimizerQueueElement& other ) const = default;
71
72 bool isOutdated( const std::vector<VertId>& neighbors ) const
73 {
74 return !neighbors[nextId].valid() || !neighbors[prevId].valid();
75 }
76};
77
82struct TriangulatedFanData
83{
86 std::vector<VertId> neighbors;
87
89 std::vector<std::pair<double, int>> cacheAngleOrder;
90
93 VertId border;
94
96 FewSmallest<PointsProjectionResult> nearesetPoints;
97
100 MR_BIND_IGNORE std::priority_queue<FanOptimizerQueueElement> queue;
101};
102
103struct Settings
104{
107 float radius = 0;
108
111 int numNeis = 0;
112
114 float critAngle = PI2_F;
115
117 float boundaryAngle = 0.9f * PI_F;
118
121 const VertNormals* orientedNormals = nullptr;
122 const VertBitSet* untrustedNormals = nullptr;
123
125 bool automaticRadiusIncrease = true;
126
128 int maxRemoves = INT_MAX;
129
131 std::vector<VertId> * allNeighbors = nullptr;
132
134 float * actualRadius = nullptr;
135
137 const PointCloud * searchNeighbors = nullptr;
138};
139
141MRMESH_API void buildLocalTriangulation( const PointCloud& cloud, VertId v, const Settings & settings,
142 TriangulatedFanData & fanData );
143
146[[nodiscard]] MRMESH_API std::optional<std::vector<SomeLocalTriangulations>> buildLocalTriangulations(
147 const PointCloud& cloud, const Settings & settings, const ProgressCallback & progress = {} );
148
150[[nodiscard]] MRMESH_API std::optional<AllLocalTriangulations> buildUnitedLocalTriangulations(
151 const PointCloud& cloud, const Settings & settings, const ProgressCallback & progress = {} );
152
162[[nodiscard]] MRMESH_API bool isBoundaryPoint( const PointCloud& cloud, VertId v, const Settings & settings,
163 TriangulatedFanData & fanData );
164
166[[nodiscard]] MRMESH_API std::optional<VertBitSet> findBoundaryPoints( const PointCloud& pointCloud, const Settings & settings,
167 ProgressCallback cb = {} );
168
169
170} //namespace TriangulationHelpers
171
172} //namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
the class stores some number of smallest elements from a larger number of candidates
Definition MRFewSmallest.h:14
Definition MRMesh/MRPointCloud.h:17
Definition MRPointCloudTriangulationHelpers.h:55
Definition MRPointCloudTriangulationHelpers.h:104
new unsafe ref bool automaticRadiusIncrease
new unsafe MR.? Const_VertCoords orientedNormals
new unsafe MR.? Const_PointCloud searchNeighbors
new unsafe ref float critAngle
new unsafe MR.Misc.? Box< float > actualRadius
new unsafe MR.Std.? Vector_MRVertId allNeighbors
new unsafe ref float boundaryAngle
Definition MRPointCloudTriangulationHelpers.h:83
new unsafe MR.Std.Vector_MRVertId neighbors
new unsafe MR.Std.Vector_StdPairDoubleInt cacheAngleOrder
new unsafe MR.FewSmallest_MRPointsProjectionResult nearesetPoints
MRMESH_API void findNeighborsInBall(const PointCloud &pointCloud, VertId v, float radius, std::vector< VertId > &neighbors)
Finds all neighbors of v in given radius (v excluded)
MRMESH_API float updateNeighborsRadius(const VertCoords &points, VertId v, VertId boundaryV, const std::vector< VertId > &fan, float baseRadius)
Finds max radius of neighbors search, for possible better local triangulation.
MRMESH_API bool isBoundaryPoint(const PointCloud &cloud, VertId v, const Settings &settings, TriangulatedFanData &fanData)
Checks if given vertex is on boundary of the point cloud, by constructing local triangulation around ...
MRMESH_API void filterNeighbors(const VertNormals &orientedNormals, const VertBitSet *untrustedNormals, VertId v, std::vector< VertId > &neighbors)
Filter neighbors with crossing normals.
MRMESH_API float findNumNeighbors(const PointCloud &pointCloud, VertId v, int numNeis, std::vector< VertId > &neighbors, FewSmallest< PointsProjectionResult > &tmp, float upDistLimitSq=FLT_MAX)
Finds at most given number of neighbors of v (v excluded)
MRMESH_API std::optional< std::vector< SomeLocalTriangulations > > buildLocalTriangulations(const PointCloud &cloud, const Settings &settings, const ProgressCallback &progress={})
MRMESH_API std::optional< VertBitSet > findBoundaryPoints(const PointCloud &pointCloud, const Settings &settings, ProgressCallback cb={})
Returns bit set of points that are considered as boundary by calling isBoundaryPoint in each.
MRMESH_API void buildLocalTriangulation(const PointCloud &cloud, VertId v, const Settings &settings, TriangulatedFanData &fanData)
constructs local triangulation around given point
MRMESH_API std::optional< AllLocalTriangulations > buildUnitedLocalTriangulations(const PointCloud &cloud, const Settings &settings, const ProgressCallback &progress={})
Definition MRCameraOrientationPlugin.h:8