【问题标题】:How to get the distance between a point and a shape in pythonocc-core?如何在pythonocc-core中获取点和形状之间的距离?
【发布时间】:2021-09-06 13:45:59
【问题描述】:

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

另外,这里是示例 srcipts:core_geometry_minimal_distance(上面的代码)

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

这里有一个简单的方法可以通过pythonocc获取点和形状之间的距离吗?

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

其实我是在尝试做一个Adaptively Sampled Distance Fields。据我了解,在制作的过程中,点和形状之间的距离是有必要的。

另外,谁能告诉任何关于如何制作Adaptively Sampled Distance Fields 的想法?

如果我没有解释清楚或使用了错误的措辞,请告诉我,我会改正的。

【问题讨论】:

  • 我可以尝试通过遍历和比较来获取点和面之间的距离。或者使用球替换点。如果没有简单的方法。

标签: python-3.x pythonocc


【解决方案1】:

一个多星期过去了。

作者展示的例子是:

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

只需使用BRepBuilderAPI_MakeVertex 制作一个形状,它只是替换示例代码中的框的一个点。例如:


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

【讨论】:

    猜你喜欢
    • 2017-01-08
    • 2021-06-27
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    • 2017-07-10
    • 2011-05-28
    • 2014-01-21
    相关资源
    最近更新 更多