0

我在 for 循环中运行以下代码,只是为了测试它:

slice1 = trimesh.intersections.slice_mesh_plane(cubo, plane_normal=triRandomVector(True), plane_origin=triRandomOrigin(cube), cap=True, cached_dots=None)

slice2 = trimesh.intersections.slice_mesh_plane(cubo, plane_normal=triRandomVector(True), plane_origin=triRandomOrigin(cube), cap=True, cached_dots=None)

union = trimesh.boolean.union([slice2, slice1], 'scad')

differenza = trimesh.boolean.difference([cube, union], 'scad')

其中 cube 是一个水密立方体的网格,函数是随机生成一个 plane_normal 和一个 plane_origin:

def triRandomVector(returnInt):
    d = [0.0, 0.0, 0.0]
    if returnInt == False:
        a = random.uniform(-1, 1)
        b = random.uniform(-1, 1)
        c = random.uniform(-1, 1)
        s = abs(a) + abs(b) + abs(c)
        d = [a/s, b/s, c/s]
    if returnInt == True:
        t = random.randint(0, 2)
        s = random.randint(1, 2)
        d[t] = 1.0*pow(-1, s)
    return d

def triRandomOrigin(mesh):
    a = random.uniform(mesh.bounds[0][0], mesh.bounds[1][0])
    b = random.uniform(mesh.bounds[0][1], mesh.bounds[1][1])
    c = random.uniform(mesh.bounds[0][2], mesh.bounds[1][2])
    d = [a, b, c]
    return d

我在 for 循环中的随机点得到的错误如下:

回溯(最近一次通话最后):

  File "/home/alessandro/ProgettoIacca/log-carving-approximator/multiCuts.py", line 191, in <module>
differenza = trimesh.boolean.difference([cube, union], 'scad')
  File "/home/alessandro/miniconda3/envs/tensorflow/lib/python3.7/site-packages/trimesh/boolean.py", line 25, in difference
result = _engines[engine](meshes, operation='difference', **kwargs)
  File "/home/alessandro/miniconda3/envs/tensorflow/lib/python3.7/site-packages/trimesh/interfaces/scad.py", line 65, in boolean
return interface_scad(meshes, script, debug=debug, **kwargs)
  File "/home/alessandro/miniconda3/envs/tensorflow/lib/python3.7/site-packages/trimesh/interfaces/scad.py", line 53, in interface_scad
result = scad.run(_scad_executable + ' $SCRIPT -o $MESH_POST')
  File "/home/alessandro/miniconda3/envs/tensorflow/lib/python3.7/site-packages/trimesh/interfaces/generic.py", line 93, in run
startupinfo=startupinfo)
  File "/home/alessandro/miniconda3/envs/tensorflow/lib/python3.7/subprocess.py", line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/openscad', '/tmp/tmpya1afsl4', '-o', '/tmp/tmpm8nk03gg.off']' returned non-zero exit status 1.

有人知道为什么会这样吗?网格似乎总是不漏水的,它似乎不依赖于网格体积(但我可能是错的),它不依赖于平面的法线。

4

0 回答 0