visualization problem

I have this code in a loop:
Handle_AIS_Shape aisShape=new AIS_Shape(shape);
theContext->SetColor(aisShape, colorName);
theContext->SetDisplayMode(aisShape, 1, Standard_False);
theContext->SetCurrentObject(aisShape, Standard_False);

and this out of the loop:


I have to draw lots of object but not during the loop, but after everything is computed.
Everything works fine with this code except selection of objects does not.


Something like this in loop works with selection, but its displaying objects as the loop progresses. And gets realy slow after lots of objects...:

Handle(AIS_Shape) aisShape=new AIS_Shape(shape);
myContext->SetMaterial(aisShape, materialName);
myContext->SetDisplayMode(aisShape, 1, Standard_False);
myContext->Display(aisShape, Standard_False);
myContext->SetCurrentObject(aisShape, Standard_False);


Help would be appreciated on how to fix the first example to work with selection.

Timo Roth's picture

In the second example you should use
myContext->SetMaterial(aisShape, materialName, Standard_False);
instead of
myContext->SetMaterial(aisShape, materialName);
in order not to update the view each time in the loop.

pazduha's picture

Thanks alot!