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
35MRMESH_API void fixMultipleEdges( Mesh & mesh, const std::vector<MultipleEdge> & multipleEdges, FaceHashMap * new2Old = nullptr );
38
40[[nodiscard]] MRMESH_API Expected<FaceBitSet> findDegenerateFaces( const MeshPart& mp, float criticalAspectRatio = FLT_MAX, ProgressCallback cb = {} );
41
44[[nodiscard]] MRMESH_API Expected<FaceBitSet> findNotSmoothFaces( const MeshPart& mp, float minAngle = 0.3f, ProgressCallback cb = {} );
45
47[[nodiscard]] MRMESH_API Expected<UndirectedEdgeBitSet> findShortEdges( const MeshPart& mp, float criticalLength, ProgressCallback cb = {} );
48
50MRMESH_API void deleteFacesWithLongEdges( Mesh& mesh, float maxEdgeLength );
51
53{
55 float maxDeviation{ 0.0f };
56
58 float tinyEdgeLength{ 0.0f };
59
63
65 float maxAngleChange{ PI_F / 3 };
66
69 float stabilizer = 1e-6f;
70
72 FaceBitSet* region = nullptr;
73
80
83 bool mimicPatch = false;
84
90
92};
93
96
103
105[[nodiscard]] MRMESH_API VertBitSet findInnerVertsOfDegree( const MeshTopology& topology, int n, const VertBitSet* region = nullptr );
106
108[[nodiscard]] MRMESH_API bool isEdgeBetweenDoubleTris( const MeshTopology& topology, EdgeId e );
109
117MRMESH_API EdgeId eliminateDoubleTris( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr, bool eliminatePillows = false );
118
121MRMESH_API void eliminateDoubleTrisAround( MeshTopology & topology, VertId v, FaceBitSet * region = nullptr );
122
124[[nodiscard]] MRMESH_API bool isDegree3Dest( const MeshTopology& topology, EdgeId e );
125
130MRMESH_API EdgeId eliminateDegree3Dest( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
131
135MRMESH_API int eliminateDegree3Vertices( MeshTopology& topology, VertBitSet & region, FaceBitSet * fs = nullptr );
136
139[[nodiscard]] MRMESH_API EdgeId isVertexRepeatedOnHoleBd( const MeshTopology& topology, VertId v );
140
142[[nodiscard]] MRMESH_API VertBitSet findRepeatedVertsOnHoleBd( const MeshTopology& topology );
143
147[[nodiscard]] MRMESH_API FaceBitSet findHoleComplicatingFaces( const Mesh & mesh );
148
151{
153 float creaseAngle = PI_F * 175.0f / 180.0f;
154
157
159 int maxIters = 10;
160};
161
163MRMESH_API void fixMeshCreases( Mesh& mesh, const FixCreasesParams& params = {} );
164
181
184
185
187
188}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRMeshTopology.h:31
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:790
tl::expected< T, E > Expected
Definition MRExpected.h:31
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMeshFwd.h:635
std::pair< VertId, VertId > VertPair
Definition MRMeshFwd.h:500
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)
EdgeId eliminateDoubleTris(MeshTopology &topology, EdgeId e, FaceBitSet *region=nullptr, bool eliminatePillows=false)
VertBitSet findRepeatedVertsOnHoleBd(const MeshTopology &topology)
returns set bits for all vertices present on the boundary of a hole several times;
Expected< UndirectedEdgeBitSet > findShortEdges(const MeshPart &mp, float criticalLength, ProgressCallback cb={})
finds edges having length <= criticalLength
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)
void fixMultipleEdges(Mesh &mesh, const std::vector< MultipleEdge > &multipleEdges, FaceHashMap *new2Old=nullptr)
VertPair MultipleEdge
finds multiple edges in the mesh
Definition MRMeshFixer.h:29
Expected< void > fixMeshDataDegeneracies(ObjectMeshData &data, const FixMeshDegeneraciesParams &params)
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 strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Parameters for findDisorientedFaces function.
Definition MRMeshFixer.h:167
ProgressCallback cb
Definition MRMeshFixer.h:179
RayMode
Mode of detecting disoriented face.
Definition MRMeshFixer.h:170
@ Both
both direction should have correct number of intersections (positive - even; negative - odd)
Definition MRMeshFixer.h:173
@ Positive
positive (normal) direction of face should have even number of intersections
Definition MRMeshFixer.h:171
@ Shallowest
positive or negative (normal or -normal) direction (the one with lowest number of intersections) shou...
Definition MRMeshFixer.h:172
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:177
Parameters structure for fixMeshCreases function.
Definition MRMeshFixer.h:151
float criticalTriAspectRatio
planar check is skipped for faces with worse aspect ratio
Definition MRMeshFixer.h:156
int maxIters
maximum number of algorithm iterations
Definition MRMeshFixer.h:159
float creaseAngle
edges with dihedral angle sharper this will be considered as creases
Definition MRMeshFixer.h:153
Definition MRMeshFixer.h:53
FaceBitSet * region
degenerations will be fixed only in given region, it is updated during the operation
Definition MRMeshFixer.h:72
ProgressCallback cb
Definition MRMeshFixer.h:91
float maxDeviation
maximum permitted deviation from the original surface
Definition MRMeshFixer.h:55
float maxAngleChange
Permit edge flips if it does not change dihedral angle more than on this value.
Definition MRMeshFixer.h:65
bool protectAttributeBorders
Definition MRMeshFixer.h:89
bool mimicPatch
Definition MRMeshFixer.h:83
enum MR::FixMeshDegeneraciesParams::Mode Remesh
Mode
Definition MRMeshFixer.h:75
@ Remesh
if decimation does not succeed, perform subdivision too
Definition MRMeshFixer.h:77
@ Decimate
use decimation only to fix degeneracies
Definition MRMeshFixer.h:76
@ RemeshPatch
if both decimation and subdivision does not succeed, removes degenerate areas and fills occurred hole...
Definition MRMeshFixer.h:78
float criticalTriAspectRatio
Definition MRMeshFixer.h:62
float tinyEdgeLength
edges not longer than this value will be collapsed ignoring normals and aspect ratio checks
Definition MRMeshFixer.h:58
float stabilizer
Definition MRMeshFixer.h:69
Definition MRMesh.h:24
mesh and its per-element attributes for ObjectMeshHolder
Definition MRObjectMeshData.h:17