Skip to content
Michael Keilman edited this page Jul 20, 2022 · 16 revisions

in progress

VTK is open-source 3D rendering code authored by KitWare. We use it to visualize particle trajectories in WarpVND, magnets in Radia, and beamlines in SRW

dev most active on c++ (link) - can be useful to see what is available

we use javascript (link) which is typically behind the c++

we update on major version releases (x of x.y.z) (or soon thereafter) because they release several per day

class wrappers for ease of use

API

sirepo-vtk-plotting.js

VTKUtils

Collection of static methods and fields related to vtk

Constructor

new VTKUtils()

Source:

Methods

(static) buildBoundingBox(bounds, padPct) → {BoxBundle}

Builds a wireframe box with the specified bounds and optional padding

Parameters:
Name Type Default Description
bounds Array.<number> the bounds in the format [xMin, xMax, yMin, yMax, zMin, zMax]
padPct number 0 additional padding as a percentage of the size

Source:

Returns:

Type
BoxBundle

(static) buildOrientationMarke(actor, interactor, location) → {vtk.Interaction.Widgets.vtkOrientationMarkerWidget}

Makes an orientation widget out of the given vtk actor and interactor, placed in the given corner of the viewport

Parameters:
Name Type Description
actor vtk.Rendering.Core.vtkActor vtk actor
interactor vtk.Rendering.Core.vtkRenderWindowInteractor interactor from a render window
location vtk.Interaction.Widgets.vtkOrientationMarkerWidget.Corners which corner to place the widget

Source:

Returns:

Type
vtk.Interaction.Widgets.vtkOrientationMarkerWidget

(static) colorToFloat(hexStringOrArray) → {Array.<number>}

Converts a string or an array of floats to an array of floats using vtk's conversion util, for use in colors

Parameters:
Name Type Description
hexStringOrArray string | Array.<number> a color string (#rrggbb) or array of floats

Source:

Returns:

- array of floats ranging from 0 - 1.

Type
Array.<number>

(static) colorToHex(hexStringOrArray) → {string}

Converts a string or an array of floats to a string using vtk's conversion util, for use in colors

Parameters:
Name Type Description
hexStringOrArray string | Array.<number> a color string (#rrggbb) or array of floats

Source:

Returns:

- a color string (#rrggbb)

Type
string

(static) interactionMode() → {Object}

Modes when interacting with the vtk canvas

Source:

Returns:

- interactionModes

Type
Object

(static) userMatrix() → {Array.<Array.<number>>}

Creates a vtk user matrix from a SquareMatrix. * @param {SquareMatrix} matrix - vtk actor

Source:

Returns:

Type
Array.<Array.<number>>

Documentation generated by JSDoc 3.6.10 on Wed Jul 13 2022 15:19:06 GMT+0000 (GMT)

VTKScene

(generated jsdoc)

ActorBundle

A convenient object bundling a source, actor, and mapper, which almost always appear together anyway

Constructor

new ActorBundle(source, transform, actorProperties)

Parameters:
Name Type Description
source * a vtk source, reader, etc.
transform SIREPO.GEOMETRY.Transform a Transform to translate between "lab" and "local" coordinate systems
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Members

actor :vtk.Rendering.Core.vtkActor

the transform

Type:
  • vtk.Rendering.Core.vtkActor

Source:

actorProperties :vtk.Rendering.Core.Property

properties of the actor

Type:
  • vtk.Rendering.Core.Property

Source:

mapper :vtk.Rendering.Core.vtkMapper

a mapper

Type:
  • vtk.Rendering.Core.vtkMapper

Source:

transform :SIREPO.GEOMETRY.Transform

the transform

Type:
  • SIREPO.GEOMETRY.Transform

Source:

Methods

actorBoundingBox(padPct) → {BoxBundle}

Builds a wireframe box around this actor, with optional padding

Parameters:
Name Type Default Description
padPct number 0 additional padding as a percentage of the size

Source:

Returns:

Type
BoxBundle

getActorProperty(name) → {*}

Gets the value of the actor property with the given name

Parameters:
Name Type Description
name string the name of the property

Source:

Returns:

Type
*

setActorProperty(name, value)

Sets the actor property with the given name to the given value

Parameters:
Name Type Description
name string the name of the property
value * the value to set

Source:

setColor(color)

Convenience method for setting the color. Uses colorToFloat to convert

Parameters:
Name Type Description
color string | Array.<number>

Source:

setMapper(mapper)

Sets the mapper for this bundle as well as the actor

Parameters:
Name Type Description
mapper vtk.Rendering.Core.vtkMapper

Source:

setSource(source)

Sets the source for this bundle. Also sets the mapper's input connection to the source's output

Parameters:
Name Type Description
source * vtk source

Source:

Documentation generated by JSDoc 3.6.10 on Wed Jul 13 2022 15:19:06 GMT+0000 (GMT)

BoxBundle

A bundle for a cube source

Constructor

new BoxBundle(labSize, labCenter, transform, actorProperties)

Parameters:
Name Type Description
labSize Array.<number> array of the x, y, z sides of the box in the lab
labCenter Array.<number> array of the x, y, z coords of the box's center in the lab
transform SIREPO.GEOMETRY.Transform a Transform to translate between "lab" and "local" coordinate systems
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Methods

setCenter(labCenter)

Sets the center of the box

Parameters:
Name Type Description
labCenter Array.<number> array of the x, y, z coords of the box's center in the lab

Source:

setSize(labSize-)

Sets the size of the box

Parameters:
Name Type Description
labSize- Array.<number> array of the x, y, z lengths of the box

Source:

Documentation generated by JSDoc 3.6.10 on Wed Jul 13 2022 15:19:06 GMT+0000 (GMT)

CoordMapper

Provides a mapping from "lab" coordinates to vtk's coordinates via a SIREPO.GEOMETRY.Transform. Also wraps the creation of various Bundles so the transform gets applied automatically

Constructor

new CoordMapper(transform)

Parameters:
Name Type Description
transform SIREPO.GEOMETRY.Transform a Transform to translate between "lab" and "local" coordinate systems

Source:

Methods

buildActorBundle(source, transform, actorProperties)

Creates a Bundle from an arbitrary source

Parameters:
Name Type Description
source * a vtk source, reader, etc.
transform SIREPO.GEOMETRY.Transform a Transform to translate between "lab" and "local" coordinate systems
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

buildBox(labSize, labCenter, actorProperties) → {BoxBundle}

Builds a box

Parameters:
Name Type Description
labSize Array.<number> array of the x, y, z sides of the box in the lab
labCenter Array.<number> array of the x, y, z coords of the box's center in the lab
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Returns:

Type
BoxBundle

buildLine(labP1, labP2, actorProperties) → {LineBundle}

Builds a line

Parameters:
Name Type Description
labP1 Array.<number> 1st point
labP2 Array.<number> 2nd point
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Returns:

Type
LineBundle

buildPlane(labOrigin, labP1, labP2, actorProperties) → {LineBundle}

Builds a plane

Parameters:
Name Type Description
labOrigin Array.<number> origin
labP1 Array.<number> 1st point
labP2 Array.<number> 2nd point
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Returns:

Type
LineBundle

buildSphere(labCenter, radius, actorProperties) → {SphereBundle}

Builds a sphere

Parameters:
Name Type Description
labCenter Array.<number> center in the lab
radius number
actorProperties Object a map of actor properties (e.g. 'color') to values

Source:

Returns:

Type
SphereBundle

Documentation generated by JSDoc 3.6.10 on Wed Jul 13 2022 15:19:06 GMT+0000 (GMT)

Also see sirepo-geometry.js

Clone this wiki locally