简体   繁体   English

如何查找点是否在VTK中由2D非结构化网格定义的轮廓内?

[英]How to find if a point is within a contour defined by a 2D unstructured grid in VTK?

In my current problem, I want to be able to detect when a point is within a 2D vtkUnstructuredGrid or not. 在我当前的问题中,我希望能够检测点何时位于2D vtkUnstructuredGrid中。

I have tried using vtkSelectEnclosedPoints by making a vtkGeometryFilter and using it on my unstructuredGrid. 我尝试通过制作vtkGeometryFilter并在我的unstructuredGrid上使用它来使用vtkSelectEnclosedPoints。 However, the vtkSelectEnclosedPoints class is designed to check if points are located within a surface, not within a contour. 但是,vtkSelectEnclosedPoints类旨在检查点是否位于曲面内,而不是轮廓内。 Thus, when I try to apply it in 2D, I find that my points are outside of my mesh even though I know that they are located inside. 因此,当我尝试以2D方式应用它时,即使我知道点位于内部,也发现我的点在网格之外。 This is because the class inherently works in 3D. 这是因为该类固有地在3D中工作。 Is there a similar class or approach I could use to detect when points are within a 2D vtkUnstructuredGrid? 是否可以使用类似的类或方法来检测点何时位于2D vtkUnstructuredGrid中? The code is able to know the dimension of the mesh before opening it (it is a user input). 该代码能够在打开网格之前知道网格的尺寸(这是用户输入)。

So all the points in your "contour" vtkUnstructuredGrid form a single polygon? 因此,“轮廓” vtkUnstructuredGrid中的所有点都形成一个多边形? In that case you could use the vtkPolygon class, see example here . 在这种情况下,您可以使用vtkPolygon类,请参见此处的示例。 If your unstructured grid is multiple polygons, then I would still use the same thing, just iterated over all the polygons. 如果您的非结构化网格是多个多边形,那么我仍然会使用相同的东西,只是遍历所有多边形。

You could create a vtkModifiedBSPTree based on your 2D grid and perform raycasting (IntersectWithLine) for the points you want to test. 您可以基于2D网格创建vtkModifiedBSPTree,然后对要测试的点执行光线投射(IntersectWithLine)。 I have used this class for terrain models triangulated as polydata, it is extremely fast and reliable. 我将此类用于三角化为多数据的地形模型,它非常快速且可靠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM