-// purpose :
-//=======================================================================
-
-TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape )
-{
- TopoDS_Shape S;
- TCollection_AsciiString IOR = geom->GetStringFromIOR(aShape);
- Standard_Integer anIndex = Find(IOR, S);
-
- if (anIndex !=0 ) return S ;
-
- /******* in case of a MAIN GEOM::SHAPE ********/
- if (aShape->IsMainShape()) {
- S = Load(geom, aShape);
- Bind(IOR, S);
- return S;
- }
-
- /******* in case of SUB GEOM::SHAPE ***********/
- // Load and Explore the Main Shape
- TopoDS_Shape aMainShape = GetShape (geom, aShape->GetMainShape());
- GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
-
- TopTools_IndexedMapOfShape anIndices;
- TopExp::MapShapes(aMainShape, anIndices);
-
- /* Case of only one subshape */
- if (list->length() == 1)
- {
- S = anIndices.FindKey(list[0]);
- }
+// purpose :
+//=======================================================================
+TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape )
+{
+ TopoDS_Shape S;
+ CORBA::String_var anIOR = geom->GetStringFromIOR(aShape);
+ TCollection_AsciiString IOR = (char*)anIOR.in();
+ Standard_Boolean anIndex = Find(IOR, S);
+
+ if (anIndex) return S;
+
+ /******* in case of a MAIN GEOM::SHAPE ********/
+ if (aShape->IsMainShape()) {
+ S = Load(geom, aShape);
+ Bind(IOR, S);
+ return S;
+ }
+
+ /******* in case of SUB GEOM::SHAPE ***********/
+ // Load and Explore the Main Shape
+ TopoDS_Shape aMainShape = GetShape (geom, aShape->GetMainShape());
+ GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
+
+ CORBA::String_var aMainIOR = geom->GetStringFromIOR(aShape->GetMainShape());
+ TCollection_AsciiString mainIOR = (char*)aMainIOR.in();
+
+ //find subshapes only one time
+ if (_mySubShapes.count(mainIOR) == 0)
+ {
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aMainShape, anIndices);
+ Standard_Integer ii = 1, nbSubSh = anIndices.Extent();
+ for (; ii <= nbSubSh; ii++)
+ {
+ _mySubShapes[mainIOR].push_back(anIndices.FindKey(ii));
+ }
+ }
+
+ /* Case of only one subshape */
+ if (list->length() == 1 && list[0] > 0) {
+ S = _mySubShapes[mainIOR][list[0]-1];
+ }