PyVista 几何可视化



GEMC 使用 PyVista 在 Python 中直接可视化探测器几何。 几何可以交互式查看、导出为 .vtksz 文件以用于网页展示,或渲染为截图。 完整的 API 参考请参见 PyVista API 文档。


快速开始

将示例复制到当前目录:

cp -r $GEMC_HOME/examples/basic/pyvista .
cd pyvista
./gemc_pyvista.py

交互式预览几何(会打开一个 PyVista 窗口):

./gemc_pyvista.py -pv


几何

该示例在 pyvista_basic_shapes.py 中定义了四个几何体:一个透明的容器盒、 一个实心圆柱体、一个球体,以及容器内一个经过旋转的小盒子。

交互式查看器:


用法

构建几何

./gemc_pyvista.py

python API

Pass -h for additional command line options:

options:
  -h, --help            show this help message and exit
  -f, --factory FACTORY
						ascii, sqlite
  -v, --variation VARIATION
                        Set variation name
  -r, --run RUN         Set run number
  -sql, --dbhost DBHOST
                        SQLite filename or MYSQL host
  -pv, --pyvista        Show geometry using pyvista (needs pyvista)
  -pvb, --pvb, --pyvista-background
                        Use PyVista BackgroundPlotter (needs pyqt6 pyvistaqt)
  -pvw, --width WIDTH   Set plotter width
  -pvh, --height HEIGHT
						Set plotter height
  -pvx, --x X           Set plotter x position
  -pvy, --y Y           Set plotter y position
  -axes, --add_axes_at_zero

If you have pyvista (see also install pyvista), you can use the -pv and -pvb options to display the setup without having to run GEMC


运行 GEMC

gemc pyvista.yaml -n=10

添加 -gui 可交互式运行。