From 30f930404c91733cac4cdba103511e9b2767477a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Sat, 16 Sep 2017 08:51:54 +0200 Subject: [PATCH] PartDesign: Allow boolean Fuse/Common without base feature --- src/Mod/PartDesign/App/FeatureBoolean.cpp | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index 796721152a..c518e9c90a 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -67,11 +67,14 @@ short Boolean::mustExecute() const App::DocumentObjectExecReturn *Boolean::execute(void) { + // Get the operation type + std::string type = Type.getValueAsString(); + // Check the parameters const Part::Feature* baseFeature = this->getBaseObject(/* silent = */ true); - if (!baseFeature) { - return new App::DocumentObjectExecReturn("Cannot do boolean operation with invalid BaseFeature"); + if (!baseFeature && type == "Cut") { + return new App::DocumentObjectExecReturn("Cannot do boolean cut without BaseFeature"); } std::vector tools = Group.getValues(); @@ -79,7 +82,18 @@ App::DocumentObjectExecReturn *Boolean::execute(void) return App::DocumentObject::StdReturn; // Get the base shape to operate on - Part::TopoShape baseTopShape = baseFeature->Shape.getShape(); + Part::TopoShape baseTopShape; + if(baseFeature) + baseTopShape = baseFeature->Shape.getShape(); + else { + auto feature = tools.back(); + if(!feature->isDerivedFrom(Part::Feature::getClassTypeId())) + return new App::DocumentObjectExecReturn("Cannot do boolean with anything but Part::Feature and its derivatives"); + + baseTopShape = static_cast(feature)->Shape.getShape(); + tools.pop_back(); + } + if (baseTopShape.getShape().IsNull()) return new App::DocumentObjectExecReturn("Cannot do boolean operation with invalid base shape"); @@ -91,13 +105,8 @@ App::DocumentObjectExecReturn *Boolean::execute(void) TopoDS_Shape result = baseTopShape.getShape(); - // Get the operation type - std::string type = Type.getValueAsString(); - for (auto tool : tools) { - // Extract the body shape. Its important to get the actual feature that provides the last solid in the body - // so that the placement will be right if(!tool->isDerivedFrom(Part::Feature::getClassTypeId())) return new App::DocumentObjectExecReturn("Cannot do boolean with anything but Part::Feature and its derivatives");