How can I select face or vertex with MeshVS_Mesh

Hello, I opened my STL file via MeshVS_Mesh and with certain display modes I can see nodes and triangles but is there way to select that triangles/surfaces and vertices one by one or multi select in certain area.

Kirill Gavrilov's picture

Default selection mode 0 would make MeshVS_Mesh selectable as a whole object. To selection mesh elements you need activating other selection modes like MeshVS_SMF_Element from MeshVS_SelectionModeFlags enumeration with help of AIS_InteractiveContext::SetSelectionModeActive() or using extended AIS_InteractiveContext::Display().

o s's picture

Hello and thanks for tip but ,I tried this way;

 Handle(MeshVS_Mesh) m_mesh;
 m_viewer->getContext()->InitSelected();
 m_viewer->getContext()->SetSelectionModeActive(mesh->m_mesh, MeshVS_SMF_Face,Standard_True);

and I tried this

    m_viewer->getContext()->Display(mesh->m_mesh,1, MeshVS_SMF_Face,true);

but I couldn't able to click on "face(s)"

Kirill Gavrilov's picture

That's strange. vselmode command should basically do the same thing and it works in Draw Harness:

pload XDE VISUALIZATION
vinit View1
meshfromstl m [locate_data_file shape.stl]
vsetdispmode m 3
vselmode m 8 1

o s's picture

I tested with my file as well and yes it is working. Do I need to "init selection" before or after, I'm kind of confused by selection.

Kirill Gavrilov's picture

Check description of AIS_InteractiveContext::InitSelected() - it has nothing to do with activating selection. It is a legacy interface to iterate over selected objects.

o s's picture

Yeah, I figured that out and also I was able to selected as well, after display object I did SetSelectionModeActive

m_viewer->getContext()->Display(mesh->m_mesh,true);
m_viewer->getContext()->SetSelectionModeActive(mesh->m_mesh, MeshVS_SMF_Face, Standard_True);

Thank you.

Mauro C's picture

Hello, I have a question on this topic:
I need to select verteices of the mesh.
I tried this :
m_viewer->getContext()->SetSelectionModeActive(mesh->m_mesh, MeshVS_SMF_Node, Standard_True);
but I am not able click a vertex.
(the same with "MeshVS_SMF_Face" runs fine)
Any suggestion for mesh verteices selection?
Thanks

Giovanni Bettega's picture

occHandle(TColStd_HPackedMapOfInteger) nodes = new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
aMesh->SetSelectableNodes(nodes);

Giovanni Bettega's picture

occHandle(TColStd_HPackedMapOfInteger) nodes = new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
aMesh->SetSelectableNodes(nodes);