一个多星期过去了。
作者展示的示例是:
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