MeshLib C++ Docs
Loading...
Searching...
No Matches
MRAlphaShape.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
5#include "MRFastInt128.h"
6#include "MRVector.h"
7#include "MRBitSet.h"
8#include "MRPch/MRBindingMacros.h"
9#include <cstddef>
10#include <optional>
11
12namespace MR
13{
16
17
20
25{
28
32
36 VertBitSet twins;
37
39 [[nodiscard]] bool knowsTwins() const { return !intPoints.empty(); }
40
44 std::int64_t intRadiusSq = 0;
45
48 float searchRadius = 0;
49
52 [[nodiscard]] MRMESH_API PreciseVertCoords coords( const PointCloud & cloud, VertId v ) const;
53};
54
58[[nodiscard]] MRMESH_API AlphaShapeData getAlphaShapeData( const PointCloud & cloud, float radius, bool allPoints );
59
64{
68 std::size_t collectedNeis = 0;
69
72 std::size_t redundancyTests = 0;
73
75 std::size_t redundantNeis = 0;
76
79 std::size_t consideredTris = 0;
80
83 std::size_t touchableTris = 0;
84
88 std::size_t inBallTests = 0;
89
91 std::size_t shadowTests = 0;
92
95 std::size_t exactShadowTests = 0;
96
98 std::size_t shadowedNeis = 0;
99
113};
114
117{
120
122 MR_BIND_IGNORE FastInt128 distSq;
123};
124
131 const AlphaShapeData & data,
132 Triangulation & appendTris,
133 Vector<AlphaShapeNei> & neis,
134 bool onlyLargerVids,
135 AlphaShapeStats * stats = nullptr );
136
139{
142
145 bool cwFromVk = false;
146};
147
159[[nodiscard]] MRMESH_API VertId findBallPivotVertex( const PointCloud & cloud, VertId vi, VertId vj, VertId vk,
160 const AlphaShapeData & data,
162
164[[nodiscard]] MRMESH_API std::optional<Triangulation> findAlphaShapeAllTriangles( const PointCloud & cloud, float radius,
165 const ProgressCallback & cb, AlphaShapeStats * stats = nullptr );
166[[nodiscard]] MRMESH_API Triangulation findAlphaShapeAllTriangles( const PointCloud & cloud, float radius,
167 AlphaShapeStats * stats = nullptr );
168
171[[nodiscard]] MRMESH_API std::optional<Triangulation> findAlphaShapeAllTriangles( const PointCloud & cloud,
172 const AlphaShapeData & data, const ProgressCallback & cb, AlphaShapeStats * stats = nullptr );
173[[nodiscard]] MRMESH_API Triangulation findAlphaShapeAllTriangles( const PointCloud & cloud,
174 const AlphaShapeData & data, AlphaShapeStats * stats = nullptr );
175
179[[nodiscard]] MRMESH_API std::optional<Mesh> findAlphaShape( const PointCloud & cloud, float radius,
180 const ProgressCallback & cb, std::vector<MeshBuilder::VertDuplication> * dups = nullptr, AlphaShapeStats * stats = nullptr );
181[[nodiscard]] MRMESH_API Mesh findAlphaShape( const PointCloud & cloud, float radius,
182 std::vector<MeshBuilder::VertDuplication> * dups = nullptr, AlphaShapeStats * stats = nullptr );
183
189[[nodiscard]] MRMESH_API std::optional<ThreeVertIds> findBallPivotingSeed( const PointCloud & cloud, VertId v, const Vector3f & dir,
190 const AlphaShapeData & data,
191 Triangulation & tris,
192 Vector<AlphaShapeNei> & neis );
193
198[[nodiscard]] MRMESH_API std::optional<Triangulation> findBallPivotingComponent( const PointCloud & cloud, const ThreeVertIds & seed,
199 const AlphaShapeData & data,
200 const ProgressCallback & cb = {} );
201
208[[nodiscard]] MRMESH_API std::optional<Triangulation> findBallPivotingTriangles( const PointCloud & cloud,
209 const AlphaShapeData & data,
210 bool allComponents = false, const ProgressCallback & cb = {} );
211
215[[nodiscard]] MRMESH_API std::optional<Mesh> findBallPivotingMesh( const PointCloud & cloud, float radius, bool allComponents,
216 const ProgressCallback & cb, std::vector<MeshBuilder::VertDuplication> * dups = nullptr );
217[[nodiscard]] MRMESH_API Mesh findBallPivotingMesh( const PointCloud & cloud, float radius, bool allComponents = false,
218 std::vector<MeshBuilder::VertDuplication> * dups = nullptr );
219
220}
#define MRMESH_API
Definition MRMeshFwd.h:85
Vector<T> is indexed by size_t.
Definition MRVector.h:24
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:790
VertId findBallPivotVertex(const PointCloud &cloud, VertId vi, VertId vj, VertId vk, const AlphaShapeData &data, Vector< BallPivotCandidate > &cands)
temporary storage to avoid memory allocations, it will be filled with the touchable points in unspeci...
std::size_t collectedNeis
Definition MRAlphaShape.h:68
std::size_t redundancyTests
Definition MRAlphaShape.h:72
FastInt128 distSq
the exact squared distance from v in the units of the same integer grid
Definition MRAlphaShape.h:122
std::optional< Mesh > findBallPivotingMesh(const PointCloud &cloud, float radius, bool allComponents, const ProgressCallback &cb, std::vector< MeshBuilder::VertDuplication > *dups=nullptr)
std::size_t redundantNeis
the number of neighbours found redundant by those checks and excluded from the search
Definition MRAlphaShape.h:75
AlphaShapeData getAlphaShapeData(const PointCloud &cloud, float radius, bool allPoints)
std::size_t consideredTris
Definition MRAlphaShape.h:79
std::optional< ThreeVertIds > findBallPivotingSeed(const PointCloud &cloud, VertId v, const Vector3f &dir, const AlphaShapeData &data, Triangulation &tris, Vector< AlphaShapeNei > &neis)
temporary storage to avoid memory allocations, see findAlphaShapeNeiTriangles
bool cwFromVk
Definition MRAlphaShape.h:145
std::size_t inBallTests
Definition MRAlphaShape.h:88
PreciseVertCoords coords
the point's id together with its integer coordinates
Definition MRAlphaShape.h:141
ConvertToIntVector toInt
converts cloud's points in integer coordinates
Definition MRAlphaShape.h:27
Vector< Vector3i, VertId > intPoints
Definition MRAlphaShape.h:31
std::size_t touchableTris
Definition MRAlphaShape.h:83
AlphaShapeStats & operator+=(const AlphaShapeStats &r)
Definition MRAlphaShape.h:100
PreciseVertCoords coords
the neighbour's id together with its integer coordinates
Definition MRAlphaShape.h:119
std::int64_t intRadiusSq
Definition MRAlphaShape.h:44
std::size_t shadowTests
the number of neighbours tested for being shadowed by the balls of a touchable triangle
Definition MRAlphaShape.h:91
PreciseVertCoords coords(const PointCloud &cloud, VertId v) const
std::size_t shadowedNeis
the number of neighbours found shadowed, which are excluded from the search
Definition MRAlphaShape.h:98
std::optional< Triangulation > findBallPivotingTriangles(const PointCloud &cloud, const AlphaShapeData &data, bool allComponents=false, const ProgressCallback &cb={})
std::optional< Mesh > findAlphaShape(const PointCloud &cloud, float radius, const ProgressCallback &cb, std::vector< MeshBuilder::VertDuplication > *dups=nullptr, AlphaShapeStats *stats=nullptr)
void findAlphaShapeNeiTriangles(const PointCloud &cloud, VertId v, const AlphaShapeData &data, Triangulation &appendTris, Vector< AlphaShapeNei > &neis, bool onlyLargerVids, AlphaShapeStats *stats=nullptr)
optional statistics of the work done, which is increased here
float searchRadius
Definition MRAlphaShape.h:48
std::optional< Triangulation > findBallPivotingComponent(const PointCloud &cloud, const ThreeVertIds &seed, const AlphaShapeData &data, const ProgressCallback &cb={})
reports the fraction of the cloud points in the triangles found so far, so it stays small for a small...
bool knowsTwins() const
whether the twins are known, i.e. the data was prepared with allPoints=true (for a cloud with valid p...
Definition MRAlphaShape.h:39
std::size_t exactShadowTests
Definition MRAlphaShape.h:95
VertBitSet twins
Definition MRAlphaShape.h:36
std::optional< Triangulation > findAlphaShapeAllTriangles(const PointCloud &cloud, float radius, const ProgressCallback &cb, AlphaShapeStats *stats=nullptr)
finds all triangles of alpha-shape with negative alpha = -1/radius
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
__int128_t FastInt128
Definition MRFastInt128.h:22
Definition MRAlphaShape.h:25
a neighbour of the point v in the search of alpha-shape triangles around it
Definition MRAlphaShape.h:117
Definition MRAlphaShape.h:64
a point touchable by a ball together with the edge (vi, vj) in the search of findBallPivotVertex
Definition MRAlphaShape.h:139
translate then scale float-to-int coordinate converter
Definition MRPrecisePredicates3.h:100
Definition MRMesh.h:24
Definition MRPointCloud.h:17
Definition MRPrecisePredicates3.h:38
three vertex ids describing a triangle with the corners in vertices given by their ids
Definition MRId.h:203