0025365: Regressions after changes in IsClosed flag
authorabv <abv@opencascade.com>
Mon, 13 Oct 2014 16:44:33 +0000 (20:44 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 16 Oct 2014 11:43:55 +0000 (15:43 +0400)
Restore previous behavior of BRep_Tool::IsClosed() for shells: empty shells and shells containing only INTERNAL or EXTERNAL sub-shapes are considered non-closed.

src/BRep/BRep_Tool.cxx

index f025a17..af654bf 100644 (file)
@@ -1458,28 +1458,34 @@ Standard_Boolean BRep_Tool::IsClosed (const TopoDS_Shape& theShape)
   if (theShape.ShapeType() == TopAbs_SHELL || theShape.ShapeType() == TopAbs_SOLID)
   {
     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
-    for (TopExp_Explorer exp (theShape, TopAbs_EDGE); exp.More(); exp.Next())
+    TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
+    Standard_Boolean hasBound = Standard_False;
+    for (; exp.More(); exp.Next())
     {
       const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
       if (BRep_Tool::Degenerated(E) || E.Orientation() == TopAbs_INTERNAL || E.Orientation() == TopAbs_EXTERNAL)
         continue;
+      hasBound = Standard_True;
       if (!aMap.Add(E))
         aMap.Remove(E);
     }
-    return aMap.IsEmpty();
+    return hasBound && aMap.IsEmpty();
   }
   else if (theShape.ShapeType() == TopAbs_WIRE)
   {
     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
-    for (TopExp_Explorer exp (theShape, TopAbs_VERTEX); exp.More(); exp.Next())
+    TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_VERTEX);
+    Standard_Boolean hasBound = Standard_False;
+    for (; exp.More(); exp.Next())
     {
       const TopoDS_Shape& V = exp.Current();
       if (V.Orientation() == TopAbs_INTERNAL || V.Orientation() == TopAbs_EXTERNAL)
         continue;
+      hasBound = Standard_True;
       if (!aMap.Add(V))
         aMap.Remove(V);
     }
-    return aMap.IsEmpty();
+    return hasBound && aMap.IsEmpty();
   }
   return theShape.Closed();
 }