0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_ShapeTool.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 972be41..732f320
@@ -1,85 +1,86 @@
-// File:       Prs3d_ShapeTool.cxx
-// Created:    Mon Aug  7 10:48:43 1995
-// Author:     Modelistation
-//             <model@metrox>
+// Created on: 1995-08-07
+// Created by: Modelistation
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
-#define OCC215           //SAV: 01/04/02 vertex exploring is done for all types of shape.
-#define OCC598          //SAV: 22/10/02 searching for internal vertices. 
-
-#include <Prs3d_ShapeTool.ixx>
 
+#include <Bnd_Box.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
 #include <BRepTools.hxx>
-#include <TopoDS.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Poly_Polygon3D.hxx>
+#include <Poly_PolygonOnTriangulation.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Prs3d_ShapeTool.hxx>
 #include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <BRepBndLib.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <Bnd_Box.hxx>
-#include <BRep_Tool.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_Plane.hxx>
-
 
 //=======================================================================
 //function : Prs3d_ShapeTool
 //purpose  : 
 //=======================================================================
-
-Prs3d_ShapeTool::Prs3d_ShapeTool(const TopoDS_Shape& TheShape):
-                                 myShape (TheShape) 
+Prs3d_ShapeTool::Prs3d_ShapeTool (const TopoDS_Shape& theShape,
+                                  const Standard_Boolean theAllVertices)
+: myShape (theShape)
 {
   myEdgeMap.Clear();
   myVertexMap.Clear();
-  TopExp::MapShapesAndAncestors(TheShape,TopAbs_EDGE,TopAbs_FACE,myEdgeMap);
-
-#ifndef OCC215
-  // find vertices not under ancestors.
-  TopAbs_ShapeEnum E = TheShape.ShapeType();
+  TopExp::MapShapesAndAncestors (theShape,TopAbs_EDGE,TopAbs_FACE, myEdgeMap);
 
-
-  // this check were done to reduce the number of selectable objects
-  // in a local context. By now, there's no noticeable performance improvement.
-  if (E != TopAbs_SOLID && E != TopAbs_SHELL)
-#endif
+  TopExp_Explorer anExpl;
+  if (theAllVertices)
+  {
+    for (anExpl.Init (theShape, TopAbs_VERTEX); anExpl.More(); anExpl.Next())
     {
-      TopExp_Explorer ex(TheShape,TopAbs_VERTEX, TopAbs_EDGE);
-      while (ex.More()) {
-       const TopoDS_Shape& aV=ex.Current();
-       myVertexMap.Add(aV);
-       ex.Next();
-      }
+      myVertexMap.Add (anExpl.Current());
     }
-#ifdef OCC598
-  TopExp_Explorer edges( TheShape, TopAbs_EDGE );
-  while( edges.More() ) {
-    //xf
-    const TopoDS_Shape& aE= edges.Current();
-    TopoDS_Iterator aIt(aE, Standard_False, Standard_True);
-    while( aIt.More() ) {
-      const TopoDS_Shape& aV=aIt.Value();
-      if (aV.Orientation()==TopAbs_INTERNAL) {
-       myVertexMap.Add(aV);
-      }
-      aIt.Next();
+  }
+  else
+  {
+    // Extracting isolated vertices
+    for (anExpl.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); anExpl.More(); anExpl.Next())
+    {
+      myVertexMap.Add (anExpl.Current());
     }
-    /*
-    TopExp_Explorer vertices( edges.Current(), TopAbs_VERTEX );
-    while( vertices.More() ) {
-      TopoDS_Vertex current = TopoDS::Vertex( vertices.Current() );
-      if ( current.Orientation() == TopAbs_INTERNAL )
-       myVertexMap.Add( current );
-      vertices.Next();
+
+    // Extracting internal vertices
+    for (anExpl.Init (theShape, TopAbs_EDGE); anExpl.More(); anExpl.Next())
+    {
+      TopoDS_Iterator aIt (anExpl.Current(), Standard_False, Standard_True);
+      for (; aIt.More(); aIt.Next())
+      {
+        const TopoDS_Shape& aV = aIt.Value();
+        if (aV.Orientation() == TopAbs_INTERNAL)
+        {
+          myVertexMap.Add (aV);
+        }
+      }
     }
-    */
-    //xt
-    edges.Next();
   }
-#endif
 }
 
 //=======================================================================
@@ -141,16 +142,20 @@ Bnd_Box Prs3d_ShapeTool::FaceBound() const
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean Prs3d_ShapeTool::IsPlanarFace() const 
+Standard_Boolean Prs3d_ShapeTool::IsPlanarFace (const TopoDS_Face& theFace)
 {
   TopLoc_Location l;
-  const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current());
-  const Handle(Geom_Surface)& S = BRep_Tool::Surface(F, l);
+  const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace, l);
+  if (S.IsNull())
+  {
+    return Standard_False;
+  }
+
   Handle(Standard_Type) TheType = S->DynamicType();
 
   if (TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
     Handle(Geom_RectangularTrimmedSurface) 
-       RTS = *((Handle(Geom_RectangularTrimmedSurface)*)&S);
+       RTS = Handle(Geom_RectangularTrimmedSurface)::DownCast (S);
     TheType = RTS->BasisSurface()->DynamicType();
   }
   return (TheType == STANDARD_TYPE(Geom_Plane));