- Standard_Integer j = 1;
- TopExp_Explorer exp;
- TopAbs_ShapeEnum ShapeType = TopAbs_ShapeEnum(aShape->ShapeType());
-
- /* Case of only one subshape */
- if (list->length() == 1)
- {
- if (ShapeType == TopAbs_COMPOUND)
- {
- TopoDS_Iterator it;
- TopTools_ListOfShape CL;
- CL.Append( MainShape );
- 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 (j == list[0])
- {
- S = it.Value();
- Bind(IOR, S);
- return S;
- }
- j++;
- CL.Append( it.Value() );
- }
- }
- }
- }
- else
- {
- TopTools_MapOfShape M;
- for (exp.Init(MainShape, ShapeType); exp.More(); exp.Next()) {
- if ( M.Add(exp.Current()) )
- {
- if (j == list[0])
- {
- S = exp.Current();
- Bind(IOR, S);
- return S;
- }
- j++;
- }
- }
- }
- }
-
- /* Case of a compound containing two or more sub shapes (not a main shape compound !) */
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aMainShape, anIndices);