python - PyVista,如何保存整个渲染结果
问题描述
使用 PyVista 时,我们可以使用mesh.save()或pyvista.save_meshio()来保存网格,但不能保存整个渲染结果。以下面的代码为例,如何保存渲染结果,而不是只保存一个网格?
from math import sin, cos, radians
import pyvista as pv
# Create source to ray trace
sphere = pv.Sphere(radius=0.85)
# Define a list of origin points and a list of direction vectors for each ray
vectors = [ [cos(radians(x)), sin(radians(x)), 0] for x in range(0, 360, 5)]
origins = [[0, 0, 0]] * len(vectors)
# Perform ray trace
points, ind_ray, ind_tri = sphere.multi_ray_trace(origins, vectors)
# Create geometry to represent ray trace
rays = [pv.Line(o, v) for o, v in zip(origins, vectors)]
intersections = pv.PolyData(points)
# Render the result
p = pv.Plotter()
p.add_mesh(sphere, show_edges=True, opacity=0.5, color="w", lighting=False, label="Test Mesh")
p.add_mesh(rays[0], color="blue", line_width=5, label="Ray Segments")
for ray in rays[1:]:
p.add_mesh(ray, color="blue", line_width=5)
p.add_mesh(intersections, color="maroon", point_size=25, label="Intersection Points")
p.show()
解决方案
合并(网格=无,合并点=真,就地=假,main_has_priority=真)
Join one or many other grids to this grid.
Grid is updated in-place by default.
Can be used to merge points of adjacent cells when no grids are input.
Parameters
grid (vtk.UnstructuredGrid or list of vtk.UnstructuredGrids) – Grids to merge to this grid.
样本:
mesh = py.PolyData()
obj = mesh.merge(grid_list)
obj.save('obj.vtk')
推荐阅读
- python - 导入 Geopandas 的问题
- d3.js - 使用 d3 和 d3-flextree 插件绘制链接
- linux - 如何使用 fpm 创建手册页?
- java - JSON 反序列化器在 POJO 中设置自定义属性
- javascript - Marklogic 中的 JavaScript 多语句事务
- entity-framework - 将新记录添加到 EF 失败并出现 NULL 列错误
- android - 如何在 LinearLayout 内设置视图高度变化的动画?
- parallel-processing - 以大于 1 的并行度运行 Flink
- linux - 如何使用 Bus、Device、Function 和 Offset 获取物理地址
- angular - 使用 adal angular 获取 azure AD 的刷新令牌