From 86b1c2e863787318227bbdddcff4538121a4b89d Mon Sep 17 00:00:00 2001 From: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:50:42 +0200 Subject: [PATCH] Activate Part/Part Design check and refine preferences by default (#14406) * Activate Part/Part Design check and refine preferences by default * added bool in .ui * Update tests * Fix Sketcher tests --- src/Mod/Part/App/FeaturePartBoolean.cpp | 2 +- src/Mod/Part/App/FeaturePartCommon.cpp | 4 ++-- src/Mod/Part/App/FeaturePartFuse.cpp | 4 ++-- src/Mod/Part/Gui/DlgSettingsGeneral.ui | 9 +++++++++ src/Mod/PartDesign/App/FeatureAddSub.cpp | 2 +- src/Mod/PartDesign/App/FeatureBoolean.cpp | 2 +- src/Mod/PartDesign/App/FeatureTransformed.cpp | 11 ++++------- src/Mod/PartDesign/App/ShapeBinder.cpp | 2 +- .../PartDesignTests/TestTopologicalNamingProblem.py | 2 +- src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py | 6 +++--- 10 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/Mod/Part/App/FeaturePartBoolean.cpp b/src/Mod/Part/App/FeaturePartBoolean.cpp index c5ac261543..f109406d3d 100644 --- a/src/Mod/Part/App/FeaturePartBoolean.cpp +++ b/src/Mod/Part/App/FeaturePartBoolean.cpp @@ -124,7 +124,7 @@ App::DocumentObjectExecReturn* Boolean::execute() ->GetGroup("Preferences") ->GetGroup("Mod/Part/Boolean"); - if (hGrp->GetBool("CheckModel", false)) { + if (hGrp->GetBool("CheckModel", true)) { BRepCheck_Analyzer aChecker(resShape); if (!aChecker.IsValid()) { return new App::DocumentObjectExecReturn("Resulting shape is invalid"); diff --git a/src/Mod/Part/App/FeaturePartCommon.cpp b/src/Mod/Part/App/FeaturePartCommon.cpp index b2363050e5..663b281434 100644 --- a/src/Mod/Part/App/FeaturePartCommon.cpp +++ b/src/Mod/Part/App/FeaturePartCommon.cpp @@ -147,7 +147,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean"); - if (hGrp->GetBool("CheckModel", false)) { + if (hGrp->GetBool("CheckModel", true)) { BRepCheck_Analyzer aChecker(resShape); if (! aChecker.IsValid() ) { return new App::DocumentObjectExecReturn("Resulting shape is invalid"); @@ -222,7 +222,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute() .GetGroup("BaseApp") ->GetGroup("Preferences") ->GetGroup("Mod/Part/Boolean"); - if (hGrp->GetBool("CheckModel", false)) { + if (hGrp->GetBool("CheckModel", true)) { BRepCheck_Analyzer aChecker(res.getShape()); if (!aChecker.IsValid()) { return new App::DocumentObjectExecReturn("Resulting shape is invalid"); diff --git a/src/Mod/Part/App/FeaturePartFuse.cpp b/src/Mod/Part/App/FeaturePartFuse.cpp index b29d09cede..18c1e71d7d 100644 --- a/src/Mod/Part/App/FeaturePartFuse.cpp +++ b/src/Mod/Part/App/FeaturePartFuse.cpp @@ -148,7 +148,7 @@ App::DocumentObjectExecReturn *MultiFuse::execute() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean"); - if (hGrp->GetBool("CheckModel", false)) { + if (hGrp->GetBool("CheckModel", true)) { BRepCheck_Analyzer aChecker(resShape); if (! aChecker.IsValid() ) { return new App::DocumentObjectExecReturn("Resulting shape is invalid"); @@ -268,7 +268,7 @@ App::DocumentObjectExecReturn *MultiFuse::execute() .GetGroup("BaseApp") ->GetGroup("Preferences") ->GetGroup("Mod/Part/Boolean"); - if (hGrp->GetBool("CheckModel", false)) { + if (hGrp->GetBool("CheckModel", true)) { BRepCheck_Analyzer aChecker(res.getShape()); if (!aChecker.IsValid()) { return new App::DocumentObjectExecReturn("Resulting shape is invalid"); diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.ui b/src/Mod/Part/Gui/DlgSettingsGeneral.ui index 931175dff1..9dad3c5675 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.ui +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.ui @@ -25,6 +25,9 @@ Automatically check model after boolean operation + + true + CheckModel @@ -38,6 +41,9 @@ Automatically refine model after boolean operation + + true + RefineModel @@ -51,6 +57,9 @@ Automatically refine model after sketch-based operation + + true + RefineModel diff --git a/src/Mod/PartDesign/App/FeatureAddSub.cpp b/src/Mod/PartDesign/App/FeatureAddSub.cpp index c500c69ad9..d9e1bce889 100644 --- a/src/Mod/PartDesign/App/FeatureAddSub.cpp +++ b/src/Mod/PartDesign/App/FeatureAddSub.cpp @@ -49,7 +49,7 @@ FeatureAddSub::FeatureAddSub() //init Refine property Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); - this->Refine.setValue(hGrp->GetBool("RefineModel", false)); + this->Refine.setValue(hGrp->GetBool("RefineModel", true)); } FeatureAddSub::Type FeatureAddSub::getAddSubType() diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index d3e05d644d..22f429d4d6 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -54,7 +54,7 @@ Boolean::Boolean() ADD_PROPERTY_TYPE(Refine,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting"); Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); - this->Refine.setValue(hGrp->GetBool("RefineModel", false)); + this->Refine.setValue(hGrp->GetBool("RefineModel", true)); ADD_PROPERTY_TYPE(UsePlacement,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Apply the placement of the second ( tool ) object"); this->UsePlacement.setValue(false); diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index fe68f30155..0156affa06 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -78,13 +78,10 @@ Transformed::Transformed() (App::PropertyType)(App::Prop_None), "Refine shape (clean up redundant edges) after adding/subtracting"); - // init Refine property - Base::Reference hGrp = App::GetApplication() - .GetUserParameter() - .GetGroup("BaseApp") - ->GetGroup("Preferences") - ->GetGroup("Mod/PartDesign"); - this->Refine.setValue(hGrp->GetBool("RefineModel", false)); + //init Refine property + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); + this->Refine.setValue(hGrp->GetBool("RefineModel", true)); } void Transformed::positionBySupport() diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index b5ce97ac48..3ea4bf9375 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -387,7 +387,7 @@ void SubShapeBinder::setupObject() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); - this->Refine.setValue(hGrp->GetBool("RefineModel", false)); + this->Refine.setValue(hGrp->GetBool("RefineModel", true)); } App::DocumentObject* SubShapeBinder::getSubObject(const char* subname, PyObject** pyObj, diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index e69eedf596..17b9ca693e 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -1420,7 +1420,7 @@ class TestTopologicalNamingProblem(unittest.TestCase): edges = [name for name in reverseMap.keys() if name.startswith("Edge")] vertexes = [name for name in reverseMap.keys() if name.startswith("Vertex")] self.assertEqual(len(body.Shape.childShapes()), 1) - self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 62) + self.assertEqual(body.Shape.childShapes()[0].ElementMapSize, 64) self.assertEqual(len(reverseMap),62) self.assertEqual(len(faces),12) self.assertEqual(len(edges),30) diff --git a/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py b/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py index 15d98a033f..9721ea46a5 100644 --- a/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py +++ b/src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py @@ -519,7 +519,7 @@ class TestSketcherSolver(unittest.TestCase): hole.DrillForDepth = 0 hole.Tapered = 0 self.Doc.recompute() - self.assertEqual(len(hole.Shape.Edges), 13) + self.assertEqual(len(hole.Shape.Edges), 12) hole.Threaded = True hole.ModelThread = True body.addObject(hole) @@ -528,8 +528,8 @@ class TestSketcherSolver(unittest.TestCase): CreateRectangleSketch(sketch2, (0, 0), (3, 3)) body.addObject(sketch2) self.Doc.recompute() - sketch2.addExternal("Hole", "Edge35") # Edge35 will disappear when we stop modeling threads - self.assertEqual(len(hole.Shape.Edges), 38) + sketch2.addExternal("Hole", "Edge29") # Edge29 will disappear when we stop modeling threads + self.assertEqual(len(hole.Shape.Edges), 32) hole.ModelThread = False hole.Refine = True self.Doc.recompute()