]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
DCQ : Debug GetIndexTopology Method
authordcq <dcq@opencascade.com>
Fri, 16 Apr 2004 12:55:31 +0000 (12:55 +0000)
committerdcq <dcq@opencascade.com>
Fri, 16 Apr 2004 12:55:31 +0000 (12:55 +0000)
src/GEOMGUI/GeometryGUI_Swig.cxx

index 55727f9099936b9f827d6860f72fb4a8ff02be84..81e1f1b457a983fd4f9b3d381eb7ed7015031792 100644 (file)
@@ -40,6 +40,8 @@ using namespace std;
 #include "OCCViewer_Viewer3d.h"
 #include <TopExp_Explorer.hxx>
 #include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <GeomAbs_CurveType.hxx>
@@ -47,6 +49,7 @@ using namespace std;
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
 
 #include "VTKViewer_RenderWindowInteractor.h"
 #include "VTKViewer_ViewFrame.h"
@@ -164,17 +167,36 @@ int  GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
   GEOM::GEOM_Shape_var aSubShape = Geom->GetIORFromString(SubIOR);
   TopoDS_Shape subshape    = ShapeReader.GetShape(Geom, aSubShape);
 
-  TopExp_Explorer Exp ( shape, subshape.ShapeType() );
   int index = 1;
-  TopTools_MapOfShape M;
-  while ( Exp.More() ) {
-    if ( M.Add(Exp.Current()) ) {
-      if ( Exp.Current().IsSame(subshape) )
-       return index;
-      index++;
-    }
-    Exp.Next();
-  }
+  if(subshape.ShapeType() == TopAbs_COMPOUND) { 
+    TopoDS_Iterator it; 
+    TopTools_ListOfShape CL; 
+    CL.Append(shape); 
+    TopTools_ListIteratorOfListOfShape itC; 
+    for(itC.Initialize(CL); itC.More(); itC.Next()) {
+      for(it.Initialize(itC.Value()); it.More(); it.Next()) { 
+       if (it.Value().ShapeType() == TopAbs_COMPOUND) {
+         if (it.Value().IsSame(subshape))
+           return index; 
+         else 
+           index++; 
+         CL.Append(it.Value()); 
+       }
+      } 
+    } 
+  } 
+  else { 
+    TopExp_Explorer Exp(shape, subshape.ShapeType()); 
+    TopTools_MapOfShape M; 
+    while(Exp.More()) { 
+      if(M.Add(Exp.Current())) {
+       if(Exp.Current().IsSame(subshape)) 
+         return index; 
+       index++; 
+      } 
+      Exp.Next(); 
+    } 
+  } 
   return -1;
 }