实战场景
同屏三几何体对比渲染实战
在脚本 examples/06_07_render_surface_brep_mesh_scene.py 中,我们将三大几何体置于同一 3D 视口中并排展示:
- 空间平移错位:通过设置空间 X 轴位移 Offset,避免模型原点相互遮挡冲突。
- 要素标记对比:同时展现 Surface 的等值线、B-Rep 的珊瑚红顶点与淡蓝面、Mesh 的海绿节点与麦黄三角面。
- 一键调度:单次
RenderEngine.render([surf, brep, mesh]) 即可统一完成三维交互。
# 同屏对比渲染场景脚本核心逻辑 (06_07_render_...)
from src import (
HyperbolicParaboloid,
create_cube_brep,
create_pyramid_mesh,
)
import pyvista as pv
# 1. 创建参数化马鞍曲面并平移至左侧 (X = -2500)
surf = HyperbolicParaboloid(a=1500, b=1500)
surf_grid = surf.to_pyvista().translate([-2500, 0, 0])
# 2. 创建精确实体长方体并置于中央 (X = 0)
brep = create_box_brep(width=400, depth=300, height=500)
brep_poly = brep.to_pyvista()
# 3. 创建参数化四棱锥网格并平移至右侧 (X = +2500)
mesh = create_pyramid_mesh(width=500, depth=500, height=600)
mesh_poly = mesh.to_pyvista().translate([2500, 0, 0])
# 4. 同一视口分层着色绘制
plotter = pv.Plotter()
plotter.add_mesh(surf_grid, color="lightseagreen", show_edges=True)
plotter.add_mesh(brep_poly, color="lightblue", opacity=0.85)
plotter.add_mesh(mesh_poly, color="wheat", show_edges=True)
plotter.show()