Selection Mode TopAbs_FACE & TopAbs_EDGE Together

Hello OCCT Community,

I've used "Selection Mode" with my AIS_InteractiveContext and when I assign "TopAbs_FACE" to the SelectionMode method (it can be seen below code block and the image of TopAbs_FACE), I am able to acquire the faces of my mesh object:

ais_interactive_context_->Display (XCAF_Prs_AIS_object_, AIS_Shaded, 0, true);
ais_interactive_context_->Activate(ais_shape, ais_shape->SelectionMode( TopAbs_FACE));

Similarly, when I assign "TopAbs_EDGE" to the "SelectionMode" method (it can be also seen below code block and the image of TopAbs_EDGE), I could acquire the edges of my mesh:

object.ais_interactive_context_->Display (XCAF_Prs_AIS_object_, AIS_Shaded, 0, true);
ais_interactive_context_->Activate(ais_shape, ais_shape->SelectionMode( TopAbs_EDGE));

However, I am not able to using them (i.e. TopAbs_EDGE & TopAbs_FACE altogether) into the "SelectionMode" method. How can I handle this issue? My intention is that when navigating with the mouse, the edges are selectable if I'm on the edges, and the surfaces are selectable if I'm on the surface.

Thank you in advance!

Kirill Gavrilov's picture

Selection mode passed to AIS_InteractiveContext::Activate() is a single mode, not a bitmask. To activate multiple modes at once you need calling the method multiple times.
If you would like activating only single mode at a time, you need deactivating previously activated modes or to use AIS_SelectionModesConcurrency_Single for AIS_InteractiveContext::SetSelectionModeActive().

Not every combination of selection modes would work as expected.

Hakan Kaya's picture

You can create a global SELECTION_MODE variable. You can update this global variable with the toolbar or the button you want to add wherever you want. You can activate the selection mode of the objects displayed after each update with the signal-slot relationship.
 

Example:

enum struct OPERATION_MODE {
    TRANSLATE,
    ROTATE,
    SCALE,
    NOTHING,
    MEASURE,
};
enum struct SELECTION_MODE {
    VERTEX,
    EDGE,
    FACE,
    BODY,
};
Tim Tu's picture

Did you solve this problem?

Nezihe Sözen's picture

Hello Tim,

Yes, I had solve this problem thanks to Kirill's advice:

Handle(SelectMgr_EntityOwner) detected_entity_owner = ais_interactive_context_->DetectedOwner();
    Handle(StdSelect_BRepOwner) selected_brep_owner = Handle(StdSelect_BRepOwner)::DownCast (detected_entity_owner);

    if (!selected_brep_owner.IsNull() && selected_brep_owner->Shape().ShapeType() == TopAbs_FACE){
        face_sub_shape_ =  TopoDS::Face(selected_brep_owner->Shape());
        LOG(" Selected shape owner is not NULL and its type is FACE");
    }else if(!selected_brep_owner.IsNull() && selected_brep_owner->Shape().ShapeType() == TopAbs_VERTEX){
        LOG(" Selected shape owner is not NULL and its type is VERTEX");
        vertex_sub_shape_ =  TopoDS::Vertex(selected_brep_owner->Shape());
    }

Regards,

Nezihe