MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPolylineDecimate.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include <cfloat>
5#include <climits>
6#include <functional>
7
8namespace MR
9{
12
13
21template<typename V>
22struct DecimatePolylineSettings
23{
25 float maxError = 0.001f;
26
28 float maxEdgeLen = FLT_MAX;
29
33 float stabilizer = 0.001f;
34
37 bool optimizeVertexPos = true;
38
40 int maxDeletedVertices = INT_MAX;
41
44 VertBitSet* region = nullptr;
45
49 bool touchBdVertices = true;
50
57 std::function<bool( EdgeId edgeToCollapse, const V & newEdgeOrgPos )> preCollapse;
58
67 std::function<void( UndirectedEdgeId ue, float & collapseErrorSq, V & collapsePos )> adjustCollapse;
68
75};
76
79
85{
86 int vertsDeleted = 0;
87 float errorIntroduced = 0;
88};
89
94MRMESH_API DecimatePolylineResult decimatePolyline( Polyline2& polyline, const DecimatePolylineSettings2& settings = {} );
95MRMESH_API DecimatePolylineResult decimatePolyline( Polyline3& polyline, const DecimatePolylineSettings3& settings = {} );
96
101MRMESH_API DecimatePolylineResult decimateContour( Contour2f& contour, const DecimatePolylineSettings2& settings = {} );
102MRMESH_API DecimatePolylineResult decimateContour( Contour3f& contour, const DecimatePolylineSettings3& settings = {} );
103
104}
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
MRMESH_API DecimatePolylineResult decimateContour(Contour2f &contour, const DecimatePolylineSettings2 &settings={})
Collapse edges in the contour according to the settings.
MRMESH_API DecimatePolylineResult decimatePolyline(Polyline2 &polyline, const DecimatePolylineSettings2 &settings={})
Collapse edges in the polyline according to the settings.
bool optimizeVertexPos
Definition MRPolylineDecimate.h:37
Vector< QuadraticForm< V >, VertId > * vertForms
If not null, then on input: if the vector is not empty then it is taken for initialization instead of...
Definition MRPolylineDecimate.h:74
float maxError
Limit from above on the maximum distance from moved vertices to original contour.
Definition MRPolylineDecimate.h:25
int maxDeletedVertices
Limit on the number of deleted vertices.
Definition MRPolylineDecimate.h:40
float errorIntroduced
Max different (as distance) between original contour and result contour.
Definition MRPolylineDecimate.h:87
float stabilizer
Definition MRPolylineDecimate.h:33
float maxEdgeLen
Maximal possible edge length created during decimation.
Definition MRPolylineDecimate.h:28
std::function< void(UndirectedEdgeId ue, float &collapseErrorSq, V &collapsePos)> adjustCollapse
The user can provide this optional callback for adjusting error introduced by this edge collapse and ...
Definition MRPolylineDecimate.h:67
VertBitSet * region
Definition MRPolylineDecimate.h:44
std::function< bool(EdgeId edgeToCollapse, const V &newEdgeOrgPos)> preCollapse
The user can provide this optional callback that is invoked immediately before edge collapse;.
Definition MRPolylineDecimate.h:57
int vertsDeleted
Number deleted verts. Same as the number of performed collapses.
Definition MRPolylineDecimate.h:86
bool touchBdVertices
Definition MRPolylineDecimate.h:49
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Results of MR::decimateContour.
Parameters structure for MR::decimatePolyline.