From 9a932e09a00eb70ad40b50f3a11c29c8a717f526 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Thu, 23 May 2013 10:49:27 +0430 Subject: [PATCH] Allow Pad and Pocket up to a face with sketch located on datum plane --- src/Mod/PartDesign/App/FeaturePad.cpp | 6 +++++- src/Mod/PartDesign/App/FeaturePocket.cpp | 6 +++++- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 12 +++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index c57ebd1744..6d6288ed5b 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -157,7 +157,7 @@ App::DocumentObjectExecReturn *Pad::execute(void) TopoDS_Shape prism; std::string method(Type.getValueAsString()); if (method == "UpToFirst" || method == "UpToLast" || method == "UpToFace") { - // Note: This will throw an exception if the sketch is located on a datum plane + // Note: This will return an unlimited planar face if support is a datum plane TopoDS_Face supportface = getSupportFace(); supportface.Move(invObjLoc); @@ -180,6 +180,10 @@ App::DocumentObjectExecReturn *Pad::execute(void) // Note: Multiple independent wires are not supported, we should check for that and // warn the user // FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results + // Check supportface for limits, otherwise Perform() throws an exception + TopExp_Explorer Ex(supportface,TopAbs_WIRE); + if (!Ex.More()) + supportface = TopoDS_Face(); BRepFeat_MakePrism PrismMaker; PrismMaker.Init(base, sketchshape, supportface, dir, 2, 1); PrismMaker.Perform(upToFace); diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index 000f4ac9dc..a06da743e8 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -134,7 +134,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void) std::string method(Type.getValueAsString()); if (method == "UpToFirst" || method == "UpToFace") { - // Note: This will throw an exception if the sketch is located on a datum plane + // Note: This will return an unlimited planar face if support is a datum plane TopoDS_Face supportface = getSupportFace(); supportface.Move(invObjLoc); @@ -151,6 +151,10 @@ App::DocumentObjectExecReturn *Pocket::execute(void) // Special treatment because often the created stand-alone prism is invalid (empty) because // BRepFeat_MakePrism(..., 2, 1) is buggy + // Check supportface for limits, otherwise Perform() throws an exception + TopExp_Explorer Ex(supportface,TopAbs_WIRE); + if (!Ex.More()) + supportface = TopoDS_Face(); BRepFeat_MakePrism PrismMaker; PrismMaker.Init(base, sketchshape, supportface, dir, 0, 1); PrismMaker.Perform(upToFace); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 57fb6b4d32..7c81b5661a 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -190,9 +190,15 @@ std::vector SketchBased::getSketchWires() const { const TopoDS_Face SketchBased::getSupportFace() const { const App::PropertyLinkSub& Support = static_cast(Sketch.getValue())->Support; App::DocumentObject* ref = Support.getValue(); - if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || - ref->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) - throw Base::Exception("Sketch must be located on a face of a solid for this feature to work"); + + if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + TopoDS_Shape plane = Feature::makeShapeFromPlane(ref); + return TopoDS::Face(plane); + } else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + PartDesign::Plane* plane = static_cast(ref); + return TopoDS::Face(plane->getShape()); + } + Part::Feature *part = static_cast(Support.getValue()); if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) throw Base::Exception("No support in sketch");