- Handle(SelectMgr_EntityOwner) anOwner = owners( i );
- if ( anOwner.IsNull() || !anOwner->HasShape() )
- continue;
-
- // GLOBAL selection
- if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
- {
- ownersmap.Add( anOwner );
- }
- // LOCAL selection
- else
- {
- Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
-
- if ( !aisShape.IsNull() && indexesMap.IsBound( (char*)entryStr.latin1() ) )
- {
- TopoDS_Shape shape = aisShape->Shape();
- TopTools_IndexedMapOfShape aMapOfShapes;
- TopExp::MapShapes( shape, aMapOfShapes );
- const TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind((char*)entryStr.latin1());
-
- const TopoDS_Shape& aSubShape = anOwner->Shape();
- int aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
-
- // check if the "sub_shape_index" is found in the "map of indexes for this entry",
- // which was passes in the parameter
- if ( subIndexes.Contains( aSubShapeId ) )
- {
- ownersmap.Add( anOwner );
- }
- }
- } // end of local selection
+ anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
+ if (!anOwner.IsNull() && anOwner->HasShape())
+ {
+ if (anOwner->ComesFromDecomposition() || !globalSelMap.contains(entryStr))
+ {
+ // has a local selection
+ Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
+ if (!aisShape.IsNull() && indexesMap.IsBound(entryStr.toLatin1().data()))
+ {
+ isLocal = true;
+ TopoDS_Shape shape = aisShape->Shape();
+ aMapOfShapes.Clear();
+ TopExp::MapShapes(shape, aMapOfShapes);
+ }
+ }
+ }
+ }
+
+ // 2. Process all owners
+ for (i = 1; i <= n; i++)
+ {
+ anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
+
+ if ( anOwner.IsNull() || !anOwner->HasShape() )
+ continue;
+
+ // GLOBAL selection
+ if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
+ {
+ ownersmap.Add( anOwner );
+ globalSelMap[entryStr]++;
+ }
+ // LOCAL selection
+ else
+ {
+ if (isLocal)
+ {
+ const TColStd_IndexedMapOfInteger& subIndexes =
+ indexesMap.ChangeFind(entryStr.toLatin1().data());
+
+ const TopoDS_Shape& aSubShape = anOwner->Shape();
+ int aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
+
+ // check if the "sub_shape_index" is found in the "map of indexes for this entry",
+ // which was passes in the parameter
+ if ( subIndexes.Contains( aSubShapeId ) )
+ {
+ ownersmap.Add( anOwner );
+ }
+ }
+ } // end of LOCAL selection