From 51e4561fd7a259b5dd9e11da91d20c5d50ed695e Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:55:16 +0000 Subject: [PATCH] [PartDesign] Hole, ignore duplicate circle/curve centers (#11773) * [PartDesign] Hole, ignore duplicate circle/curve centers * [PartDesign] Hole correct log output * [PartDesign] Hole changes based on feedback --- src/Mod/PartDesign/App/FeatureHole.cpp | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 1383f2b125..1ed836d493 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -1991,27 +1991,43 @@ TopoDS_Compound Hole::findHoles(const TopoDS_Shape& profileshape, builder.MakeCompound(holes); TopTools_IndexedMapOfShape edgeMap; TopExp::MapShapes(profileshape, TopAbs_EDGE, edgeMap); + int holePointsListSize = 0; + std::vector holePointsList; for (int i = 1; i <= edgeMap.Extent(); i++) { + bool dupCenter = false; Standard_Real c_start; Standard_Real c_end; TopoDS_Edge edge = TopoDS::Edge(edgeMap(i)); Handle(Geom_Curve) c = BRep_Tool::Curve(edge, c_start, c_end); // Circle? - if (c->DynamicType() != STANDARD_TYPE(Geom_Circle)) + if (c->DynamicType() != STANDARD_TYPE(Geom_Circle)) { continue; + } Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(c); gp_Pnt loc = circle->Axis().Location(); + for (auto holePoint : holePointsList) { + if (holePoint.IsEqual(loc, Precision::Confusion())) { + Base::Console().Log( + "PartDesign_Hole - There is a duplicate circle/curve center at %.2f : %.2f " + ": %.2f therefore not passing parameter\n", + loc.X(), + loc.Y(), + loc.Z()); + dupCenter = true; + } + } - gp_Trsf localSketchTransformation; - localSketchTransformation.SetTranslation(gp_Pnt(0, 0, 0), - gp_Pnt(loc.X(), loc.Y(), loc.Z())); - - TopoDS_Shape copy = protohole; - copy.Move(localSketchTransformation); - builder.Add(holes, copy); + if (!dupCenter) { + holePointsList.push_back(loc); + gp_Trsf localSketchTransformation; + localSketchTransformation.SetTranslation(gp_Pnt(0, 0, 0), loc); + TopoDS_Shape copy = protohole; + copy.Move(localSketchTransformation); + builder.Add(holes, copy); + } } return holes;