How to judge whether a point in a space is in the ROI?

How to judge whether a point in a space is in the ROI?

没人回…换一个方式吧.怎么得到ROI的bounds,就是说那6个顶点的坐标呢

No reply… I change the qestion to … how to get the bounds of the ROI, that is to say the coordinates of the 6 vertices?..

我想把ROI先转换成vtkcube, 再用IsInsideSurface这个方法去判断,可是没成功…哪位大神帮帮我

I want to convert the ROI to vtkcube first, and then use the method IsInsideSurface in VTK: vtkSelectEnclosedPoints Class Reference to judge, but it didn’t work…Which god can help me?

@lassoan@Juicy@jamesobutler @jcfr @pieper

我试了一下GetPolyData()这个方法,得到了一条线段

I tried the method GetPolyData() to annotation ROI and got a line segment…

The annotations ROI stores center and corner point (radius) so you can check if the point is inside center +/- radius in each dimension.

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#write-annotation-roi-to-json-file

If you use the new markups ROI node then you can get an implicit function that you can use to quickly query points (and also use in all VTK filters that take implicit functions as inputs). Example:

roiNode = getNode('R')
point = [73,45,-1181]

planes = vtk.vtkPlanes()
roiNode.GetPlanes(planes)
isInside = planes.EvaluateFunction(point) < 0
print(f"Point {point} is {'inside' if isInside else 'outside'}")

The sign of the implicit function returns distance from the ROI boundary. Negative value means that the point is inside.

1 Like

This method is wonderful! Thank you God