- TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
- int index = aGeomMap.FindIndex( aSubShape );
+ int index = mySelectedIDs.at(i);
+ if ( aMainMap.Extent() < index )
+ {
+ ok = false;
+ }
+ else
+ {
+ TopoDS_Shape aSubShape = aMainMap.FindKey( index );
+ if ( mySubShType != aSubShape.ShapeType() )
+ ok = false;
+ if ( !aGeomMap.Contains( aSubShape ) && !aGeomMap.IsEmpty() )
+ ok = false;
+ else
+ index = aGeomMap.FindIndex( aSubShape );
+ }