Commit d0ddb5b0 authored by Duggan, John's avatar Duggan, John
Browse files

Move rendering into separate Trame task

parent d43f0cf9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ RUN chmod og+rwX -R /src

FROM --platform=amd64 regproxy.ornl.gov/hub_proxy/kitware/trame:py3.10-glvnd-2024-10 AS run

RUN pip install --extra-index-url https://wheels.vtk.org vtk-egl

RUN apt update && apt install -y libgl1-mesa-dev libxrender1 nginx xvfb
RUN chmod og+rwX -R /var/lib/nginx
RUN chmod og+rwX -R /var/log/nginx
@@ -40,6 +38,7 @@ COPY scripts/run_trame.sh /
COPY --from=source /src/dist /dist
RUN pip install /dist/*.whl
RUN pip install supervisor
RUN pip install --extra-index-url https://wheels.vtk.org vtk-egl

RUN python -m trame.tools.www --client-type vue3 --output /app/www-content

+1 −1
Original line number Diff line number Diff line
[tool.poetry]
name = "ctscan-viz"
version = "0.2.3"
version = "0.2.4"
description = "Template application"
authors = []
readme = "README.md"
+2 −2
Original line number Diff line number Diff line
@@ -44,12 +44,12 @@ class MainModel:

    def update_volume(self) -> None:
        # Read the slices and validate their dimensions
        start = time()
        x_range = 0
        y_range = 0
        z_range = 0
        slices = []
        for path in self.file_list:
            start = time()
            slice = get_reader(path).read()
            slices.append(slice)
            z_range += 1
@@ -63,7 +63,7 @@ class MainModel:
                        f"All slices must have the same dimensions. Expected {(x_range, y_range, 1)} but found "
                        "{slice.dimensions}."
                    )
            print(f"Read slice {z_range}/{len(self.file_list)} in {time() - start:.2f}s", flush=True)
        print(f"Read {len(slices)} slices in {time() - start:.2f}s", flush=True)

        # Create a numpy array from the slices
        start = time()
+0 −1
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ class MainViewModel:
            await sleep(0.1)

        self.render_bind.update_in_view(None)
        self.update_view()

    def load_in_background(self) -> None:
        self.model.update_volume()
+7 −1
Original line number Diff line number Diff line
"""PyVista plotter for CT scans."""

from asyncio import create_task
from time import time
from typing import Any, Optional

@@ -51,8 +52,13 @@ class VisualizationPanel:
            html.Span("Render {{ file_count }} files", v_else=True)
        view.ui(mode="server", style="height: 66vh;")

    def render(self, _: Optional[Any] = None) -> None:
    async def render_in_background(self) -> None:
        start = time()
        self.plotter.add_volume(self.vm.get_volume(), opacity="sigmoid")
        self.plotter.view_isometric(self.plotter)
        print(f"PyVista volume rendering: {time() - start:.2f}s", flush=True)

        self.vm.update_view()

    def render(self, _: Optional[Any] = None) -> None:
        self.render_thread = create_task(self.render_in_background())