From bc5311b3eec28b2c537747e2fa8da6c8ee335d8b Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 24 Feb 2021 17:08:20 +0100 Subject: [PATCH] PD: fixes #0004567: Pattern from a feature type UpToFace and Offset > copy whole body --- src/Mod/PartDesign/App/FeaturePad.cpp | 8 ++++---- src/Mod/PartDesign/App/FeaturePocket.cpp | 3 ++- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 12 +++++++++--- src/Mod/PartDesign/App/FeatureSketchBased.h | 8 +++++++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index fc0e0d7e36..b2b700de92 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -274,8 +274,8 @@ App::DocumentObjectExecReturn *Pad::execute(void) return new App::DocumentObjectExecReturn("Pad: Up to face: Could not extrude the sketch!"); prism = PrismMaker.Shape(); #else - Standard_Integer fuse = fabs(Offset.getValue()) > Precision::Confusion() ? 1 : 2; - generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, fuse, Standard_True); + PrismMode mode = PrismMode::None; + generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, mode, Standard_True); #endif base.Nullify(); } else { @@ -300,8 +300,8 @@ App::DocumentObjectExecReturn *Pad::execute(void) return new App::DocumentObjectExecReturn("Pad: Up to face: Could not extrude the sketch!"); prism = PrismMaker.Shape(); #else - Standard_Integer fuse = fabs(Offset.getValue()) > Precision::Confusion() ? 1 : 2; - generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, fuse, Standard_True); + PrismMode mode = PrismMode::None; + generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, mode, Standard_True); #endif } } else { diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index af635cbdd5..3c248d7683 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -189,7 +189,8 @@ App::DocumentObjectExecReturn *Pocket::execute(void) TopoDS_Shape prism = PrismMaker.Shape(); #else TopoDS_Shape prism; - generatePrism(prism, method, base, profileshape, supportface, upToFace, dir, 0, Standard_True); + PrismMode mode = PrismMode::CutFromBase; + generatePrism(prism, method, base, profileshape, supportface, upToFace, dir, mode, Standard_True); #endif // And the really expensive way to get the SubShape... diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 2b1d4ae2fd..3a54985488 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -540,6 +540,12 @@ void ProfileBased::addOffsetToFace(TopoDS_Face& upToFace, const gp_Dir& dir, dou mov.SetTranslation(offset * gp_Vec(dir)); TopLoc_Location loc(mov); upToFace.Move(loc); + + // When using the face with BRepFeat_MakePrism::Perform(const TopoDS_Shape& Until) + // then the algorithm expects that the 'NaturalRestriction' flag is set in order + // to work as expected (see generatePrism()) + BRep_Builder builder; + builder.NaturalRestriction(upToFace, Standard_True); } else { throw Base::TypeError("SketchBased: Up to Face: Offset not supported yet for non-planar faces"); } @@ -617,7 +623,7 @@ void ProfileBased::generatePrism(TopoDS_Shape& prism, const TopoDS_Face& supportface, const TopoDS_Face& uptoface, const gp_Dir& direction, - Standard_Integer Mode, + PrismMode Mode, Standard_Boolean Modify) { if (method == "UpToFirst" || method == "UpToFace" || method == "UpToLast") { @@ -630,8 +636,8 @@ void ProfileBased::generatePrism(TopoDS_Shape& prism, throw Base::RuntimeError("ProfileBased: Up to face: Could not extrude the sketch!"); base = PrismMaker.Shape(); - if (Mode == 2) - Mode = 1; + if (Mode == PrismMode::None) + Mode = PrismMode::FuseWithBase; } prism = base; diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index 04b184c843..17a5659287 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -148,6 +148,12 @@ protected: const double L2, const bool midplane, const bool reversed); + // See BRepFeat_MakePrism + enum PrismMode { + CutFromBase = 0, + FuseWithBase = 1, + None = 2 + }; /** * Generate a linear prism * It will be a stand-alone solid created with BRepFeat_MakePrism @@ -159,7 +165,7 @@ protected: const TopoDS_Face& sketchface, const TopoDS_Face& uptoface, const gp_Dir& direction, - Standard_Integer Mode, + PrismMode Mode, Standard_Boolean Modify); /// Check whether the wire after projection on the face is inside the face