MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMeshFixer.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRId.h"
5#include "MRExpected.h"
6#include "MRConstants.h"
7#include <cfloat>
8#include <string>
9
10namespace MR
11{
12
16
19
23[[nodiscard]] inline bool hasMultipleEdges( const MeshTopology & topology ) { return !findMultipleEdges( topology ).value().empty(); }
24
26MRMESH_API void fixMultipleEdges( Mesh & mesh, const std::vector<MultipleEdge> & multipleEdges );
29
31[[nodiscard]] MRMESH_API Expected<FaceBitSet> findDegenerateFaces( const MeshPart& mp, float criticalAspectRatio = FLT_MAX, ProgressCallback cb = {} );
32
35[[nodiscard]] MRMESH_API Expected<FaceBitSet> findNotSmoothFaces( const MeshPart& mp, float minAngle = 0.3f, ProgressCallback cb = {} );
36
38[[nodiscard]] MRMESH_API Expected<UndirectedEdgeBitSet> findShortEdges( const MeshPart& mp, float criticalLength, ProgressCallback cb = {} );
39
41{
43 float maxDeviation{ 0.0f };
44
46 float tinyEdgeLength{ 0.0f };
47
51
53 float maxAngleChange{ PI_F / 3 };
54
57 float stabilizer = 1e-6f;
58
60 FaceBitSet* region = nullptr;
61
68
71 bool mimicPatch = false;
72
74};
75
78
80[[nodiscard]] MRMESH_API VertBitSet findInnerVertsOfDegree( const MeshTopology& topology, int n, const VertBitSet* region = nullptr );
81
83[[nodiscard]] MRMESH_API bool isEdgeBetweenDoubleTris( const MeshTopology& topology, EdgeId e );
84
89MRMESH_API EdgeId eliminateDoubleTris( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
90
93MRMESH_API void eliminateDoubleTrisAround( MeshTopology & topology, VertId v, FaceBitSet * region = nullptr );
94
96[[nodiscard]] MRMESH_API bool isDegree3Dest( const MeshTopology& topology, EdgeId e );
97
102MRMESH_API EdgeId eliminateDegree3Dest( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
103
107MRMESH_API int eliminateDegree3Vertices( MeshTopology& topology, VertBitSet & region, FaceBitSet * fs = nullptr );
108
111[[nodiscard]] MRMESH_API EdgeId isVertexRepeatedOnHoleBd( const MeshTopology& topology, VertId v );
112
114[[nodiscard]] MRMESH_API VertBitSet findRepeatedVertsOnHoleBd( const MeshTopology& topology );
115
119[[nodiscard]] MRMESH_API FaceBitSet findHoleComplicatingFaces( const Mesh & mesh );
120
123{
125 float creaseAngle = PI_F * 175.0f / 180.0f;
126
129
131 int maxIters = 10;
132};
133
135MRMESH_API void fixMeshCreases( Mesh& mesh, const FixCreasesParams& params = {} );
136
153
156
157
159
160}
#define MRMESH_API
Definition MRMeshFwd.h:80
Definition MRMeshTopology.h:23
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:758
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::pair< VertId, VertId > VertPair
Definition MRMeshFwd.h:493
int eliminateDegree3Vertices(MeshTopology &topology, VertBitSet &region, FaceBitSet *fs=nullptr)
void fixMeshCreases(Mesh &mesh, const FixCreasesParams &params={})
Finds creases edges and re-triangulates planar areas around them, useful to fix double faces.
Expected< FaceBitSet > findDisorientedFaces(const Mesh &mesh, const FindDisorientationParams &params={})
returns all faces that are oriented inconsistently, based on number of ray intersections
EdgeId eliminateDegree3Dest(MeshTopology &topology, EdgeId e, FaceBitSet *region=nullptr)
bool hasMultipleEdges(const MeshTopology &topology)
Definition MRMeshFixer.h:23
Expected< void > fixMeshDegeneracies(Mesh &mesh, const FixMeshDegeneraciesParams &params)
Fixes degenerate faces and short edges in mesh (changes topology)
VertBitSet findRepeatedVertsOnHoleBd(const MeshTopology &topology)
returns set bits for all vertices present on the boundary of a hole several times;
EdgeId eliminateDoubleTris(MeshTopology &topology, EdgeId e, FaceBitSet *region=nullptr)
Expected< UndirectedEdgeBitSet > findShortEdges(const MeshPart &mp, float criticalLength, ProgressCallback cb={})
finds edges having length <= criticalLength
void fixMultipleEdges(Mesh &mesh, const std::vector< MultipleEdge > &multipleEdges)
resolves given multiple edges, but splitting all but one edge in each group
Expected< FaceBitSet > findNotSmoothFaces(const MeshPart &mp, float minAngle=0.3f, ProgressCallback cb={})
bool isEdgeBetweenDoubleTris(const MeshTopology &topology, EdgeId e)
returns true if the edge e has both left and right triangular faces and the degree of dest( e ) is 2
EdgeId isVertexRepeatedOnHoleBd(const MeshTopology &topology, VertId v)
bool isDegree3Dest(const MeshTopology &topology, EdgeId e)
returns true if the destination of given edge has degree 3 and 3 incident triangles
Expected< std::vector< MultipleEdge > > findMultipleEdges(const MeshTopology &topology, ProgressCallback cb={})
VertBitSet findInnerVertsOfDegree(const MeshTopology &topology, int n, const VertBitSet *region=nullptr)
finds all inner vertices in region with the given number of incident edges each
int duplicateMultiHoleVertices(Mesh &mesh)
Duplicates all vertices having more than two boundary edges (and returns the number of duplications);...
VertPair MultipleEdge
finds multiple edges in the mesh
Definition MRMeshFixer.h:21
void eliminateDoubleTrisAround(MeshTopology &topology, VertId v, FaceBitSet *region=nullptr)
Expected< FaceBitSet > findDegenerateFaces(const MeshPart &mp, float criticalAspectRatio=FLT_MAX, ProgressCallback cb={})
finds faces having aspect ratio >= criticalAspectRatio
FaceBitSet findHoleComplicatingFaces(const Mesh &mesh)
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Parameters for findDisorientedFaces function.
Definition MRMeshFixer.h:139
ProgressCallback cb
Definition MRMeshFixer.h:151
RayMode
Mode of detecting disoriented face.
Definition MRMeshFixer.h:142
@ Both
both direction should have correct number of intersections (positive - even; negative - odd)
Definition MRMeshFixer.h:145
@ Positive
positive (normal) direction of face should have even number of intersections
Definition MRMeshFixer.h:143
@ Shallowest
positive or negative (normal or -normal) direction (the one with lowest number of intersections) shou...
Definition MRMeshFixer.h:144
enum MR::FindDisorientationParams::RayMode Shallowest
bool virtualFillHoles
if set - copy mesh, and fills holes for better quality in case of ray going out through hole
Definition MRMeshFixer.h:149
Parameters structure for fixMeshCreases function.
Definition MRMeshFixer.h:123
float criticalTriAspectRatio
planar check is skipped for faces with worse aspect ratio
Definition MRMeshFixer.h:128
int maxIters
maximum number of algorithm iterations
Definition MRMeshFixer.h:131
float creaseAngle
edges with dihedral angle sharper this will be considered as creases
Definition MRMeshFixer.h:125
Definition MRMeshFixer.h:41
FaceBitSet * region
degenerations will be fixed only in given region, it is updated during the operation
Definition MRMeshFixer.h:60
ProgressCallback cb
Definition MRMeshFixer.h:73
float maxDeviation
maximum permitted deviation from the original surface
Definition MRMeshFixer.h:43
float maxAngleChange
Permit edge flips if it does not change dihedral angle more than on this value.
Definition MRMeshFixer.h:53
bool mimicPatch
Definition MRMeshFixer.h:71
enum MR::FixMeshDegeneraciesParams::Mode Remesh
Mode
Definition MRMeshFixer.h:63
@ Remesh
if decimation does not succeed, perform subdivision too
Definition MRMeshFixer.h:65
@ Decimate
use decimation only to fix degeneracies
Definition MRMeshFixer.h:64
@ RemeshPatch
if both decimation and subdivision does not succeed, removes degenerate areas and fills occurred hole...
Definition MRMeshFixer.h:66
float criticalTriAspectRatio
Definition MRMeshFixer.h:50
float tinyEdgeLength
edges not longer than this value will be collapsed ignoring normals and aspect ratio checks
Definition MRMeshFixer.h:46
float stabilizer
Definition MRMeshFixer.h:57
Definition MRMesh.h:23