Skip to content

Commit 4372454

Browse files
author
Grant Karapetyan
authored
More force options in cut mesh (#1527)
* More force options in cut mesh * Fix comments * update comments
1 parent 38e88af commit 4372454

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

source/MRMesh/MRContoursCut.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ CutMeshResult cutMesh( Mesh& mesh, const OneMeshContours& contours, const CutMes
18441844
fixOrphans( mesh, preRes.paths, preRes.removedFaces, params.new2OldMap );
18451845

18461846
res.fbsWithCountourIntersections = getBadFacesAfterCut( mesh.topology, preRes, preRes.removedFaces );
1847-
if ( !params.forceFillAfterBadCut && res.fbsWithCountourIntersections.count() > 0 )
1847+
if ( params.forceFillMode_ == CutMeshParameters::ForceFill::None && res.fbsWithCountourIntersections.count() > 0 )
18481848
return res;
18491849

18501850
// find one edge for every hole to fill
@@ -1874,7 +1874,8 @@ CutMeshResult cutMesh( Mesh& mesh, const OneMeshContours& contours, const CutMes
18741874
for ( int edgeId = 0; edgeId < path.size(); ++edgeId )
18751875
{
18761876
FaceId oldf = preRes.removedFaces[pathId][edgeId].f;
1877-
if ( !oldf.valid() || res.fbsWithCountourIntersections.test( oldf ) )
1877+
if ( !oldf.valid() ||
1878+
( params.forceFillMode_ == CutMeshParameters::ForceFill::Good && res.fbsWithCountourIntersections.test( oldf ) ) )
18781879
continue;
18791880
if ( oldEdgesInfo[edgeId].hasLeft && !mesh.topology.left( path[edgeId] ).valid() )
18801881
addHoleDesc( path[edgeId], oldf );

source/MRMesh/MRContoursCut.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,16 @@ struct CutMeshParameters
121121
const SortIntersectionsData* sortData{nullptr};
122122
/// This is optional output - map from newly generated faces to old faces (N-1)
123123
FaceMap* new2OldMap{nullptr};
124-
/// If this flag is set, MR::cutMesh will fill all possible triangles, except bad ones; otherwise it will leave deleted faces on all contours line (only in case of bad triangles)
125-
/// \note Bad triangles here mean faces where contours have intersections and cannot be cut and filled in an good way
126-
bool forceFillAfterBadCut{false};
124+
/// This enum defines the MR::cutMesh behaviour in case of bad faces acure
125+
/// basicaly MR::cutMesh removes all faces which contours pass through, adds new edges to topology and fills all removed parts
126+
///
127+
/// \note Bad faces here mean faces where contours have intersections and cannot be cut and filled in an good way
128+
enum class ForceFill
129+
{
130+
None, //< if bad faces occur does not fill anything
131+
Good, //< fills all faces except bad ones
132+
All //< fills all faces with bad ones, but on bad faces triangulation can also be bad (may have self-intersections or tunnels)
133+
} forceFillMode_{ ForceFill::None };
127134
};
128135

129136
/** \struct MR::CutMeshResult

0 commit comments

Comments
 (0)