DiscussionsIssue archiveVisualization and 3D Viewer

Archived discussion

How can I select face or vertex with MeshVS_Mesh

Visualization and 3D ViewerSat, 11/27/2021 - 09:1010 replies

Browse this forum
QuestionAuthor

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.

Discussion

10 archived replies

Posts are displayed in their archived order.

01Commenter-1

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().

02Author

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)"

03Commenter-1

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

Archived image: external image

04Author

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.

05Commenter-1

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

06Author

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.

07Commenter-2

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

08Commenter-3

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

09Commenter-3

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

10Commenter-4

How to get the selected mesh nodes?