From 34a4da7c04fd425eeaa379051ca9b8f5ac8c103f Mon Sep 17 00:00:00 2001 From: bgbsww Date: Sat, 21 Sep 2024 15:35:00 -0400 Subject: [PATCH] Update method names and clean --- src/Mod/PartDesign/App/FeatureHole.cpp | 36 ++++++++++--------- .../SketcherTests/TestSketcherSolver.py | 6 ++-- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 0fe227c413049..436e0a6ba57d3 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -51,10 +51,14 @@ #include #include #include +#include +#include #include "FeatureHole.h" #include "json.hpp" +FC_LOG_LEVEL_INIT("PartDesign", true, true); + namespace PartDesign { /* TRANSLATOR PartDesign::Hole */ @@ -1885,19 +1889,17 @@ App::DocumentObjectExecReturn* Hole::execute() std::vector holes; auto compound = findHoles(holes, profileshape, protoHole); - TopoShape result(0,getDocument()->getStringHasher()); + TopoShape result(0); // set the subtractive shape property for later usage in e.g. pattern this->AddSubShape.setValue(compound); - if (isRecomputePaused()) - return App::DocumentObject::StdReturn; if (base.isNull()) { Shape.setValue(compound); return App::DocumentObject::StdReturn; } - // First try cuting with compound which will be faster as it is done in + // First try cutting with compound which will be faster as it is done in // parallel bool retry = true; const char *maker; @@ -1905,9 +1907,6 @@ App::DocumentObjectExecReturn* Hole::execute() case Additive: maker = Part::OpCodes::Fuse; break; - case Intersecting: - maker = Part::OpCodes::Common; - break; default: maker = Part::OpCodes::Cut; } @@ -1915,7 +1914,7 @@ App::DocumentObjectExecReturn* Hole::execute() if (base.isNull()) result = compound; else - result.makEBoolean(maker, {base,compound}); + result.makeElementBoolean(maker, {base,compound}); result = getSolid(result); retry = false; } catch (Standard_Failure & e) { @@ -1931,20 +1930,20 @@ App::DocumentObjectExecReturn* Hole::execute() for (auto & hole : holes) { ++i; try { - result.makEBoolean(maker, {base,hole}); + result.makeElementBoolean(maker, {base,hole}); } catch (Standard_Failure &) { std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation failed on profile Edge")); msg += std::to_string(i); return new App::DocumentObjectExecReturn(msg.c_str()); } catch (Base::Exception &e) { e.ReportException(); - std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operataion failed on profile Edge")); + std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation failed on profile Edge")); msg += std::to_string(i); return new App::DocumentObjectExecReturn(msg.c_str()); } base = getSolid(result); if (base.isNull()) { - std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operataion produced non-solid on profile Edge")); + std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation produced non-solid on profile Edge")); msg += std::to_string(i); return new App::DocumentObjectExecReturn(msg.c_str()); } @@ -1952,6 +1951,9 @@ App::DocumentObjectExecReturn* Hole::execute() result = base; } + if (!isSingleSolidRuleSatisfied(result.getShape())) { + return new App::DocumentObjectExecReturn( + QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported.")); this->Shape.setValue(result); return App::DocumentObject::StdReturn; @@ -2030,7 +2032,7 @@ TopoShape Hole::findHoles(std::vector &holes, const TopoShape& profileshape, const TopoDS_Shape& protoHole) const { - TopoShape result(0,getDocument()->getStringHasher()); + TopoShape result(0); int i = 0; for(const auto &profileEdge : profileshape.getSubTopoShapes(TopAbs_EDGE)) { @@ -2053,16 +2055,16 @@ TopoShape Hole::findHoles(std::vector &holes, gp_Pnt(loc.X(), loc.Y(), loc.Z()) ); Part::ShapeMapper mapper; - mapper.populate(true, profileEdge, TopoShape(protoHole).getSubTopoShapes(TopAbs_FACE)); + mapper.populate(Part::MappingStatus::Modified, profileEdge, TopoShape(protoHole).getSubTopoShapes(TopAbs_FACE)); - TopoShape hole(-getID(), getDocument()->getStringHasher()); - hole.makESHAPE(protoHole, mapper, {profileEdge}); + TopoShape hole(-getID()); + hole.makeShapeWithElementMap(protoHole, mapper, {profileEdge}); // transform and generate element map. - hole = hole.makETransform(localSketchTransformation); + hole = hole.makeElementTransform(localSketchTransformation); holes.push_back(hole); } - return TopoShape().makECompound(holes); + return TopoShape().makeElementCompound(holes); } TopoDS_Shape Hole::makeThread(const gp_Vec& xDir, const gp_Vec& zDir, double length) diff --git a/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py b/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py index fdf02d6477c45..e9936cf61e2cb 100644 --- a/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py +++ b/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py @@ -520,7 +520,7 @@ def testRemovedExternalGeometryReference(self): hole.DrillForDepth = 0 hole.Tapered = 0 self.Doc.recompute() - self.assertEqual(len(hole.Shape.Edges), 12) + self.assertEqual(len(hole.Shape.Edges), 13) hole.Threaded = True hole.ModelThread = True body.addObject(hole) @@ -530,11 +530,11 @@ def testRemovedExternalGeometryReference(self): body.addObject(sketch2) self.Doc.recompute() sketch2.addExternal("Hole", "Edge29") # Edge29 will disappear when we stop modeling threads - self.assertEqual(len(hole.Shape.Edges), 32) + self.assertEqual(len(hole.Shape.Edges), 38) hole.ModelThread = False hole.Refine = True self.Doc.recompute() - self.assertEqual(len(hole.Shape.Edges), 32) + self.assertEqual(len(hole.Shape.Edges), 38) self.assertEqual(len(sketch2.ExternalGeometry), 1) def testSaveLoadWithExternalGeometryReference(self):