MeshLib Documentation
Loading...
Searching...
No Matches
Fill/Stitch Holes overview

This chapter represents documentation about hole triangulations or stitching two holes. More...

Classes

struct  MR::FillHoleParams
 Parameters structure for MR::fillHole
Structure has some options to control MR::fillHole. More...
 
struct  MR::StitchHolesParams
 Parameters structure for MR::buildCylinderBetweenTwoHoles
Structure has some options to control MR::buildCylinderBetweenTwoHoles. More...
 
struct  MR::FillHoleItem
 
struct  MR::HoleFillPlan
 concise representation of proposed hole triangulation More...
 
struct  MR::FillHoleMetric
 Holds metrics for fillHole and buildCylinderBetweenTwoHoles triangulation
. More...
 

Typedefs

using MR::FillTriangleMetric = std::function<double( VertId a, VertId b, VertId c )>
 
using MR::FillEdgeMetric = std::function<double( VertId a, VertId b, VertId l, VertId r )>
 
using MR::FillCombineMetric = std::function<double( double, double )>
 

Functions

MRMESH_API void MR::buildCylinderBetweenTwoHoles (Mesh &mesh, EdgeId a, EdgeId b, const StitchHolesParams &params={})
 Stitches two holes in Mesh
.
 
MRMESH_API bool MR::buildCylinderBetweenTwoHoles (Mesh &mesh, const StitchHolesParams &params={})
 this version finds holes in the mesh by itself and returns false if they are not found
 
MRMESH_API void MR::fillHole (Mesh &mesh, EdgeId a, const FillHoleParams &params={})
 Fills hole in mesh
.
 
MRMESH_API void MR::fillHoles (Mesh &mesh, const std::vector< EdgeId > &as, const FillHoleParams &params={})
 fill all holes given by their representative edges in
 
MRMESH_API bool MR::isHoleBd (const MeshTopology &topology, const EdgeLoop &loop)
 
MRMESH_API HoleFillPlan MR::getHoleFillPlan (const Mesh &mesh, EdgeId e, const FillHoleParams &params={})
 
MRMESH_API HoleFillPlan MR::getPlanarHoleFillPlan (const Mesh &mesh, EdgeId e)
 
MRMESH_API void MR::executeHoleFillPlan (Mesh &mesh, EdgeId a0, HoleFillPlan &plan, FaceBitSet *outNewFaces=nullptr)
 quickly triangulates the face or hole to the left of (e) given the plan (quickly compared to fillHole function)
 
MRMESH_API VertId MR::fillHoleTrivially (Mesh &mesh, EdgeId a, FaceBitSet *outNewFaces=nullptr)
 Triangulates face of hole in mesh trivially
.
 
MRMESH_API EdgeId MR::extendHole (Mesh &mesh, EdgeId a, const Plane3f &plane, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API std::vector< EdgeId > MR::extendAllHoles (Mesh &mesh, const Plane3f &plane, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API EdgeId MR::extendHole (Mesh &mesh, EdgeId a, std::function< Vector3f(const Vector3f &)> getVertPos, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API EdgeId MR::buildBottom (Mesh &mesh, EdgeId a, Vector3f dir, float holeExtension, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API EdgeId MR::makeDegenerateBandAroundHole (Mesh &mesh, EdgeId a, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API bool MR::makeBridge (MeshTopology &topology, EdgeId a, EdgeId b, FaceBitSet *outNewFaces=nullptr)
 
MRMESH_API EdgeId MR::makeBridgeEdge (MeshTopology &topology, EdgeId a, EdgeId b)
 
MRMESH_API double MR::calcCombinedFillMetric (const Mesh &mesh, const FaceBitSet &filledRegion, const FillHoleMetric &metric)
 Computes combined metric after filling a hole.
 
MRMESH_API FillHoleMetric MR::getCircumscribedMetric (const Mesh &mesh)
 
MRMESH_API FillHoleMetric MR::getPlaneFillMetric (const Mesh &mesh, EdgeId e)
 
MRMESH_API FillHoleMetric MR::getPlaneNormalizedFillMetric (const Mesh &mesh, EdgeId e)
 
MRMESH_API FillHoleMetric MR::getComplexStitchMetric (const Mesh &mesh)
 
MRMESH_API FillHoleMetric MR::getEdgeLengthFillMetric (const Mesh &mesh)
 Simple metric minimizing the sum of all edge lengths.
 
MRMESH_API FillHoleMetric MR::getEdgeLengthStitchMetric (const Mesh &mesh)
 
MRMESH_API FillHoleMetric MR::getVerticalStitchMetric (const Mesh &mesh, const Vector3f &upDir)
 
MRMESH_API FillHoleMetric MR::getComplexFillMetric (const Mesh &mesh, EdgeId e)
 
MRMESH_API FillHoleMetric MR::getParallelPlaneFillMetric (const Mesh &mesh, EdgeId e, const Plane3f *plane=nullptr)
 This metric minimizes summary projection of new edges to plane normal, (try do produce edges parallel to plane)
 
MRMESH_API FillHoleMetric MR::getMaxDihedralAngleMetric (const Mesh &mesh)
 
MRMESH_API FillHoleMetric MR::getUniversalMetric (const Mesh &mesh)
 
MRMESH_API FillHoleMetric MR::getMinTriAngleMetric (const Mesh &mesh)
 This metric maximizes the minimal angle among all faces in the triangulation.
 
MRMESH_API FillHoleMetric MR::getMinAreaMetric (const Mesh &mesh)
 

Variables

MRMESH_API const double MR::BadTriangulationMetric
 

Detailed Description

This chapter represents documentation about hole triangulations or stitching two holes.

Typedef Documentation

◆ FillCombineMetric

using MR::FillCombineMetric = std::function<double( double, double )>

◆ FillEdgeMetric

using MR::FillEdgeMetric = std::function<double( VertId a, VertId b, VertId l, VertId r )>

◆ FillTriangleMetric

using MR::FillTriangleMetric = std::function<double( VertId a, VertId b, VertId c )>

Function Documentation

◆ buildBottom()

MRMESH_API EdgeId MR::buildBottom ( Mesh & mesh,
EdgeId a,
Vector3f dir,
float holeExtension,
FaceBitSet * outNewFaces = nullptr )

adds cylindrical extension of given hole represented by one of its edges (having no valid left face) by adding new vertices located in lowest point of the hole -dir*holeExtension and 2 * number_of_hole_edge triangles;

Returns
the edge of new hole opposite to input edge (a)

◆ buildCylinderBetweenTwoHoles() [1/2]

MRMESH_API bool MR::buildCylinderBetweenTwoHoles ( Mesh & mesh,
const StitchHolesParams & params = {} )

this version finds holes in the mesh by itself and returns false if they are not found

◆ buildCylinderBetweenTwoHoles() [2/2]

MRMESH_API void MR::buildCylinderBetweenTwoHoles ( Mesh & mesh,
EdgeId a,
EdgeId b,
const StitchHolesParams & params = {} )

Stitches two holes in Mesh
.

Build cylindrical patch to fill space between two holes represented by one of their edges each,
default metric: ComplexStitchMetric

Before
After

Next picture show, how newly generated faces can be smoothed MR::positionVertsSmoothly MR::subdivideMesh

Stitch with smooth
Parameters
meshmesh with hole
aEdgeId which represents 1st hole (should not have valid left FaceId)
bEdgeId which represents 2nd hole (should not have valid left FaceId)
paramsparameters of holes stitching
See also
fillHole
StitchHolesParams

◆ calcCombinedFillMetric()

MRMESH_API double MR::calcCombinedFillMetric ( const Mesh & mesh,
const FaceBitSet & filledRegion,
const FillHoleMetric & metric )

Computes combined metric after filling a hole.

◆ executeHoleFillPlan()

MRMESH_API void MR::executeHoleFillPlan ( Mesh & mesh,
EdgeId a0,
HoleFillPlan & plan,
FaceBitSet * outNewFaces = nullptr )

quickly triangulates the face or hole to the left of (e) given the plan (quickly compared to fillHole function)

◆ extendAllHoles()

MRMESH_API std::vector< EdgeId > MR::extendAllHoles ( Mesh & mesh,
const Plane3f & plane,
FaceBitSet * outNewFaces = nullptr )

adds cylindrical extension of too all holes of the mesh by calling extendHole(...);

Returns
representative edges of one per every hole after extension

◆ extendHole() [1/2]

MRMESH_API EdgeId MR::extendHole ( Mesh & mesh,
EdgeId a,
const Plane3f & plane,
FaceBitSet * outNewFaces = nullptr )

adds cylindrical extension of given hole represented by one of its edges (having no valid left face) by adding new vertices located in given plane and 2 * number_of_hole_edge triangles;

Returns
the edge of new hole opposite to input edge (a)

◆ extendHole() [2/2]

MRMESH_API EdgeId MR::extendHole ( Mesh & mesh,
EdgeId a,
std::function< Vector3f(const Vector3f &)> getVertPos,
FaceBitSet * outNewFaces = nullptr )

adds extension of given hole represented by one of its edges (having no valid left face) by adding new vertices located at getVertPos( existing vertex position );

Returns
the edge of new hole opposite to input edge (a)

◆ fillHole()

MRMESH_API void MR::fillHole ( Mesh & mesh,
EdgeId a,
const FillHoleParams & params = {} )

Fills hole in mesh
.

Fills given hole represented by one of its edges (having no valid left face),
uses fillHoleTrivially if cannot fill hole without multiple edges,
default metric: CircumscribedFillMetric

Before
After

Next picture show, how newly generated faces can be smoothed MR::positionVertsSmoothly MR::subdivideMesh

Fill with smooth
Parameters
meshmesh with hole
aEdgeId which represents hole (should not have valid left FaceId)
paramsparameters of hole filling
See also
buildCylinderBetweenTwoHoles
fillHoleTrivially
FillHoleParams

◆ fillHoles()

MRMESH_API void MR::fillHoles ( Mesh & mesh,
const std::vector< EdgeId > & as,
const FillHoleParams & params = {} )

fill all holes given by their representative edges in

Parameters
as

◆ fillHoleTrivially()

MRMESH_API VertId MR::fillHoleTrivially ( Mesh & mesh,
EdgeId a,
FaceBitSet * outNewFaces = nullptr )

Triangulates face of hole in mesh trivially
.

Fills given hole represented by one of its edges (having no valid left face)
by creating one new vertex in the centroid of boundary vertices and connecting new vertex with all boundary vertices.

Before
After

Next picture show, how newly generated faces can be smoothed MR::positionVertsSmoothly MR::subdivideMesh

Trivial fill with smooth
Parameters
meshmesh with hole
aEdgeId points on the face or hole to the left that will be triangulated
outNewFacesoptional output newly generated faces
Returns
new vertex
See also
fillHole

◆ getCircumscribedMetric()

MRMESH_API FillHoleMetric MR::getCircumscribedMetric ( const Mesh & mesh)

This metric minimizes the sum of circumcircle radii for all triangles in the triangulation. It is rather fast to calculate, and it results in typically good triangulations.

◆ getComplexFillMetric()

MRMESH_API FillHoleMetric MR::getComplexFillMetric ( const Mesh & mesh,
EdgeId e )

This metric minimizes the sum of triangleMetric for all triangles in the triangulation plus the sum edgeMetric for all edges inside and on the boundary of the triangulation.
Where
triangleMetric is proportional to weighted triangle area and triangle aspect ratio
edgeMetric grows with angle between triangles as ( ( 1 - cos( x ) ) / ( 1 + cos( x ) ) ) ^ 4.

◆ getComplexStitchMetric()

MRMESH_API FillHoleMetric MR::getComplexStitchMetric ( const Mesh & mesh)

This metric minimizes the sum of triangleMetric for all triangles in the triangulation plus the sum edgeMetric for all edges inside and on the boundary of the triangulation.
Where
triangleMetric is proportional to triangle aspect ratio
edgeMetric is proportional to ( 1 - dihedralAngleCos )

◆ getEdgeLengthFillMetric()

MRMESH_API FillHoleMetric MR::getEdgeLengthFillMetric ( const Mesh & mesh)

Simple metric minimizing the sum of all edge lengths.

◆ getEdgeLengthStitchMetric()

MRMESH_API FillHoleMetric MR::getEdgeLengthStitchMetric ( const Mesh & mesh)

Forbids connecting vertices from the same hole
Simple metric minimizing edge length

◆ getHoleFillPlan()

MRMESH_API HoleFillPlan MR::getHoleFillPlan ( const Mesh & mesh,
EdgeId e,
const FillHoleParams & params = {} )

prepares the plan how to triangulate the face or hole to the left of (e) (not filling it immediately), several getHoleFillPlan can work in parallel

◆ getMaxDihedralAngleMetric()

MRMESH_API FillHoleMetric MR::getMaxDihedralAngleMetric ( const Mesh & mesh)

This metric minimizes the maximal dihedral angle between the faces in the triangulation and on its boundary

◆ getMinAreaMetric()

MRMESH_API FillHoleMetric MR::getMinAreaMetric ( const Mesh & mesh)

This metric is for triangulation construction with minimal summed area of triangles. Warning: this metric can produce degenerated triangles

◆ getMinTriAngleMetric()

MRMESH_API FillHoleMetric MR::getMinTriAngleMetric ( const Mesh & mesh)

This metric maximizes the minimal angle among all faces in the triangulation.

◆ getParallelPlaneFillMetric()

MRMESH_API FillHoleMetric MR::getParallelPlaneFillMetric ( const Mesh & mesh,
EdgeId e,
const Plane3f * plane = nullptr )

This metric minimizes summary projection of new edges to plane normal, (try do produce edges parallel to plane)

◆ getPlanarHoleFillPlan()

MRMESH_API HoleFillPlan MR::getPlanarHoleFillPlan ( const Mesh & mesh,
EdgeId e )

prepares the plan how to triangulate the planar face or planar hole to the left of (e) (not filling it immediately), several getPlanarHoleFillPlan can work in parallel

◆ getPlaneFillMetric()

MRMESH_API FillHoleMetric MR::getPlaneFillMetric ( const Mesh & mesh,
EdgeId e )

Same as getCircumscribedFillMetric, but with extra penalty for the triangles having normals looking in the opposite side of plane containing left of (e).

◆ getPlaneNormalizedFillMetric()

MRMESH_API FillHoleMetric MR::getPlaneNormalizedFillMetric ( const Mesh & mesh,
EdgeId e )

Similar to getPlaneFillMetric with extra penalty for the triangles having normals looking in the opposite side of plane containing left of (e), but the metric minimizes the sum of circumcircle radius times aspect ratio for all triangles in the triangulation.

◆ getUniversalMetric()

MRMESH_API FillHoleMetric MR::getUniversalMetric ( const Mesh & mesh)

This metric minimizes the maximal dihedral angle between the faces in the triangulation and on its boundary, and it avoids creating too degenerate triangles; for planar holes it is the same as getCircumscribedMetric

◆ getVerticalStitchMetric()

MRMESH_API FillHoleMetric MR::getVerticalStitchMetric ( const Mesh & mesh,
const Vector3f & upDir )

Forbids connecting vertices from the same hole
All new faces should be parallel to given direction

◆ isHoleBd()

MRMESH_API bool MR::isHoleBd ( const MeshTopology & topology,
const EdgeLoop & loop )
nodiscard

returns true if given loop is a boundary of one hole in given mesh topology:

  • every edge in the loop does not have left face,
  • next/prev edges in the loop are related as follows: next = topology.prev( prev.sym() ) if the function returns true, then any edge from the loop passed to fillHole will fill the same hole

◆ makeBridge()

MRMESH_API bool MR::makeBridge ( MeshTopology & topology,
EdgeId a,
EdgeId b,
FaceBitSet * outNewFaces = nullptr )

creates a bridge between two boundary edges a and b (both having no valid left face); bridge consists of two triangles in general or of one triangle if a and b are neighboring edges on the boundary;

Returns
false if bridge cannot be created because otherwise multiple edges appear

◆ makeBridgeEdge()

MRMESH_API EdgeId MR::makeBridgeEdge ( MeshTopology & topology,
EdgeId a,
EdgeId b )

creates a new bridge edge between origins of two boundary edges a and b (both having no valid left face);

Returns
invalid id if bridge cannot be created because otherwise multiple edges appear

◆ makeDegenerateBandAroundHole()

MRMESH_API EdgeId MR::makeDegenerateBandAroundHole ( Mesh & mesh,
EdgeId a,
FaceBitSet * outNewFaces = nullptr )

creates a band of degenerate triangles around given hole;

Returns
the edge of new hole opposite to input edge (a)

Variable Documentation

◆ BadTriangulationMetric

MRMESH_API const double MR::BadTriangulationMetric
extern

Big value, but less then DBL_MAX, to be able to pass some bad triangulations instead of breaking it e10 - real metrics to have weight in triangulation, if it would be more than e15+ some metrics will be less than double precision