retrieve and display the coordinate of point

I want to retrieve the coordinates of a point from AIS_Context so I write these lines

Handle(AIS_InteractiveObject) picked;
myAISContext->InitSelected();
picked = myAISContext->SelectedInteractive();
Handle(AIS_Shape) aShape=Handle(AIS_Shape)::DownCast(picked);
Handle(AIS_Point) aPoint= Handle(AIS_Point)::DownCast(aShape);
TopoDS_Vertex aVertex=aPoint->Vertex();
gp_Pnt point=BRep_Tool::Pnt(aVertex);
gp_Pnt P = BRep_Tool::Pnt(aVertex);
TRACE("X= %f;Y= %f;Z=%f \n",point.X(),point.Y(),point.Z());

but it doesn't work. The pointer Apoint is always null
Then I want to display these coordinates in myAISContext.
is there anyone who has an idea how I can do that.
Thanks

Dennis G.'s picture

Hello ATTIA,

I haven't tried this, but you could try the following:

[code] -------------------------------------------------------------------
Handle(AIS_InteractiveObject) picked;
myAISContext->InitSelected();
picked = myAISContext->SelectedInteractive();
Handle(AIS_Shape) aShape=Handle(AIS_Shape)::DownCast(picked);
// try ...
TopoDS_Shape topShape = aShape->Shape();
TopExp_Explorer vertEx(topShape, TopAbs_Vertex);
TopoDS_Vertex aVertex=TopoDS::Vertex(vertEx.Current());
// ... this
gp_Pnt point=BRep_Tool::Pnt(aVertex);
gp_Pnt P = BRep_Tool::Pnt(aVertex);
TRACE("X= %f;Y= %f;Z=%f \n",point.X(),point.Y(),point.Z());
[/code] -------------------------------------------------------------------

Good luck,

Dennis