File: mesh-export-mesh.py

package info (click to toggle)
python-trame 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pathlib import Path

from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader

from trame.html import vtk, vuetify
from trame.layouts import SinglePage

DATA_DIR = Path(Path(__file__).parent.parent.parent.parent, "data")
MESH_PATH = str(Path(DATA_DIR, "mesh.vtu"))

# -----------------------------------------------------------------------------
# VTK pipeline
# -----------------------------------------------------------------------------

reader = vtkXMLUnstructuredGridReader()
reader.SetFileName(MESH_PATH)

# -----------------------------------------------------------------------------
# GUI
# -----------------------------------------------------------------------------

layout = SinglePage("VTK.js rendering")
layout.title.set_text("Test mesh exchange")

with layout.content:
    with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
        with vtk.VtkView() as view:
            layout.logo.click = view.reset_camera
            with vtk.VtkGeometryRepresentation(property=("{ edgeVisibility: true }",)):
                vtk.VtkPolyData("cone", dataset=reader)

# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------

if __name__ == "__main__":
    layout.start()