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
20
26MRMESH_API int duplicateMultiHoleVertices( Mesh & mesh, int maxHoles, std::vector<MeshBuilder::VertDuplication> * dups = nullptr );
27
31[[nodiscard]] inline bool hasMultipleEdges( const MeshTopology & topology ) { return !findMultipleEdges( topology ).value().empty(); }
32
34MRMESH_API void fixMultipleEdges( Mesh & mesh, const std::vector<MultipleEdge> & multipleEdges );
37
39[[nodiscard]] MRMESH_API Expected<FaceBitSet> findDegenerateFaces( const MeshPart& mp, float criticalAspectRatio = FLT_MAX, ProgressCallback cb = {} );
40
43[[nodiscard]] MRMESH_API Expected<FaceBitSet> findNotSmoothFaces( const MeshPart& mp, float minAngle = 0.3f, ProgressCallback cb = {} );
44
46[[nodiscard]] MRMESH_API Expected<UndirectedEdgeBitSet> findShortEdges( const MeshPart& mp, float criticalLength, ProgressCallback cb = {} );
47
49MRMESH_API void deleteFacesWithLongEdges( Mesh& mesh, float maxEdgeLength );
50
52{
54 float maxDeviation{ 0.0f };
55
57 float tinyEdgeLength{ 0.0f };
58
62
64 float maxAngleChange{ PI_F / 3 };
65
68 float stabilizer = 1e-6f;
69
71 FaceBitSet* region = nullptr;
72
79
82 bool mimicPatch = false;
83
85};
86
89
91[[nodiscard]] MRMESH_API VertBitSet findInnerVertsOfDegree( const MeshTopology& topology, int n, const VertBitSet* region = nullptr );
92
94[[nodiscard]] MRMESH_API bool isEdgeBetweenDoubleTris( const MeshTopology& topology, EdgeId e );
95
100MRMESH_API EdgeId eliminateDoubleTris( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
101
104MRMESH_API void eliminateDoubleTrisAround( MeshTopology & topology, VertId v, FaceBitSet * region = nullptr );
105
107[[nodiscard]] MRMESH_API bool isDegree3Dest( const MeshTopology& topology, EdgeId e );
108
113MRMESH_API EdgeId eliminateDegree3Dest( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
114
118MRMESH_API int eliminateDegree3Vertices( MeshTopology& topology, VertBitSet & region, FaceBitSet * fs = nullptr );
119
122[[nodiscard]] MRMESH_API EdgeId isVertexRepeatedOnHoleBd( const MeshTopology& topology, VertId v );
123
125[[nodiscard]] MRMESH_API VertBitSet findRepeatedVertsOnHoleBd( const MeshTopology& topology );
126
130[[nodiscard]] MRMESH_API FaceBitSet findHoleComplicatingFaces( const Mesh & mesh );
131
134{
136 float creaseAngle = PI_F * 175.0f / 180.0f;
137
140
142 int maxIters = 10;
143};
144
146MRMESH_API void fixMeshCreases( Mesh& mesh, const FixCreasesParams& params = {} );
147
164
167
168
170
171}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRMeshTopology.h:30
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:759
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::pair< VertId, VertId > VertPair
Definition MRMeshFwd.h:489
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.
void deleteFacesWithLongEdges(Mesh &mesh, float maxEdgeLength)
deletes all faces having at least one edge longer than maxEdgeLength
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:31
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)
VertPair MultipleEdge
finds multiple edges in the mesh
Definition MRMeshFixer.h:29
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:150
ProgressCallback cb
Definition MRMeshFixer.h:162
RayMode
Mode of detecting disoriented face.
Definition MRMeshFixer.h:153
@ Both
both direction should have correct number of intersections (positive - even; negative - odd)
Definition MRMeshFixer.h:156
@ Positive
positive (normal) direction of face should have even number of intersections
Definition MRMeshFixer.h:154
@ Shallowest
positive or negative (normal or -normal) direction (the one with lowest number of intersections) shou...
Definition MRMeshFixer.h:155
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:160
Parameters structure for fixMeshCreases function.
Definition MRMeshFixer.h:134
float criticalTriAspectRatio
planar check is skipped for faces with worse aspect ratio
Definition MRMeshFixer.h:139
int maxIters
maximum number of algorithm iterations
Definition MRMeshFixer.h:142
float creaseAngle
edges with dihedral angle sharper this will be considered as creases
Definition MRMeshFixer.h:136
Definition MRMeshFixer.h:52
FaceBitSet * region
degenerations will be fixed only in given region, it is updated during the operation
Definition MRMeshFixer.h:71
ProgressCallback cb
Definition MRMeshFixer.h:84
float maxDeviation
maximum permitted deviation from the original surface
Definition MRMeshFixer.h:54
float maxAngleChange
Permit edge flips if it does not change dihedral angle more than on this value.
Definition MRMeshFixer.h:64
bool mimicPatch
Definition MRMeshFixer.h:82
enum MR::FixMeshDegeneraciesParams::Mode Remesh
Mode
Definition MRMeshFixer.h:74
@ Remesh
if decimation does not succeed, perform subdivision too
Definition MRMeshFixer.h:76
@ Decimate
use decimation only to fix degeneracies
Definition MRMeshFixer.h:75
@ RemeshPatch
if both decimation and subdivision does not succeed, removes degenerate areas and fills occurred hole...
Definition MRMeshFixer.h:77
float criticalTriAspectRatio
Definition MRMeshFixer.h:61
float tinyEdgeLength
edges not longer than this value will be collapsed ignoring normals and aspect ratio checks
Definition MRMeshFixer.h:57
float stabilizer
Definition MRMeshFixer.h:68
Definition MRMesh.h:24