提问人:Bulbasaur 提问时间:8/30/2023 最后编辑:Bulbasaur 更新时间:8/30/2023 访问量:101
使用 pyvista 时内核崩溃。PolyDataFilters.boolean_union()
Kernel Crash when using pyvista.PolyDataFilters.boolean_union()
问:
我正在尝试将两个简单建筑物的网格组合在一起,使它们成为“一体”,没有封闭的表面。我尝试使用 pyvista 提供的 boolean_union 操作。使用 .merge() 时,此代码工作正常:
import numpy as np
import pyvista as pv
building_1 = np.array([
[52.56, 42.43, 6],
[102.47, 42.43, 6],
[102.47, 12.13, 6],
[52.56, 12.13, 6],
[52.56, 42.43, 0],
[102.47, 42.43, 0],
[102.47, 12.13, 0],
[52.56, 12.13, 0]
])
building_2 = np.array([
[94.67, 12.13, 6],
[94.67, 0, 6],
[52.56, 0, 6],
[52.56, 12.13, 6],
[94.67, 12.13, 0],
[94.67, 0, 0],
[52.56, 0, 0],
[52.56, 12.13, 0]
])
building1_polydata = pv.PolyData(building_1)
building1_mesh = building1_polydata.delaunay_3d()
building1_surface = building1_mesh.extract_surface()
building1_triangulated = building1_surface.triangulate()
building2_polydata = pv.PolyData(building_2)
building2_mesh = building2_polydata.delaunay_3d()
building2_surface = building2_mesh.extract_surface()
building2_triangulated = building2_surface.triangulate()
test=building2_triangulated.merge(building1_triangulated)
test.plot(show_edges=True, opacity=0.5, color="gray")
但返回具有封闭曲面的网格。所以我尝试使用boolean_union操作,它旨在做我想做的事,但它会导致内核崩溃:
test=building2_triangulated.boolean_union(building1_triangulated)
我不明白为什么会这样。使用以下方法时确实会检测到碰撞:
building2_triangulated.collision(building1_triangulated)
所以它应该起作用吗?为什么会发生这种奇怪的内核崩溃?有没有解决方法?
答: 暂无答案
评论
building2_triangulated.translate([1e-3, 1e-3, 1e-3]).boolean_union(building1_triangulated).clean()
.clean(tolerance=1e-2)