diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index e961fded4..a126fcbd8 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -87,15 +87,32 @@ App::DocumentObjectExecReturn *Groove::execute(void) angle *= (-1.0); std::vector wires; - TopoDS_Shape support; try { wires = getSketchWires(); - support = getSupportShape(); } catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } - // update Axis from ReferenceAxis + // Get the sketch support + TopoDS_Shape support; + try { + support = getSupportShape(); + } catch (const Base::Exception&) { + // ignore, because support isn't mandatory any more + support = TopoDS_Shape(); + } + + // Get the base shape + TopoDS_Shape base; + try { + base = getBaseShape(); + } catch (const Base::Exception&) { + // fall back to support (for legacy features) + base = support; + if (base.IsNull()) + return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the groove!"); + } + updateAxis(); // get revolve axis @@ -122,6 +139,7 @@ App::DocumentObjectExecReturn *Groove::execute(void) pnt.Transform(invObjLoc.Transformation()); dir.Transform(invObjLoc.Transformation()); support.Move(invObjLoc); + base.Move(invObjLoc); sketchshape.Move(invObjLoc); // Check distance between sketchshape and axis - to avoid failures and crashes @@ -138,10 +156,10 @@ App::DocumentObjectExecReturn *Groove::execute(void) this->SubShape.setValue(result); // cut out groove to get one result object - BRepAlgoAPI_Cut mkCut(support, result); + BRepAlgoAPI_Cut mkCut(base, result); // Let's check if the fusion has been successful if (!mkCut.IsDone()) - throw Base::Exception("Cut out of support failed"); + throw Base::Exception("Cut out of base feature failed"); // we have to get the solids (fuse sometimes creates compounds) TopoDS_Shape solRes = this->getSolid(mkCut.Shape()); diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index b1d053edb..ebc414eb9 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -47,7 +47,7 @@ #include #include -#include "Body.h" +//#include "Body.h" #include "FeaturePad.h" @@ -175,6 +175,7 @@ App::DocumentObjectExecReturn *Pad::execute(void) BRep_Builder builder; builder.MakeCompound(comp); + // FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) { BRepFeat_MakePrism PrismMaker; PrismMaker.Init(support, xp.Current(), supportface, dir, 2, 1); diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index 20d28cdf6..35b739117 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -89,15 +89,33 @@ App::DocumentObjectExecReturn *Pocket::execute(void) Part::Part2DObject* sketch = 0; std::vector wires; - TopoDS_Shape support; try { sketch = getVerifiedSketch(); wires = getSketchWires(); - support = getSupportShape(); } catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); } + // Get the sketch support + TopoDS_Shape support; + try { + support = getSupportShape(); + } catch (const Base::Exception&) { + // ignore, because support isn't mandatory any more + support = TopoDS_Shape(); + } + + // Get the base shape + TopoDS_Shape base; + try { + base = getBaseShape(); + } catch (const Base::Exception&) { + // fall back to support (for legacy features) + base = support; + if (base.IsNull()) + return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the pocket!"); + } + // get the Sketch plane Base::Placement SketchPos = sketch->Placement.getValue(); Base::Rotation SketchOrientation = SketchPos.getRotation(); @@ -111,7 +129,8 @@ App::DocumentObjectExecReturn *Pocket::execute(void) TopLoc_Location invObjLoc = this->getLocation().Inverted(); try { - support.Move(invObjLoc); + support.Move(invObjLoc); + base.Move(invObjLoc); gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z); dir.Transform(invObjLoc.Transformation()); @@ -140,6 +159,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void) for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) { // Special treatment because often the created stand-alone prism is invalid (empty) because // BRepFeat_MakePrism(..., 2, 1) is buggy + // FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results BRepFeat_MakePrism PrismMaker; PrismMaker.Init(prism, xp.Current(), supportface, dir, 0, 1); PrismMaker.Perform(upToFace); @@ -170,10 +190,10 @@ App::DocumentObjectExecReturn *Pocket::execute(void) prism = refineShapeIfActive(prism); this->SubShape.setValue(prism); - // Cut the SubShape out of the support - BRepAlgoAPI_Cut mkCut(support, prism); + // Cut the SubShape out of the base feature + BRepAlgoAPI_Cut mkCut(base, prism); if (!mkCut.IsDone()) - return new App::DocumentObjectExecReturn("Pocket: Cut out of support failed"); + return new App::DocumentObjectExecReturn("Pocket: Cut out of base feature failed"); TopoDS_Shape result = mkCut.Shape(); // we have to get the solids (fuse sometimes creates compounds) TopoDS_Shape solRes = this->getSolid(result); diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index 76bb61366..67b888685 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -143,13 +143,22 @@ App::DocumentObjectExecReturn *Revolution::execute(void) // set the additive shape property for later usage in e.g. pattern this->AddShape.setValue(result); - // if the sketch has a support fuse them to get one result object (PAD!) - if (!support.IsNull()) { + // if the Base property has a valid shape, fuse the AddShape into it + TopoDS_Shape base; + try { + base = getBaseShape(); + base.Move(invObjLoc); + } catch (const Base::Exception&) { + // fall back to support (for legacy features) + base = support; + } + + if (!base.IsNull()) { // Let's call algorithm computing a fuse operation: - BRepAlgoAPI_Fuse mkFuse(support, result); + BRepAlgoAPI_Fuse mkFuse(base, result); // Let's check if the fusion has been successful if (!mkFuse.IsDone()) - throw Base::Exception("Fusion with support failed"); + throw Base::Exception("Fusion with base feature failed"); result = mkFuse.Shape(); result = refineShapeIfActive(result); }