Esempio n. 1
0
def build_view_child(dimensions, spacing, origin, field, enabled, i, j, k,
                     window, level):
    slice_prop = {"colorWindow": window, "colorLevel": level}
    child = [
        dash_vtk.ShareDataSet(
            dash_vtk.ImageData(
                dimensions=dimensions,
                spacing=spacing,
                origin=origin,
                children=dash_vtk.PointData(
                    dash_vtk.DataArray(registration="setScalars",
                                       values=field)),
            ), ),
    ]

    if "Volume" in enabled:
        child.append(
            dash_vtk.VolumeRepresentation(
                [dash_vtk.VolumeController(),
                 dash_vtk.ShareDataSet()], ))
    if "i" in enabled:
        child.append(
            dash_vtk.SliceRepresentation(
                iSlice=int(round(i)),
                property=slice_prop,
                children=dash_vtk.ShareDataSet(),
            ))

    if "j" in enabled:
        child.append(
            dash_vtk.SliceRepresentation(
                jSlice=int(round(j)),
                property=slice_prop,
                children=dash_vtk.ShareDataSet(),
            ))

    if "k" in enabled:
        child.append(
            dash_vtk.SliceRepresentation(
                kSlice=int(round(k)),
                property=slice_prop,
                children=dash_vtk.ShareDataSet(),
            ))

    return child
Esempio n. 2
0
# Use helper to get a volume structure that can be passed as-is to a Volume
volume_state = to_volume_state(dataset)  # No need to select field

content = dash_vtk.View([
    dash_vtk.VolumeRepresentation([
        # GUI to control Volume Rendering
        # + Setup good default at startup
        dash_vtk.VolumeController(),
        # Actual volume
        dash_vtk.ShareDataSet([
            dash_vtk.Volume(state=volume_state),
        ]),
    ]),
    dash_vtk.SliceRepresentation(iSlice=10,
                                 children=[
                                     dash_vtk.ShareDataSet(),
                                 ]),
    dash_vtk.SliceRepresentation(jSlice=10,
                                 children=[
                                     dash_vtk.ShareDataSet(),
                                 ]),
    dash_vtk.SliceRepresentation(kSlice=10,
                                 children=[
                                     dash_vtk.ShareDataSet(),
                                 ]),
])

# Dash setup
app = dash.Dash(__name__)
server = app.server
Esempio n. 3
0
    ]),
)

slice_property = {"colorWindow": 4095, "colorLevel": 1000}

slice_view = dash_vtk.View(
    id="slice-view",
    cameraPosition=[1, 0, 0],
    cameraViewUp=[0, 0, -1],
    cameraParallelProjection=False,
    background=[0.9, 0.9, 1],
    children=[
        dash_vtk.ShareDataSet(dash_vtk.Volume(state=volume_state)),
        dash_vtk.SliceRepresentation(
            id="slice-repr-i",
            iSlice=128,
            property=slice_property,
            children=dash_vtk.ShareDataSet(),
        ),
        dash_vtk.SliceRepresentation(
            id="slice-repr-j",
            jSlice=128,
            property=slice_property,
            children=dash_vtk.ShareDataSet(),
        ),
        dash_vtk.SliceRepresentation(
            id="slice-repr-k",
            kSlice=47,
            property=slice_property,
            children=dash_vtk.ShareDataSet(),
        ),
    ],
Esempio n. 4
0
                                dash_vtk.PointData(
                                    [
                                        dash_vtk.DataArray(
                                            registration="setScalars", values=field,
                                        )
                                    ]
                                )
                            ],
                        ),
                    ]
                ),
            ]
        ),
        dash_vtk.SliceRepresentation(
            property={"colorWindow": 500, "colorLevel": 200},
            iSlice=5,
            children=[dash_vtk.ShareDataSet()],
        ),
    ]
)

# Dash setup
app = dash.Dash(__name__)
server = app.server

app.layout = html.Div(
    style={"width": "100%", "height": "calc(100vh - 15px)"}, children=[content],
)

if __name__ == "__main__":
    app.run_server(debug=True)
import dash_vtk

field = [random.random() * i for i in range(10 * 10 * 10)]

content = dash_vtk.View([
    dash_vtk.SliceRepresentation(
        property={
            "colorWindow": 500,
            "colorLevel": 200
        },
        iSlice=5,
        children=[
            dash_vtk.ImageData(
                dimensions=[10, 10, 10],
                spacing=[1, 1, 1],
                origin=[-4, -4, -4],
                children=[
                    dash_vtk.PointData([
                        dash_vtk.DataArray(
                            registration="setScalars",
                            values=field,
                        )
                    ])
                ],
            ),
        ],
    ),
])

# Dash setup
app = dash.Dash(__name__)
server = app.server