Manipulating InteractiveObjects

Hi everyone!
I am new to OpenCascade and I am trying to do the following:
-import a step file using the ImportExport Example
-get all shapes from the interactive context
-apply a layer on top of the imported object by using boolean

I can use


to get a list of all objects in the context. Now how can I access the single shapes contained in this list? Can anybody give a short example for accessing two boxes from the InteractiveContext and then being merged by boolean operations?


Hugues's picture

You perform traversal of Open Cascade List objects with list iterators.
To traverse an AIS_ListOfInteractive object, use an AIS_ListIteratorOfListOfInteractive object :

AIS_ListIteratorOfListOfInteractive it (aList);
//iterate on list:
while (it.More ())
//do something with the current item : it.Value ()
it.Next ();

Udo's picture

Hi Hugues,

thanks for your reply. I konow about the iterator, but how can I access the shapes of the returned objects?
it.Value() returns a Handle_AIS_InteractiveObject. Can I convert this somehow to a TopoDS_Shape?

Hugues Delorme's picture

Sorry for my dummy answer, here is what you can do to access the underlying shape :
Normally, your AIS_InteractiveObject instances are AIS_Shape objects.
So you should cast them :

//"it" is an iterator on a list of InteractiveObject instances.
Handle_AIS_InteractiveObject current_ais_item = it.Value ();
assert (current_ais_item->IsKind (STANDARD_TYPE (AIS_Shape));//instance_of_ais_shape
Handle_AIS_Shape current_ais_shape = Handle_AIS_Shape::DownCast (current_ais_item);
assert (not current_ais_shape.IsNull ());//not_null
const TopoDS_Shape& current_topo_shape = current_ais_shape->Shape ();

Try this code, I have not test it, but this is a way to get what you need.

Udo's picture

Thanks, that was exactly what I needed´to get a good start on solving my problem!