我搜索过类似的问题,With OpenCascade, how to do a collision detection of 2 shapes fast?。
另外,下面是示例srcipts:core_geometry_minimal_distance (上面的代码)
但是,这对我来说很难有任何想法:得到一个点和一个形状之间的距离。
这里有没有一种简单的方法可以通过pythonocc得到点和形状之间的距离?
如果没有,任何人都能告诉你关于获得距离的任何想法吗?
事实上,我正在尝试让一个Adaptively Sampled Distance Fields.In成为我的理解,在制作它的过程中,点和形状之间的距离是很有必要的。
另外,有没有人能告诉我如何制作Adaptively Sampled Distance Fields
如果我解释不清楚或使用了错误的措辞,请告诉我,我会纠正它。
发布于 2021-07-13 14:01:50
一个多星期过去了。
作者展示的示例如下:
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 typehttps://stackoverflow.com/questions/68092461
复制相似问题