From 6edce0cafad7284e84678bbfd93de16209a7a7d1 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 7 Feb 2025 21:44:43 -0600 Subject: [PATCH] PD: Add onlyHaveRefined() to FeatureRefine --- src/Mod/PartDesign/App/FeatureChamfer.cpp | 6 +-- src/Mod/PartDesign/App/FeatureExtrude.cpp | 7 +-- src/Mod/PartDesign/App/FeatureFillet.cpp | 7 +-- src/Mod/PartDesign/App/FeatureGroove.cpp | 6 +-- src/Mod/PartDesign/App/FeatureHelix.cpp | 7 +-- src/Mod/PartDesign/App/FeatureLoft.cpp | 6 +-- src/Mod/PartDesign/App/FeaturePipe.cpp | 6 +-- src/Mod/PartDesign/App/FeaturePrimitive.cpp | 6 +-- src/Mod/PartDesign/App/FeatureRefine.cpp | 52 ++++++++++++-------- src/Mod/PartDesign/App/FeatureRefine.h | 42 ++++++++-------- src/Mod/PartDesign/App/FeatureRevolution.cpp | 7 +-- src/Mod/PartDesign/App/FeatureThickness.cpp | 6 +-- 12 files changed, 67 insertions(+), 91 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index 406e094d4a..9a0bfab347 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -104,11 +104,7 @@ short Chamfer::mustExecute() const App::DocumentObjectExecReturn *Chamfer::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } // NOTE: Normally the Base property and the BaseFeature property should point to the same object. // The only difference is that the Base property also stores the edges that are to be chamfered diff --git a/src/Mod/PartDesign/App/FeatureExtrude.cpp b/src/Mod/PartDesign/App/FeatureExtrude.cpp index e2deb3f82b..73659cc6bd 100644 --- a/src/Mod/PartDesign/App/FeatureExtrude.cpp +++ b/src/Mod/PartDesign/App/FeatureExtrude.cpp @@ -468,11 +468,8 @@ void FeatureExtrude::setupObject() App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions options) { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } + bool makeface = options.testFlag(ExtrudeOption::MakeFace); bool fuse = options.testFlag(ExtrudeOption::MakeFuse); diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 9524cd6bb6..25d60c2778 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -65,11 +65,8 @@ short Fillet::mustExecute() const App::DocumentObjectExecReturn *Fillet::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } + Part::TopoShape baseShape; try { diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index 24e3fa6e57..66f27fdcd3 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -81,11 +81,7 @@ short Groove::mustExecute() const App::DocumentObjectExecReturn *Groove::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } // Validate parameters double angle = Angle.getValue(); diff --git a/src/Mod/PartDesign/App/FeatureHelix.cpp b/src/Mod/PartDesign/App/FeatureHelix.cpp index 62c70e5efa..10e4d22f0c 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.cpp +++ b/src/Mod/PartDesign/App/FeatureHelix.cpp @@ -126,12 +126,7 @@ short Helix::mustExecute() const App::DocumentObjectExecReturn* Helix::execute() { - - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape, RefineErrorPolicy::Warn); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } // Validate and normalize parameters HelixMode mode = static_cast(Mode.getValue()); diff --git a/src/Mod/PartDesign/App/FeatureLoft.cpp b/src/Mod/PartDesign/App/FeatureLoft.cpp index 70a7de5f19..8b53808ea5 100644 --- a/src/Mod/PartDesign/App/FeatureLoft.cpp +++ b/src/Mod/PartDesign/App/FeatureLoft.cpp @@ -112,11 +112,7 @@ Loft::getSectionShape(const char *name, App::DocumentObjectExecReturn *Loft::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } std::vector wires; try { diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index 6d7642f31e..371bee53d4 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -104,11 +104,7 @@ short Pipe::mustExecute() const App::DocumentObjectExecReturn *Pipe::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } auto getSectionShape = [](App::DocumentObject* feature, const std::vector& subs) -> TopoDS_Shape { diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index e7a52f76b2..21cc034d8d 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -68,11 +68,7 @@ FeaturePrimitive::FeaturePrimitive() App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitive) { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } try { //transform the primitive in the correct coordinance diff --git a/src/Mod/PartDesign/App/FeatureRefine.cpp b/src/Mod/PartDesign/App/FeatureRefine.cpp index 730d720788..3199fc03fe 100644 --- a/src/Mod/PartDesign/App/FeatureRefine.cpp +++ b/src/Mod/PartDesign/App/FeatureRefine.cpp @@ -1,23 +1,24 @@ -/*************************************************************************** - * Copyright (c) 2024 * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * +// SPDX-License-Identifier: LGPL-2.1-or-later +/**************************************************************************** + * * + * Copyright (c) 2024 * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * ***************************************************************************/ @@ -70,6 +71,17 @@ bool FeatureRefine::onlyHasToRefine() const return true; } + +bool FeatureRefine::onlyHaveRefined() +{ + if (onlyHasToRefine()){ + TopoShape result = refineShapeIfActive(rawShape); + Shape.setValue(result); + return true; + } + return false; +} + TopoShape FeatureRefine::refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError) const { if (this->Refine.getValue()) { diff --git a/src/Mod/PartDesign/App/FeatureRefine.h b/src/Mod/PartDesign/App/FeatureRefine.h index a29fc1ee09..73ee4fc353 100644 --- a/src/Mod/PartDesign/App/FeatureRefine.h +++ b/src/Mod/PartDesign/App/FeatureRefine.h @@ -1,23 +1,24 @@ -/*************************************************************************** - * Copyright (c) 2024 * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * +// SPDX-License-Identifier: LGPL-2.1-or-later +/**************************************************************************** + * * + * Copyright (c) 2024 * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * ***************************************************************************/ @@ -50,6 +51,7 @@ protected: TopoShape rawShape; bool onlyHasToRefine() const; + bool onlyHaveRefined(); TopoShape refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError = RefineErrorPolicy::Raise) const; }; diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index 0f9cca70cb..d60b1f6558 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -80,11 +80,8 @@ short Revolution::mustExecute() const App::DocumentObjectExecReturn* Revolution::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } + // Validate parameters // All angles are in radians unless explicitly stated diff --git a/src/Mod/PartDesign/App/FeatureThickness.cpp b/src/Mod/PartDesign/App/FeatureThickness.cpp index 002fcf0700..7be41c2ded 100644 --- a/src/Mod/PartDesign/App/FeatureThickness.cpp +++ b/src/Mod/PartDesign/App/FeatureThickness.cpp @@ -65,11 +65,7 @@ int16_t Thickness::mustExecute() const { } App::DocumentObjectExecReturn *Thickness::execute() { - if (onlyHasToRefine()){ - TopoShape result = refineShapeIfActive(rawShape); - Shape.setValue(result); - return App::DocumentObject::StdReturn; - } + if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; } // Base shape Part::TopoShape TopShape;