From c3a8348861372b055c2446a09f0fc49a6cd7a2ef Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 30 Sep 2018 22:40:32 +0200 Subject: [PATCH] fixes 0003571: Offset3D of volumes intersection is not solid --- src/Mod/Part/App/TopoShape.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 5dc0f1c24d..3f447900ba 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -2317,14 +2317,33 @@ TopoDS_Shape TopoShape::makeOffsetShape(double offset, double tol, bool intersec bool selfInter, short offsetMode, short join, bool fill) const { + // If the input shape is a compound with a single solid then the offset + // algorithm creates only a shell instead of a solid which causes errors + // when using it e.g. for boolean operations. (#0003571) + // But when extracting the solid and passing it to the algorithm the output + // shape is a solid. + TopoDS_Shape inputShape = this->_Shape; + TopExp_Explorer xp; + xp.Init(inputShape, TopAbs_VERTEX, TopAbs_SOLID); + if (!xp.More()) { + xp.Init(inputShape, TopAbs_SOLID); + if (xp.More()) { + // If exactly one solid then get it + TopoDS_Shape inputSolid = xp.Current(); + xp.Next(); + if (xp.More() == Standard_False) + inputShape = inputSolid; + } + } + #if OCC_VERSION_HEX < 0x070200 - BRepOffsetAPI_MakeOffsetShape mkOffset(this->_Shape, offset, tol, BRepOffset_Mode(offsetMode), + BRepOffsetAPI_MakeOffsetShape mkOffset(inputShape, offset, tol, BRepOffset_Mode(offsetMode), intersection ? Standard_True : Standard_False, selfInter ? Standard_True : Standard_False, GeomAbs_JoinType(join)); #else BRepOffsetAPI_MakeOffsetShape mkOffset; - mkOffset.PerformByJoin(this->_Shape, offset, tol, BRepOffset_Mode(offsetMode), + mkOffset.PerformByJoin(inputShape, offset, tol, BRepOffset_Mode(offsetMode), intersection ? Standard_True : Standard_False, selfInter ? Standard_True : Standard_False, GeomAbs_JoinType(join));