I found on the Internet that there is a use of raycasting to judge the odd and even numbers of the intersection points… but I want to know are there some special methods in Slicer?
The simplest is to use vtkImplicitPolyDataDistance, as it is shown in this example. It may struggle (can be slow and unreliable) if the mesh is complex or has errors.
The fastest and most robust method is to convert the model to a labelmap (by importing to segmentation and exporting to labelmap) and then check if the voxel corresponding to the probed position is inside the volume and has non-zero label value.
Thank you, teacher, I think so too, that is to dye the model through segmentation, and then judge whether the point is part of the model by the color of the position point. Does the teacher have an example of script?
However, the question I want to ask is “inside” and “outside”. If there is a gap inside the model, and this point is located in it, it will be judged as “outside” by this method…
Open the “Segmentations” module and go down the “Export/import mdels and labelmaps” section. Choose “Import” and “Models”, and select the model you want to convert as the “Input node”. Then press the “Import” button.
This will create a new segment in the segmentation corresponding to the interior of your model. You can then export that to a new labelmap by using the same section of the Segmentations module; just choose “Export” and “Labelmap” instead of import and models, and then click the “Export” button (leaving “Export to new labelmap” selected as the “Output node”).