How to select specific tetrahedron cells from mesh

If you have a mesh created from segmentmesher. how can you select the tetrahedron cells.

With the mouse? By index? How do you want to select the cell?

Two possible examples at the VTK level that might help are:

https://lorensen.github.io/VTKExamples/site/Cxx/Picking/HighlightSelection/
https://lorensen.github.io/VTKExamples/site/Cxx/Picking/HighlightSelectedPoints/

how to select with the mouse in the slicer scene, selecting cells and then coloring it and then having those cells and their positions in a file

You can use a picker to get cell IDs from mouse coordinates (see links that @adamrankin provided above). You can retrieve cell positions based on the IDs from the VTK mesh object. Add a cell array to your mesh and set different values for selected and non-selected cells. You can use this array to color the selected and non-selected cells differently.

how to interact with the 3d slice view of slicer. I have a mesh in 3d slice view. need to select some cells from it and change the colors of those selected cells.

I tried using the vtkcellpicker, but I dont understand the addobserver.

the addobserver of vtkcellpicker takes 2 arguments. first is the event and second is the method. Am I right?

Please help further. are there any examples related to slicer 3d view

This example should do most of what you need:

https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_scalar_values_at_surface_of_a_model

Hi andras,
How to select tetrahedrons in a mesh using another mesh through a python script.

Thank you

Regards,
Saima safdar

You can follow this example: Documentation/Nightly/ScriptRepository - Slicer Wiki

In a volumetric mesh, cells are tetrahedra, so probably the code will work without modification.

Hi Andras,
After selecting tetrahedrons. How to remove the selected tetrahedrons and have the unstructured grid remain without those deleted ones. example removing tumore cells from the brain mesh. how to retain the brain geometry.

regards,
Saima Safdar

You can either use vtkThreshold (cells that need to be deleted are identified by the value of a designated cell data array) or vtkExtractCells (cells that need to be deleted are identified by a cell ID list).

1 Like

Hi Andras,
Could you please see the post

I created it seperately as I could not find any thing related to it on the forum.

Thank you

Regards,
Saima Safdar