diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index d9c9230b02..bf1aed935c 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1420,7 +1420,54 @@ bool TopoShape::analyze(bool runBopCheck, std::ostream& str) const bool TopoShape::isClosed() const { - return BRep_Tool::IsClosed(this->_Shape) ? true : false; + if (this->_Shape.IsNull()) + return false; + bool closed = false; + switch (this->_Shape.ShapeType()) { + case TopAbs_SHELL: + case TopAbs_WIRE: + case TopAbs_EDGE: + closed = BRep_Tool::IsClosed(this->_Shape) ? true : false; + break; + case TopAbs_COMPSOLID: + case TopAbs_SOLID: + { + closed = true; + TopExp_Explorer xp(this->_Shape, TopAbs_SHELL); + while (xp.More()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + xp.Next(); + } + } + break; + case TopAbs_COMPOUND: + { + closed = true; + TopExp_Explorer xp; + for (xp.Init(this->_Shape, TopAbs_SHELL); xp.More(); xp.Next()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + } + for (xp.Init(this->_Shape, TopAbs_FACE, TopAbs_SHELL); xp.More(); xp.Next()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + } + for (xp.Init(this->_Shape, TopAbs_WIRE, TopAbs_FACE); xp.More(); xp.Next()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + } + for (xp.Init(this->_Shape, TopAbs_EDGE, TopAbs_WIRE); xp.More(); xp.Next()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + } + for (xp.Init(this->_Shape, TopAbs_VERTEX, TopAbs_EDGE); xp.More(); xp.Next()) { + closed &= BRep_Tool::IsClosed(xp.Current()) ? true : false; + } + } + break; + case TopAbs_FACE: + case TopAbs_VERTEX: + case TopAbs_SHAPE: + closed = BRep_Tool::IsClosed(this->_Shape) ? true : false; + break; + } + return closed; } TopoDS_Shape TopoShape::cut(TopoDS_Shape shape) const diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index ae490298aa..47bdc8a497 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -443,7 +443,12 @@ As a result, this shape becomes null. - Checks if the shape is closed. + Checks if the shape is closed +If the shape is a shell it returns True if it has no free boundaries (edges). +If the shape is a wire it returns True if it has no free ends (vertices). +(Internal and External sub-shepes are ignored in these checks) +If the shape is an edge it returns True if its vertices are the same. +