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
114[[nodiscard]] MRMESH_API FaceBitSet findDisorientedFaces( const Mesh& mesh );
115
116
118
119} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
Definition MRMesh/MRMeshTopology.h:18
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:641
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 FaceBitSet findDisorientedFaces(const Mesh &mesh)
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 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)
tl::expected< T, E > Expected
Definition MRExpected.h:59
std::pair< VertId, VertId > VertPair
Definition MRMesh/MRMeshFwd.h:413
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