bad performance of function: AIS_InteractiveContext::AddOrRemoveSelected()

I'm trying to programmably select/deselect some AIS_InteractiveObjects in a local context.

My code is like

NCollection_Set ais_obj_set;
Handle_AIS_InteractiveContext hAISContext = ...
NCollection_Set::Iterator iter(ais_obj_set);
for (; iter.More(); iter.Next())
hAISContext->AddOrRemoveSelected(iter.Value(), 0);

If there are many Interactive objects (such as 1000) being selected, the loop takes a lot of time (over 30 seconds) to finish.

Anybody has the same issue? Your advice is really appreciated.

Thank you in advance!

jelle's picture

Perhaps a view redraw is invoked after every hAISContext->AddOrRemoveSelected call?
That might be something to look into...