how to how to display a Graphic3d_group in a AIS_InterActiveContext ??

Hi !!!
i would to know how to how to display a Graphic3d_group in a 3d view (AIS_InterActiveContext ) ???
thanks .

ekiroglu's picture

Hello,

You should first create your own AIS_InteractiveObject, as in the example User_Cylinder.cxx in SampleAISSelect.
Then, you can add the following piece of code to the Compute section of User_Cylinder.cxx :

Handle( Graphic3d_Group ) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
static Graphic3d_Array1OfVertex vertices( 1, 5 );

vertices(1).SetCoord( 200, 0 , 500);
vertices(5).SetCoord( 200, 0 , 500);
vertices(2).SetCoord( 200, 200, 500);
vertices(3).SetCoord( 0, 200, 500);
vertices(4).SetCoord( 0, 0, 500);

TheGroup->Polygon(vertices);

....

Finally,

Handle(User_Cylinder) UC = new User_Cylinder(100, 200);
myAISContext->Display(UC);

I hope this will be helpfull.

Erki

zombri's picture

hi Erki !
thanks a lot that was very helpfull me !
bye

cheng's picture

TheGroup->Polygon,
how to color?

Hugues Delorme's picture

Create (for example) a local static variable like this :
static const Handle_Graphic3d_AspectLine3d polygonLineAspect =
new Graphic3d_AspectLine3d(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.);

And do the following :
TheGroup->SetPrimitivesAspect(polygonLineAspect);
TheGroup->BeginPrimitives();
TheGroup->Polygon(...);
TheGroup->EndPrimitives();