How to take the face under the mouse cursor

Hello everyone,
I need some help. I have a drawn box and when a move the mouse over the box i want to take the face over the mouse cursor like a TopoDS_Face.I am using this source

Handle_StdSelect_ViewerSelector3d hSelector = m_pAISContext->MainSelector();
while (hSelector->More())
TopoDS_Shape myFace =(TopoDS_Shape&)Handle(AIS_Shape)::DownCast( hSelector->Picked()->Selectable() )->Shape();
But myFace is not the face under the mouse cursor but the whole box
How i can get not the whole box under the mouse cursor but only the face?

Thanks in advanced

Robert W.'s picture


I have the same problem, i would like to get the TopoDS_Face of the TopoDS_Shape Object direct under the mouse pointer. I can not seem to be able to find the solution to this problem. Has anybody got ideas on how to solve it?

qa qa's picture

As far as I know this functionality is marked as deprecated. So some kind of workaround is needed in this case.

Robert W.'s picture

Which functionality? Do you have some methodname or classname, something i could use, even if it is deprecated?

Qr Qr's picture

Try out AIS_InteractiveContext::DetectedCurrentShape().

Qr Qr's picture

A more generic code is as follows:

  // ctx is your AIS_InteractiveContext
  while (ctx->MoreSelected())
    TopoDS_Shape sh = ctx->SelectedShape();


Robert W.'s picture

Thanks, i have tried to do it totaly different way, not through AIS. As a side note - i had to set the Standard Mode to select only Faces (ctx->ActivateStandardMode(4)).