ubuntu 22.04 编译 OSMESA & ParaView

可选 更新MESA驱动

编译安装 OSMESA

编译安装 ParaView

依赖项

# TBB 手动安装
sudo apt install libopenmpi-dev # libtbb-dev
git clone https://gitlab.kitware.com/paraview/paraview.git
git submodule update --init --recursive

cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DVTK_SMP_IMPLEMENTATION_TYPE=TBB -DCMAKE_BUILD_TYPE=Release ..
ninja -j6
sudo ninja install

测试代码

import paraview.simple


def main():
    render_view = paraview.simple.GetActiveViewOrCreate('RenderView')
    render_view.ViewSize = [1920, 1080]

    sphere = paraview.simple.Sphere()
    sphere_display = paraview.simple.Show(sphere, render_view)
    sphere_display.DiffuseColor = [1.0, 0.0, 0.0]

    render_view.CameraPosition = [-5.0, 0.0, 0.0]
    render_view.CameraFocalPoint = [0.0, 0.0, 0.0]
    render_view.CameraViewUp = [0.0, 0.0, 1.0]
    render_view.CameraParallelScale = 1.0

    paraview.simple.SaveScreenshot('./test.png', render_view)


if __name__ == '__main__':
    main()
posted @ 2023-07-16 23:30  山岚2013  阅读(275)  评论(0编辑  收藏  举报