diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 2d260ca7ec..fc0e0d7e36 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -194,7 +194,8 @@ App::DocumentObjectExecReturn *Pad::execute(void) getUpToFaceFromLinkSub(upToFace, UpToFace); upToFace.Move(invObjLoc); } - getUpToFace(upToFace, base, supportface, sketchshape, method, dir, Offset.getValue()); + getUpToFace(upToFace, base, supportface, sketchshape, method, dir); + addOffsetToFace(upToFace, dir, Offset.getValue()); // TODO: Write our own PrismMaker which does not depend on a solid base shape if (base.IsNull()) { diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index d1080019ae..af635cbdd5 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -166,7 +166,8 @@ App::DocumentObjectExecReturn *Pocket::execute(void) getUpToFaceFromLinkSub(upToFace, UpToFace); upToFace.Move(invObjLoc); } - getUpToFace(upToFace, base, supportface, profileshape, method, dir, Offset.getValue()); + getUpToFace(upToFace, base, supportface, profileshape, method, dir); + addOffsetToFace(upToFace, dir, Offset.getValue()); // BRepFeat_MakePrism(..., 2, 1) in combination with PerForm(upToFace) is buggy when the // prism that is being created is contained completely inside the base solid diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index ffd61417d4..2b1d4ae2fd 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -440,8 +440,7 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, const TopoDS_Face& supportface, const TopoDS_Shape& sketchshape, const std::string& method, - const gp_Dir& dir, - const double offset) + const gp_Dir& dir) { if ((method == "UpToLast") || (method == "UpToFirst")) { // Check for valid support object @@ -528,10 +527,14 @@ void ProfileBased::getUpToFace(TopoDS_Face& upToFace, BRepExtrema_DistShapeShape distSS(sketchshape, upToFace); if (distSS.Value() < Precision::Confusion()) throw Base::ValueError("SketchBased: Up to face: Must not intersect sketch!"); +} +void ProfileBased::addOffsetToFace(TopoDS_Face& upToFace, const gp_Dir& dir, double offset) +{ // Move the face in the extrusion direction // TODO: For non-planar faces, we could consider offsetting the surface if (fabs(offset) > Precision::Confusion()) { + BRepAdaptor_Surface adapt2(TopoDS::Face(upToFace)); if (adapt2.GetType() == GeomAbs_Plane) { gp_Trsf mov; mov.SetTranslation(offset * gp_Vec(dir)); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index 7e19be3bf8..04b184c843 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -129,8 +129,13 @@ protected: const TopoDS_Face& supportface, const TopoDS_Shape& sketchshape, const std::string& method, - const gp_Dir& dir, - const double offset); + const gp_Dir& dir); + + /// Add an offset to the face + static void addOffsetToFace(TopoDS_Face& upToFace, + const gp_Dir& dir, + double offset); + /** * Generate a linear prism * It will be a stand-alone solid created with BRepPrimAPI_MakePrism