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
vtk_view = dash_vtk.View( id="vtk-view", children=[ dash_vtk.GeometryRepresentation( id="vtk-representation", children=[ dash_vtk.PolyData( id="vtk-polydata", points=points, polys=polys, children=[ dash_vtk.PointData([ dash_vtk.DataArray( id="vtk-array", registration="setScalars", name="elevation", values=elevation, ) ]) ], ) ], colorMapPreset="erdc_blue2green_muted", colorDataRange=color_range, property={ "edgeVisibility": True, }, ) ], )
dash_vtk.GeometryRepresentation( children=[ dash_vtk.PolyData( points=[ 0,0,0, 1,0,0, 0,1,0, 1,1,0, ], lines=[3, 1, 3, 2], polys=[3, 0, 1, 2], children=[ dash_vtk.PointData([ dash_vtk.DataArray( #registration='setScalars', # To activate field name='onPoints', values=[0, 0.33, 0.66, 1], ) ]), dash_vtk.CellData([ dash_vtk.DataArray( # registration='setScalars', # To activate field name='onCells', values=[0, 1], ) ]) ], ), ], ), ])
content = dash_vtk.View( [ dash_vtk.VolumeRepresentation( [ dash_vtk.VolumeController(), dash_vtk.ShareDataSet( [ 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_vtk.SliceRepresentation( property={"colorWindow": 500, "colorLevel": 200}, iSlice=5, children=[dash_vtk.ShareDataSet()], ), ]
import dash_vtk content = dash_vtk.View([ dash_vtk.VolumeRepresentation([ # GUI to control Volume Rendering # + Setup good default at startup dash_vtk.VolumeController(), # Actual Imagedata dash_vtk.ImageData( dimensions=[5, 5, 5], origin=[-2, -2, -2], spacing=[1, 1, 1], children=[ dash_vtk.PointData([ dash_vtk.DataArray( registration="setScalars", values=list(range(5*5*5)), ) ]) ], ), ]), ]) # Dash setup app = dash.Dash(__name__) server = app.server app.layout = html.Div( style={"width": "100%", "height": "calc(100vh - 15px)"}, children=[content], )
0, 0, 0, 1, 0, 1, 1, 0, ], lines=[3, 1, 3, 2], polys=[3, 0, 1, 2], children=[ dash_vtk.PointData([ dash_vtk.DataArray( registration="setScalars", name="onPoints", values=[0, 0.33, 0.66, 1], ) ]), dash_vtk.CellData([ dash_vtk.DataArray( # registration='setScalars', name="onCells", values=[0, 1], ) ]), ], ), ], ), ])
"pointSize": 10, }, colorDataRange=[0, 3], mapper={ "colorByArrayName": "Temperature", "scalarMode": 3, "interpolateScalarsBeforeMapping": True, }, children=[ dash_vtk.PolyData( id="square", points=[0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0], polys=[4, 0, 1, 2, 3], children=[ dash_vtk.PointData(children=[ dash_vtk.DataArray(name="Temperature", values=[0, 3, 2, 1]) ]) ], ) ], ), ], ), html.Div(id="output"), ], ) if __name__ == "__main__": app.run_server(debug=True)