如何在 pythonocc-core 中获取点和形状之间的距离?

How to get the distance between a point and a shape in pythonocc-core?

我搜索过类似的问题,With OpenCascade, how to do a collision detection of 2 shapes fast?

此外,这里是示例脚本:core_geometry_minimal_distance(上面的代码)

但是,我很难理解:获取点和形状之间的距离。

这里有没有简单的方法通过pythonocc获取点和形状之间的距离?

如果没有,任何人都可以告诉任何关于获得距离的想法吗?

事实上,我正在尝试制作一个Adaptively Sampled Distance Fields。据我了解,在制作过程中需要获得点和形状之间的距离。

还有,谁能告诉我如何制作 Adaptively Sampled Distance Fields

如果我没有解释清楚或用词不正确,请告诉我,我会改正。

一个多星期过去了。

作者展示的例子是:

https://github.com/tpaviot/pythonocc-demos/blob/master/examples/core_geometry_minimal_distance.py

只需使用 BRepBuilderAPI_MakeVertex 制作一个形状,该形状只是一个点,可以将示例 code.such 中的方框替换为 :


from OCC.Core.BRepExtrema import BRepExtrema_DistShapeShape
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCC.Display.SimpleGui import init_display
from OCC.Core.gp import gp_Pnt, gp_Ax2, gp_Circ

from OCC.Extend.ShapeFactory import make_edge, make_vertex

def compute_minimal_distance_between_cubes(b1,b2):
    display.DisplayShape([b1, b2])

    dss = BRepExtrema_DistShapeShape()
    dss.LoadS1(b1)
    dss.LoadS2(b2)
    dss.Perform()

    assert dss.IsDone()

    return dss.Value()


_point_pnt = gp_Pnt(x, y, z)

vtx = BRepBuilderAPI_MakeVertex(_point_pnt).Shape() # shape type