How to find out if a point is inside or outside a 3d model?

how to find out if a point is inside or outside 3d model?

我在网上查到有个用raycasting的交点的奇数和偶数来判断,…在Slicer里有没有特殊的方法呢?

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.

2 Likes

谢谢老师, 我也是这么想的, 就是通过segmentation染色model, 然后通过位置点的颜色判断这个点是否为model的一部分,老师有没有script的示例呢?

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?

Probably the simplest is to ask the displayable managers, for example this example script shows how to check if a position is inside a segment.

但是, 我想问的问题是"内"和"外",如果model内部有空隙, 而这个点正好位于其中,用这个方法会判断为"外"…

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…

You can fill internal holes in a segmentation using SurfaceWrapSolidify extension.

Thank you very much! :ok_hand:

这个方法确实不错, 可我还是不知道该怎么做…

This method is really good, but I still don’t know how to do it…

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.
image

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

2 Likes