From 9ff76fc813fe5e2cb9f1efe125efb1e2054caff3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Jul 2017 12:29:46 +0200 Subject: [PATCH] try to fix tolerance if shape is broken after fillet/chamfer operation --- src/Mod/PartDesign/App/FeatureChamfer.cpp | 13 +++++++++++-- src/Mod/PartDesign/App/FeatureFillet.cpp | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index c1b776c51b..b1d8f7461a 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -32,7 +32,9 @@ # include # include # include -#include +# include +# include +# include #endif #include @@ -112,7 +114,14 @@ App::DocumentObjectExecReturn *Chamfer::execute(void) TopTools_ListOfShape aLarg; aLarg.Append(baseShape.getShape()); if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) { - return new App::DocumentObjectExecReturn("Resulting shape is invalid"); + ShapeFix_ShapeTolerance aSFT; + aSFT.LimitTolerance(shape, Precision::Confusion(), Precision::Confusion(), TopAbs_SHAPE); + Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(shape); + aSfs->Perform(); + shape = aSfs->Shape(); + if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) { + return new App::DocumentObjectExecReturn("Resulting shape is invalid"); + } } this->Shape.setValue(getSolid(shape)); diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 55eb782dde..0818a1a26b 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -29,9 +29,11 @@ # include # include # include -#include -#include -#include +# include +# include +# include +# include +# include #endif #include @@ -106,7 +108,14 @@ App::DocumentObjectExecReturn *Fillet::execute(void) TopTools_ListOfShape aLarg; aLarg.Append(baseShape.getShape()); if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) { - return new App::DocumentObjectExecReturn("Resulting shape is invalid"); + ShapeFix_ShapeTolerance aSFT; + aSFT.LimitTolerance(shape, Precision::Confusion(), Precision::Confusion(), TopAbs_SHAPE); + Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(shape); + aSfs->Perform(); + shape = aSfs->Shape(); + if (!BRepAlgo::IsValid(aLarg, shape, Standard_False, Standard_False)) { + return new App::DocumentObjectExecReturn("Resulting shape is invalid"); + } } this->Shape.setValue(getSolid(shape));