From 5f40d892d205afde10de0c584e68b4ab5df32a01 Mon Sep 17 00:00:00 2001 From: Dmitrii Kulikov <164657232+AtheneNoctuaPt@users.noreply.github.com> Date: Thu, 27 Nov 2025 13:38:35 +0000 Subject: [PATCH] Modeling - BRepFilletAPI_MakeFillet::Add hangs on adding edge (#859) - Refactored the `ReorderFaces` function to iterate through all edges at a vertex instead of assuming only two edges exist - Replaced manual face swapping with `std::swap` for cleaner code - Removed debug output statements and unused debug declarations --- .../TKFillet/ChFi3d/ChFi3d_Builder_1.cxx | 70 ++++++++----------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx index aaa9601fb0..cae5872ad7 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFi3d/ChFi3d_Builder_1.cxx @@ -61,10 +61,6 @@ #include #include -#ifdef OCCT_DEBUG -extern Standard_Boolean ChFi3d_GetcontextFORCEBLEND(); -#endif - static void ReorderFaces(TopoDS_Face& theF1, TopoDS_Face& theF2, const TopoDS_Face& theFirstFace, @@ -73,53 +69,49 @@ static void ReorderFaces(TopoDS_Face& theF1, const ChFiDS_Map& theEFmap) { if (theF1.IsSame(theFirstFace)) + { return; + } else if (theF2.IsSame(theFirstFace)) { - TopoDS_Face TmpFace = theF1; - theF1 = theF2; - theF2 = TmpFace; + std::swap(theF1, theF2); return; } // Loop until find or - Standard_Boolean ToExchange = Standard_False; - TopoDS_Edge PrevEdge = thePrevEdge, CurEdge; - TopoDS_Face PrevFace = theFirstFace, CurFace; + TopoDS_Edge PrevEdge = thePrevEdge; + TopoDS_Edge CurEdge; + TopoDS_Face PrevFace = theFirstFace; + TopoDS_Face CurFace; for (;;) { - TopTools_IndexedDataMapOfShapeListOfShape VEmap; - TopExp::MapShapesAndAncestors(PrevFace, TopAbs_VERTEX, TopAbs_EDGE, VEmap); - const TopTools_ListOfShape& Elist = VEmap.FindFromKey(theCommonVertex); - if (PrevEdge.IsSame(Elist.First())) - CurEdge = TopoDS::Edge(Elist.Last()); - else - CurEdge = TopoDS::Edge(Elist.First()); - - const TopTools_ListOfShape& Flist = theEFmap.FindFromKey(CurEdge); - if (PrevFace.IsSame(Flist.First())) - CurFace = TopoDS::Face(Flist.Last()); - else - CurFace = TopoDS::Face(Flist.First()); - - if (CurFace.IsSame(theF1)) - break; - else if (CurFace.IsSame(theF2)) + TopTools_IndexedDataMapOfShapeListOfShape aVertexEdgeMap; + TopExp::MapShapesAndAncestors(PrevFace, TopAbs_VERTEX, TopAbs_EDGE, aVertexEdgeMap); + for (const auto& anEdge : aVertexEdgeMap.FindFromKey(theCommonVertex)) { - ToExchange = Standard_True; - break; + if (anEdge.IsSame(PrevEdge)) + { + continue; + } + + CurEdge = TopoDS::Edge(anEdge); + const TopTools_ListOfShape& Flist = theEFmap.FindFromKey(CurEdge); + CurFace = PrevFace.IsSame(TopoDS::Face(Flist.First())) ? TopoDS::Face(Flist.Last()) + : TopoDS::Face(Flist.First()); + if (CurFace.IsSame(theF1)) + { + return; + } + else if (CurFace.IsSame(theF2)) + { + std::swap(theF1, theF2); + return; + } } PrevEdge = CurEdge; PrevFace = CurFace; } - - if (ToExchange) - { - TopoDS_Face TmpFace = theF1; - theF1 = theF2; - theF2 = TmpFace; - } } static void ConcatCurves(TColGeom_SequenceOfCurve& theCurves, @@ -787,9 +779,6 @@ void ChFi3d_Builder::PerformExtremity(const Handle(ChFiDS_Spine)& Spine) if (nbf > 3) { Spine->SetFirstStatus(ChFiDS_BreakPoint); -#ifdef OCCT_DEBUG - std::cout << "top has : " << nbf << " faces." << std::endl; -#endif } nbf = 0, jf = 0; for (It.Initialize(myVFMap(Spine->LastVertex())); It.More(); It.Next()) @@ -809,9 +798,6 @@ void ChFi3d_Builder::PerformExtremity(const Handle(ChFiDS_Spine)& Spine) if (nbf > 3) { Spine->SetLastStatus(ChFiDS_BreakPoint); -#ifdef OCCT_DEBUG - std::cout << "top has : " << nbf << " faces." << std::endl; -#endif } } } -- 2.39.5