Functionnalies on an imported shape

Hi,
I already imported my shape using the import-export, sample. Now I want to add functionnalites on that shape. For instance explore the model and put different colors depending on a selected direction. I am sure somebody has done something similar.
Thank for sharing.

Kreshnik's picture

Hi,

You have to use this code first to get all the dispayed objects in the viewer :

// On obtient la liste des objets affichés
AIS_ListOfInteractive ais_objects;
aContext->DisplayedObjects (ais_objects);

// On instancie un iterateur d'objets
AIS_ListIteratorOfListOfInteractive iobject;

// Pour chaque objet affiché
for (iobject.Initialize (ais_objects); iobject.More(); iobject.Next())
{
// You get the object and you can do what you want(e.g change color...)
Handle(AIS_InteractiveObject) ais_object = iobject.Value();

}

mamadou sy's picture

Thank you very much. I will try your code and will let you know the result.

mamadou sy's picture

Could you guys check this for me:

Handle_AIS_InteractiveContext GlobalContext;
{
Handle(AIS_Shape) myAISObj = Handle(AIS_Shape)::DownCast(myAISContext->Current());
TopoDS_Shape aShape = myAISObj->Shape();

TopTools_IndexedMapOfShape aFaces;
TopExp::MapShapes(aShape, TopAbs_FACE, aFaces);
Standard_Integer nbFaces = aFaces.Extent();

GlobalContext->EraseAll();

GlobalContext->Display((aFaces(1), Quantity_NOC_WHITE, Standard_False));

}

Goal was to display face 1 in certain color.
Here is my error:

error C2664: 'void __thiscall AIS_InteractiveContext::Display(const class Handle_AIS_InteractiveObject &,const unsigned int)' : cannot convert parameter 1 from 'unsi
gned int' to 'const class Handle_AIS_InteractiveObject &'
Reason: cannot convert from 'unsigned int' to 'const class Handle_AIS_InteractiveObject'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

Thank you

Kreshnik's picture

These are the two ways to call the function Diaplay. The first parameter must be an AIS_InteractiveObject or a derived class.

void Display (const Handle(AIS_InteractiveObject)& anIobj,const Standard_Boolean updateviewer=Standard_True)

void Display (const Handle(AIS_InteractiveObject)& anIobj,const Standard_Integer amode,const Standard_Integer aSelectionMode,const Standard_Boolean updateviewer=Standard_True,const Standard_Boolean allowdecomposition=Standard_True)