How to get detected face in neutral point



as far as i know the local context is deprecated and all of the functionality should be available in neutral point. I want to make it visible ,which TopoDS_Face object is under the mouse and be able to get the underlying TopoDS_Face object.

In local context i was able to achieve both things by:

  1. Opening a local context and setting ActivateStandardMode to TopAbs_Face
  2. ​Calling DetectedShape() on my interactive context

The both things are not possible withing a neutral point (the code makes a return when no local context is open).

The first thing (highlight functionality) i was able to achieve by calling Activate on my SelectionManager and setting it to TopAbs_Face. The only problem is that i need to do it to all AIS_Shapes, and not like in local context set it globally for all.

I can live with that (unless someone has better idea how to achieve the same thing)

The second thing i dont seem able to achieve. I do not know how to get the underlying TopoDS_Face object.


Any help or ideas?

Kirill Gavrilov's picture

OCCT selection mechanism uses Owner (SelectMgr_EntityOwner) for identifying entire Object (normal selection, usually mode 0) or its part (local selection - e.g. sub-shapes within AIS_Shape). So to retrieve selection results you need to use methods having Owner in name - AIS_InteractiveContext::SelectedOwner() for selected parts and ::DetectedOwner() for detected parts.

You may also notice many methods accepting SelectMgr_EntityOwner as an argument like ::IsSelected() and the same methods accepting AIS_InteractiveObject which redirects to SelectMgr_EntityOwner since it is what selection really works with.

Owner objects created by interactive Objects within method AIS_InteractiveObject::ComputeSelection(), and thus depend on presentation class implementation. AIS_Shape creates Owner objects of class StdSelect_BRepOwner storing TopoDS_Shape as class field. So if you need TopoDS_Shape, you may cast SelectMgr_EntityOwner to StdSelect_BRepOwner and access its shape through getter. This will be either original shape of AIS_Shape (within global selection of entire object) or its sub-shape (local selection) without presentation local transformation being applied.

Robert W.'s picture

Thank you for your fast reply. I have already implemented it by getting the picked elements from my MainSelector object (because it had access to the current Sensitive Entities). Your way seems more logical, i am going to look into that.

Now i fear i may have made a mistake by setting my Highlight mode on the SelectionManager for all AIS_Shapes. It has a following bug - the objects that are hidden (Erase method on the AIS_Context) can be highlighted, which means, sub-parts get the hover effect, in spite of the objects not being visible,

I have already seen, that the Activate/Deactivate methods on the AIS_InteractiveContext set this selection mode only for visible objects. In my particular case, i need it to be set also for the 3D Models that are not visible (because the user can make it visible anytime).