MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/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
34[[nodiscard]] MRMESH_API Expected<UndirectedEdgeBitSet> findShortEdges( const MeshPart& mp, float criticalLength, ProgressCallback cb = {} );
35
37{
39 float maxDeviation{ 0.0f };
40
42 float tinyEdgeLength{ 0.0f };
43
47
49 float maxAngleChange{ PI_F / 3 };
50
53 float stabilizer = 1e-6f;
54
56 FaceBitSet* region = nullptr;
57
58 enum class Mode
59 {
60 Decimate,
61 Remesh,
63 } mode{ Mode::Remesh };
64
66};
67
70
72[[nodiscard]] MRMESH_API VertBitSet findNRingVerts( const MeshTopology& topology, int n, const VertBitSet* region = nullptr );
73
75[[nodiscard]] MRMESH_API bool isEdgeBetweenDoubleTris( const MeshTopology& topology, EdgeId e );
76
81MRMESH_API EdgeId eliminateDoubleTris( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
82
85MRMESH_API void eliminateDoubleTrisAround( MeshTopology & topology, VertId v, FaceBitSet * region = nullptr );
86
88[[nodiscard]] MRMESH_API bool isDegree3Dest( const MeshTopology& topology, EdgeId e );
89
94MRMESH_API EdgeId eliminateDegree3Dest( MeshTopology& topology, EdgeId e, FaceBitSet * region = nullptr );
95
99MRMESH_API int eliminateDegree3Vertices( MeshTopology& topology, VertBitSet & region, FaceBitSet * fs = nullptr );
100
103[[nodiscard]] MRMESH_API EdgeId isVertexRepeatedOnHoleBd( const MeshTopology& topology, VertId v );
104
106[[nodiscard]] MRMESH_API VertBitSet findRepeatedVertsOnHoleBd( const MeshTopology& topology );
107
111[[nodiscard]] MRMESH_API FaceBitSet findHoleComplicatingFaces( const Mesh & mesh );
112
115{
117 float creaseAngle = PI_F * 175.0f / 180.0f;
118
121
123 int maxIters = 10;
124};
125
127MRMESH_API void fixMeshCreases( Mesh& mesh, const FixCreasesParams& params = {} );
128
131{
133 enum class RayMode
134 {
135 Positive,
136 Shallowest,
137 Both
139
141 bool virtualFillHoles{ false };
142
144};
145
148
149
151
152} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
Definition MRMesh/MRMeshTopology.h:18
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:663
MRMESH_API int duplicateMultiHoleVertices(Mesh &mesh)
Duplicates all vertices having more than two boundary edges (and returns the number of duplications);...
bool hasMultipleEdges(const MeshTopology &topology)
Definition MRMesh/MRMeshFixer.h:23
MRMESH_API Expected< FaceBitSet > findDegenerateFaces(const MeshPart &mp, float criticalAspectRatio=FLT_MAX, ProgressCallback cb={})
finds faces having aspect ratio >= criticalAspectRatio
MRMESH_API VertBitSet findNRingVerts(const MeshTopology &topology, int n, const VertBitSet *region=nullptr)
finds vertices in region with complete ring of N edges
MRMESH_API FaceBitSet findHoleComplicatingFaces(const Mesh &mesh)
MRMESH_API bool isDegree3Dest(const MeshTopology &topology, EdgeId e)
returns true if the destination of given edge has degree 3 and 3 incident triangles
MRMESH_API Expected< FaceBitSet > findDisorientedFaces(const Mesh &mesh, const FindDisorientationParams &params={})
returns all faces that are oriented inconsistently, based on number of ray intersections
MRMESH_API 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
MRMESH_API int eliminateDegree3Vertices(MeshTopology &topology, VertBitSet &region, FaceBitSet *fs=nullptr)
MRMESH_API VertBitSet findRepeatedVertsOnHoleBd(const MeshTopology &topology)
returns set bits for all vertices present on the boundary of a hole several times;
MRMESH_API EdgeId isVertexRepeatedOnHoleBd(const MeshTopology &topology, VertId v)
MRMESH_API void fixMeshCreases(Mesh &mesh, const FixCreasesParams &params={})
Finds creases edges and re-triangulates planar areas around them, useful to fix double faces.
MRMESH_API EdgeId eliminateDoubleTris(MeshTopology &topology, EdgeId e, FaceBitSet *region=nullptr)
VertPair MultipleEdge
finds multiple edges in the mesh
Definition MRMesh/MRMeshFixer.h:21
MRMESH_API EdgeId eliminateDegree3Dest(MeshTopology &topology, EdgeId e, FaceBitSet *region=nullptr)
MRMESH_API Expected< void > fixMeshDegeneracies(Mesh &mesh, const FixMeshDegeneraciesParams &params)
Fixes degenerate faces and short edges in mesh (changes topology)
MRMESH_API Expected< std::vector< MultipleEdge > > findMultipleEdges(const MeshTopology &topology, ProgressCallback cb={})
MRMESH_API Expected< UndirectedEdgeBitSet > findShortEdges(const MeshPart &mp, float criticalLength, ProgressCallback cb={})
finds edges having length <= criticalLength
MRMESH_API void fixMultipleEdges(Mesh &mesh, const std::vector< MultipleEdge > &multipleEdges)
resolves given multiple edges, but splitting all but one edge in each group
MRMESH_API void eliminateDoubleTrisAround(MeshTopology &topology, VertId v, FaceBitSet *region=nullptr)
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:425
Parameters for findDisorientedFaces function.
Definition MRMesh/MRMeshFixer.h:131
ProgressCallback cb
Definition MRMesh/MRMeshFixer.h:143
RayMode
Mode of detecting disoriented face.
Definition MRMesh/MRMeshFixer.h:134
@ Both
both direction should have correct number of intersections (positive - even; negative - odd)
@ Positive
positive (normal) direction of face should have even number of intersections
@ Shallowest
positive or negative (normal or -normal) direction (the one with lowest number of intersections) shou...
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 MRMesh/MRMeshFixer.h:141
Parameters structure for fixMeshCreases function.
Definition MRMesh/MRMeshFixer.h:115
float criticalTriAspectRatio
planar check is skipped for faces with worse aspect ratio
Definition MRMesh/MRMeshFixer.h:120
int maxIters
maximum number of algorithm iterations
Definition MRMesh/MRMeshFixer.h:123
float creaseAngle
edges with dihedral angle sharper this will be considered as creases
Definition MRMesh/MRMeshFixer.h:117
Definition MRMesh/MRMeshFixer.h:37
FaceBitSet * region
degenerations will be fixed only in given region, it is updated during the operation
Definition MRMesh/MRMeshFixer.h:56
ProgressCallback cb
Definition MRMesh/MRMeshFixer.h:65
float maxDeviation
maximum permitted deviation from the original surface
Definition MRMesh/MRMeshFixer.h:39
float maxAngleChange
Permit edge flips if it does not change dihedral angle more than on this value.
Definition MRMesh/MRMeshFixer.h:49
enum MR::FixMeshDegeneraciesParams::Mode Remesh
Mode
Definition MRMesh/MRMeshFixer.h:59
@ Remesh
if decimation does not succeed, perform subdivision too
@ Decimate
use decimation only to fix degeneracies
@ RemeshPatch
if both decimation and subdivision does not succeed, removes degenerate areas and fills occurred hole...
float criticalTriAspectRatio
Definition MRMesh/MRMeshFixer.h:46
float tinyEdgeLength
edges not longer than this value will be collapsed ignoring normals and aspect ratio checks
Definition MRMesh/MRMeshFixer.h:42
float stabilizer
Definition MRMesh/MRMeshFixer.h:53
Definition MRMesh/MRMesh.h:22