Module EasyVtk
In: easy_vtk.rb

The EasyVtk module provides methods to draw 3D graph easily using VTK

Authors:Seiya Nishizawa,
Version:0.1 2006-05-11 seiya

Methods

Constants

With_narray = true
With_narray = false

Public Instance methods

Method for clearing actors

 Clears actors
  • Arguments
    • none
  • Return
    • nil

Method for clearing color lookup table

 Clears color lookup table
  • Arguments
    • none
  • Return
    • nil

Method for drawing colorbar

 Draws colorbar
  • Arguments
    • none
  • Optional arguments
    • options (Hash)
      • options[‘orientation’] (String)
        • ‘horizontal’: Sets orientation of colorbar to horizontal
        • ‘vertical’: Sets orientation of colorbar to vertical
      • options[‘height’] (Numeric)
      • options[‘width’] (Numeric)
      • options[‘position’] (Array)
        • position of bottom-left corner of colorbar (between 0 and 1) length must be 2.
  • Return
    • nil

Method for drawing contour surfaces

 Draws contour surfaces
  • Arguments
    • num (Fixnum)
    • min (Numric)
      • minimum value of range for contour
    • max (Numric)
      • maxmum value of range for contour
  • Optional arguments
    • options (Hash)
      • options[‘opacity’] (Numeric)
        • opacity of the surface from 0 (no transparency) to 1 (full transparency)
      • options[‘axes’] (true|false or Hash)
        • If this is true or Hash, draws axes.
          • true
            • draw axes with default properties
          • options[‘axes’][‘format’] (String)
            • format of label (ex. ’%4.2f’)
          • options[‘axes’][‘factor’] (Numric)
            • factor of label size
          • options[‘axes’][‘color’] (Array[Numeric,Numeric,Numeric])
            • RGB of axes ([red, green, blue])
  • Return
    • nil

Method for creating color lookup table automatically

 creats color lookup table automatically
  • Arguments
    • min (Numeric)
      • minimum value of data for color map
    • max (Numeric)
      • maximum value of data for color map
  • Optional arguments
    • hue_range (Array)
      • range in hue (between 0 and 1) length must be 2
    • saturation_range (Array)
      • range in saturation (between 0 and 1) length must be 2
    • value_range (Array)
      • range in value (between 0 and 1) length must be 2
    • alpha_range (Array)
      • range in alpha (between 0 and 1) length must be 2
  • Return
    • nil

Method for drawing fixed text

 Draws fixed text
  • Arguments
    • str (String)
    • x (Numeric)
      • x-position of text
    • y (Numeric)
      • y-position of text
  • Optional Arguments
    • options
      • options[‘vertical_justification’] (String)
        • ‘bottom’: Sets vertical justification to bottom
        • ‘top’: Sets vertical justification to top
        • ‘centered’: Sets vertical justification to centered
      • options[‘horizontal_justification’] (String)
        • ‘bottom’: Sets horizontal justification to bottom
        • ‘top’: Sets horizontal justification to top
        • ‘centered’: Sets horizontal justification to centered
      • options[‘color’] (Array)
        • RGB of axes length must be 3
  • Return
    • nil

Method for starting drawing and GUI

 Starts drawing and GUI
  • Arguments
    • none
  • Block (optional)
    • this execute when ‘return’ key pressed
  • Return
    • nil

Method for initialization of EasyVtk

 In the initialization,
 Vtk::Renderer, Vtk::RenderWindow, and Vtk::RenderWindowInteractior are made,
 and set to module variable.
  • Arguments
    • none
  • Return
    • nil

Method for looping of drawing

 Starts loop for drawing
  • Arguments
    • count (Integer)
  • Optional arguments
    • interval (Numeric)
      • seconds for sleep after execution given block
    • clear (true|false)
      • set true if you want to clear actors
  • Block
    • block arugument is current count of loop
  • Return
    • nil

Method for drawing plane

 Draws tone of a plane
  • Arguments
    • origin (Array)
      • point of origin of plane to be drawn length of origin must be 3.
    • normal (Array)
      • vector of normal of plane to be drawn length of origin must be 3.
  • Optional arguments
    • options (Hash)
      • options[‘opacity’] (Numeric)
        • opacity of the surface from 0 (no transparency) to 1 (full transparency)
      • options[‘axes’] (true|false or Hash)
        • If this is true or Hash, draws axes.
          • true
            • draw axes with default properties
          • options[‘axes’][‘format’] (String)
            • format of label (ex. ’%4.2f’)
          • options[‘axes’][‘factor’] (Numric)
            • factor of label size
          • options[‘axes’][‘color’] (Array[Numeric,Numeric,Numeric])
            • RGB of axes ([red, green, blue])
  • Return
    • nil

Method for saveing image file

 Saves window image to file
  • Arguments
    • filename (String)
      • filename to be saved
  • Optional arguments
    • type (String)
      • image type to be saved
  • Return
    • nil

Method for setting array of axes

 Vtk::RectilineraGrid is made.
 Sets the three arrays of x, y and z axes.
 Length of the all arrays must be the same.
  • Arguments
    • x (Vtk::DataArray or NArray)
      • array of values of x axis
    • y (Vtk::DataArray or NArray)
      • array of values of y axis
    • z (Vtk::DataArray or NArray)
      • array of values of z axis
  • Optional arguments
    • scale (Array)
      • array of three compornents for scale to draw
  • Return
    • nil

Method for setting background color of window

 Sets the background color of window.
  • Arguments
    • red (Numeric)
      • red compornent of RGB form 0 to 1
    • green (Numeric)
      • green compornent of RGB form 0 to 1
    • blue (Numeric)
      • blue compornent of RGB form 0 to 1
  • Return
    • nil

Method for setting position of camera

 Sets the position of the camera in world coordinate
  • Arguments
    • x (Numeric)
      • x coordinates of the position
    • y (Numeric)
      • y coordinates of the position
    • z (Numeric)
      • z coordinates of the position
  • Return
    • nil

Method for setting array of scalar data

 Sets the array of scalar data.
  • Arguments
    • data (Vtk::DataArray or NArray)
      • array of values of data Length of the array must be (length of x axis)*(length of y axis)*(length of z axis) set by set_axes or set_grid. If the class is NArray, its rank must be 1.
  • Optional arguments
    • options (Hash)
      • options[‘type’] (String)
        • ‘scalar’ : data type is scalar
        • ‘vector’ : data type is vector
  • Return
    • nil

Method for setting array of grid points

 Vtk::StructuredGrid is made.
 Sets the three arrays of x, y and z of grid points.
 Length of the all arrays must be the same as that of data.
  • Arguments
    • x (Vtk::DataArray or NArray)
      • array of values of x coordinate of grid points
    • y (Vtk::DataArray or NArray)
      • array of values of y coordinate of grid points
    • z (Vtk::DataArray or NArray)
      • array of values of z coordinate of grid points
    • shape (Array)
      • array of three components of grid
  • Optional arguments
    • scale (Array)
      • array of three components for scale to draw
  • Return
    • nil

Method for setting window size

 Sets the size of window.
  • Arguments
    • width (Numeric)
      • width of window
    • height (Numeric)
      • height of window
  • Return
    • nil

Method for drawing sphere

 Draw sphere surface
  • Arguments
 * radius (Numeric)
   * radius of sphere to be drawn
  • Optional arguments
 * resolution (Numeric)
   * resolution of sphere to be drawn
  • Return
 * nil

Method for drawing streamline

 Draws streamline
  • Arguments
    • point (Array)
      • start point length of point must be 3.
    • time (Numeric)
      • time for integration
    • ds (Numeric)
      • length of line segments to be drawn
  • Optional arguments
    • options (Hash)
      • options[‘accuracy’] (Numric)
        • accuracy of integration (from 0 to 1)
      • options[method’] (String)
        • integration method
          • ‘rk2’ : RungeKutta2
          • ‘rk4’ : RungeKutta4
          • ‘rk45’: RungeKutta45
      • options[‘direction’] (String)
        • direction of integration
          • ‘forward’ : integrate forward
          • ‘backward’: integrate backward
          • ‘both’ : integrate forward and backward
      • options[‘color’] (Array)
      • options[‘type’] (String)
        • type of line
          • ‘line‘
          • ‘ribbon‘
          • ‘tube‘
      • options[‘width’] (Numeric)
        • width of ribbon or tube
      • options[‘normal’] (Array)
        • vector of normal of ribbon or tube length of origin must be 3.
      • options[‘vary’] (String)
        • ‘off’ : disable variation of ribbon or tube width
        • ‘scalar’: variation of ribbon or tube width with scalar value
        • ‘vector’: variation of tube width with vector value (only for tube)
      • options[‘vary_factor’] (Numeric)
        • the maximum ribbon or tube width in terms of a multiple of the minimum width
      • options[‘tube_sides’] (Integer)
        • number of sides of tube
  • Return
    • nil

Method for drawing surface

 Draw isosurface
  • Arguments
    • value (Numeric)
      • value of isosurface
  • Optional arguments
    • options (Hash)
      • options[‘opacity’] (Numeric)
        • opacity of the surface from 0 (no transparency) to 1 (full transparency)
      • options[‘axes’] (true|false or Hash)
        • If this is true or Hash, draws axes.
          • true
            • draw axes with default properties
          • options[‘axes’][‘format’] (String)
            • format of label (ex. ’%4.2f’)
          • options[‘axes’][‘factor’] (Numric)
            • factor of label size
          • options[‘axes’][‘color’] (Array[Numeric,Numeric,Numeric])
            • RGB of axes ([red, green, blue])
  • Return
    • nil

Method for drawing text

 Draws text
  • Arguments
    • str (String)
    • x (Numeric)
      • normalized x-position of text
    • y (Numeric)
      • normalized y-position of text
    • z (Numeric)
      • normalized z-position of text
    • size (Numeric)
  • Return
    • nil

Method for volume rendering

 Draws Volume Rendering
  • Optional arguments
    • options (Hash)
      • options[‘opacity’] (nil or Hash)
        • {value0 => opacity0, value1 => opacity1, …}
          • opacity must be between 0 to 1
      • options[‘color’] (nil or Hash)
        • {value0 => [R0,G0,B0], value1 => [R1,G1,B1], …}
      • options[‘technique’] (String)
        • "ray casting"
        • "2d texture mapping": default
      • options[‘axes’] (true|false or Hash)
        • If this is true or Hash, draws axes.
          • true
            • draw axes with default properties
          • options[‘axes’][‘format’] (String)
            • format of label (ex. ’%4.2f’)
          • options[‘axes’][‘factor’] (Numric)
            • factor of label size
          • options[‘axes’][‘color’] (Array[Numeric,Numeric,Numeric])
            • RGB of axes ([red, green, blue])
  • Return
    • nil

[Validate]