The properties available on the GeometryRepresentation let you tune the way you want to render your geometry.
In VTK a representation is composed of an Actor, a Mapper and a Property. Each of those objects can be configured using the actor, mapper and property arguments of the GeometryRepresentation.
The list below shows the default values for each argument:
On top of those previous settings we provide additional properties to configure a lookup table using one of our available colorMapPreset and a convenient colorDataRange to rescale to color map to your area of focus.
With the GeometryRepresentation you also have the option to turn on the CubeAxes using the showCubeAxes=True
along with additional configuration parameters that can be provided via the cubeAxesStyle
property. The content of the object for cubeAxesStyle can be found in the source code of vtk.js from the default section here.
GlyphRepresentation lets you use a source as a Glyph which will then be cloned and positioned at every point of another source. The properties available on the GlyphRepresentation let you tune the way you want to render your geometry.
In VTK a representation is composed of an Actor, a Mapper and a Property. Each of those objects can be configured using the actor, mapper and property arguments of the GlyphRepresentation.
The list below shows the default values for each argument:
On top of those previous settings we provide additional properties to configure a lookup table using one of our available colorMapPreset and a convenient colorDataRange to rescale to color map to your area of focus.
An example of the GlyphRepresentation could be creating a spiky sphere by positioning cones normal to the sphere.
def Example():
return dash_vtk.View(
children=[
dash_vtk.GlyphRepresentation(
mapper={'orientationArray': 'Normals'}
children=[
dash_vtk.Algorithm(
port=0,
vtkClass='vtkSphereSource',
state={
'phiResolution': 10,
'thetaResolution': 20,
},
),
dash_vtk.Algorithm(
port=1,
vtkClass='vtkConeSource'
state={
'resolution': 30,
'height': 0.25,
'radius': 0.08,
},
),
]
)
]
)
The properties available on the VolumeRepresentation let you tune the way you want to render your volume.
In VTK a representation is composed of a vtk_volume, a Mapper and a Property. Each of those objects can be configured using the actor, mapper and property arguments of the GeometryRepresentation.
The list below shows the default values for each argument:
On top of those previous settings we provide additional properties to configure a lookup table using one of our available colorMapPreset and a convenient colorDataRange to rescale to color map to your area of focus.
Because it can be cumbersome and difficult to properly configure your volume rendering properties, it is convenient to add as first child to that representation a VolumeController which will give you a UI to drive some of those parameters while also providing better defaults for your ImageData.
The VolumeController provide a convenient UI element to control your Volume Rendering settings and can be tuned with the following set of properties:
The SliceRepresentation lets you see a slice within a 3D image. That slice can be along i,j,k or x,y,z if your volume contains an orientation matrix.
The following set of properties lets you pick which slice you want to see. Only one of those properties can be used at a time.
Then we have the standard representation set or properties with their defaults:
The PointCloudRepresentation is just a helper using the following structure to streamline rendering a point cloud dataset. The code snippet below is not complete but it should provide you with some understanding of the kind of simplification that is happening under the hood.
def PointCloudRepresentation(**kwargs):
return dash_vtk.GeometryRepresentation(
id=kwargs.get('id'),
colorMapPreset=kwargs.get('colorMapPreset'),
colorDataRange=kwargs.get('colorDataRange'),
property=kwargs.get('property'),
children=[
dash_vtk.PolyData(
points=kwargs.get('xyz'),
connectivity='points',
children=[
dash_vtk.PointData([
dash_vtk.DataArray(
registration='setScalars',
values={kwargs.get('scalars')}
)
])
],
)
],
)
The set of convenient properties are as follows:
- xyz = list of xyz of each point inside a flat array
- colorMapPreset = color preset name to use
- colorDataRange = rescale color map to provided that range
- property = {} # Same as GeometryRepresentation/property
- rgb / rgba / scalars = [...]
let you define the field you want to color your point cloud with. The rgb(a) expects numbers up to 255 for each component: Red Green Blue (Alpha).
The VolumeDataRepresentation is just a helper using the following structure to streamline rendering a volume. The code snippet below is not complete but it should provide you with some understanding of the kind of simplification that is happening under the hood.
def VolumeDataRepresentation(**kwargs):
return dash_vtk.VolumeRepresentation(
id=kwargs.get('id'),
colorMapPreset=kwargs.get('colorMapPreset'),
colorDataRange=kwargs.get('colorDataRange'),
property=kwargs.get('property'),
mapper=kwargs.get('mapper'),
volume=kwargs.get('volume'),
children=[
dash_vtk.VolumeController(
rescaleColorMap=kwargs.get('rescaleColorMap'),
size=kwargs.get('size'),
),
dash_vtk.ImageData(
dimensions=kwargs.get('dimensions'),
origin=kwargs.get('origin'),
spacing=kwargs.get('spacing'),
children=[
dash_vtk.PointData([
dash_vtk.DataArray(
registration='setScalars',
values=kwargs.get('scalars'),
)
])
],
),
],
)
The set of convenient properties are as follows:
- dimensions: Number of points along x, y, z
- spacing: Spacing along x, y, z between points in world
- origin: World coordinate of the lower left corner of your vtkImageData (i=0, j=0, k=0).
- rgb: Use RGB values to attach to the points/vertex
- rgba: Use RGBA values to attach to the points/vertex
- scalars: Field values to attach to the points
- scalarsType: Types of numbers provided in scalars (i.e. Float32Array, Uint8Array, …)
- mapper: Properties to set to the mapper
- volume: Properties to set to the volume
- property: Properties to set to the volume.property
- colorMapPreset: Preset name for the lookup table color map
- volumeController: Show volumeController
- controllerSize: Controller size in pixels
- rescaleColorMap: Use opacity range to rescale color map