VTK Implementation

Added in version 5.0.

This module provides VTK visualization implementation for NURBS-Python.

Note

Please make sure that you have installed vtk package before using this visualization module.

Class Reference

class geomdl.visualization.VisVTK.VisConfig(**kwargs)

Bases: VisConfigAbstract

Configuration class for VTK visualization module.

This class is only required when you would like to change the visual defaults of the plots and the figure.

The VisVTK module has the following configuration variables:

  • ctrlpts (bool): Control points polygon/grid visibility. Default: True

  • evalpts (bool): Curve/surface points visibility. Default: True

  • trims (bool): Trim curve visibility. Default: True

  • trim_size (int): Size of the trim curves. Default: 4

  • figure_size (list): Size of the figure in (x, y). Default: (800, 600)

  • line_width (int): Thickness of the lines on the figure. Default: 1.0

keypress_callback(obj, ev)

VTK callback for keypress events.

Keypress events:
  • e: exit the application

  • p: pick object (hover the mouse and then press to pick)

  • f: fly to point (click somewhere in the window and press to fly)

  • r: reset the camera

  • s and w: switch between solid and wireframe modes

  • b: change background color

  • m: change color of the picked object

  • d: print debug information (of picked object, point, etc.)

  • h: change object visibility

  • n: reset object visibility

  • arrow keys: pan the model

Please refer to vtkInteractorStyle class reference for more details.

Parameters:
  • obj (vtkRenderWindowInteractor) – render window interactor

  • ev (str) – event name

geomdl.visualization.VisVTK.VisCurve2D

alias of VisCurve3D

class geomdl.visualization.VisVTK.VisCurve3D(config=<geomdl.visualization.VisVTK.VisConfig object>, **kwargs)

Bases: VisAbstract

VTK visualization module for curves.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points

  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.

  • name (str) – name of the plot displayed on the legend

  • color (int) – plot color

  • color – plot index

animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

property ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:

Gets the offset value

Setter:

Sets the offset value

Type:

float

render(**kwargs)

Plots the curve and the control points polygon.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:

plot_type (str) – plot type

Returns:

number of plots defined by the plot type

Return type:

int

property vconf

User configuration class for visualization

Getter:

Gets the user configuration class

Type:

vis.VisConfigAbstract

class geomdl.visualization.VisVTK.VisSurface(config=<geomdl.visualization.VisVTK.VisConfig object>, **kwargs)

Bases: VisAbstract

VTK visualization module for surfaces.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points

  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.

  • name (str) – name of the plot displayed on the legend

  • color (int) – plot color

  • color – plot index

animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

property ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:

Gets the offset value

Setter:

Sets the offset value

Type:

float

render(**kwargs)

Plots the surface and the control points grid.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:

plot_type (str) – plot type

Returns:

number of plots defined by the plot type

Return type:

int

property vconf

User configuration class for visualization

Getter:

Gets the user configuration class

Type:

vis.VisConfigAbstract

class geomdl.visualization.VisVTK.VisVolume(config=<geomdl.visualization.VisVTK.VisConfig object>, **kwargs)

Bases: VisAbstract

VTK visualization module for volumes.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points

  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.

  • name (str) – name of the plot displayed on the legend

  • color (int) – plot color

  • color – plot index

animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

property ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:

Gets the offset value

Setter:

Sets the offset value

Type:

float

render(**kwargs)

Plots the volume and the control points.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:

plot_type (str) – plot type

Returns:

number of plots defined by the plot type

Return type:

int

property vconf

User configuration class for visualization

Getter:

Gets the user configuration class

Type:

vis.VisConfigAbstract

class geomdl.visualization.VisVTK.VisVoxel(config=<geomdl.visualization.VisVTK.VisConfig object>, **kwargs)

Bases: VisAbstract

VTK visualization module for voxel representation of the volumes.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points

  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.

  • name (str) – name of the plot displayed on the legend

  • color (int) – plot color

  • color – plot index

animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

property ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:

Gets the offset value

Setter:

Sets the offset value

Type:

float

render(**kwargs)

Plots the volume and the control points.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:

plot_type (str) – plot type

Returns:

number of plots defined by the plot type

Return type:

int

property vconf

User configuration class for visualization

Getter:

Gets the user configuration class

Type:

vis.VisConfigAbstract

geomdl.visualization.VisVTK.random() x in the interval [0, 1).