HowToAddSimpleDllFilters

From user's Wiki!
Jump to: navigation, search

This page provides you some tips on how to extend Gimias framework with simple dlls

You can watch a tutorial video here.

Extend with simple VTK Filter

This extension can be done at runtime, without the need of compiling Gimias. It's an easy way to integrate vtk simple filters in Gimias without having to create manually a GUI. The steps are the followings:

1. Create a .xml file with the description of the filter ( see next paragraph for details)

2. If you are developing in Gimias, put the file in a Plugin subfolder named "Filters" (i.e. Apps/Plugins/SceneViewPlugin/Filters/vtkImageThreshold.xml) then do "Install files to build folder"; if you just have the binaries, add the file to for example plugins/sceneviewplugin/lib/Release/Filters directly.

3. Add the Plugin with this subfolder to the Profile and you will have the filter integrated

The xml description file

Inside the this header we will find mainly three parts: General description, Setting parameters and Input/Output parameters

<?xml version="1.0" encoding="utf-8"?>
<executable>
 [...]

  <parameters>
    <label>Parameters</label>
    <description>Parameters</description>
    [...]
  </parameters>

  <parameters>
    <label>IO</label>
    <description>Input/output parameters</description>
    [...]
  </parameters>

</executable>

General Description

In this part you will be able to:

  • set the path to your filter, category will be the submenu name of Tools where you will find your filter named as title.
  • add a description that will be added to the "Help & Acknowledgment" section of the filter in the GUI see picture AutomaticGUIvtk.
  • add a link to the "online documentation" of the class through the field documentation-url
  • add (Mandatory) the constructor, destructor and updatefunction as they are called in the filter class
  • add (Mandatory) the name of the dynamicLibrary to which it belongs the class ( normally in vtk is "vtk" plus the name of the folder that contains the file (from the online documentation click on the filter header file and it will give this information)
  • add (Mandatory) the hierarchy that is given from the online documentation of the filter (see picture classvtkImageThreshold)
  <category>Image processing</category>
  <title>Image Threshold</title>
  <description>Threshold an image</description>
  <version>1.0</version>
  <documentation-url>http://noodle.med.yale.edu/vtk5/classvtkImageThreshold.html</documentation-url>
  <license></license>
  <contributor>Xavi Planes</contributor>
  <constructor>New</constructor>
  <destructor>Delete</destructor>
  <updateFunction>Update</updateFunction>
  <dynamicLibrary>vtkImaging</dynamicLibrary>
  <hierarchy>vtkImageThreshold,vtkThreadedImageAlgorithm,vtkImageAlgorithm,vtkAlgorithm,vtkObject,vtkObjectBase</hierarchy>
AutomaticGUIvtkFilter
ClassHierarchy


Settings Parameters

Once that you have these general parameters set you have to add the parameters you want to have in the GUI. This is an example of a double parameter called "OutValue" and the corresponding function called "SetOutValue":

    void vtkImageThreshold::SetOutValue ( double val )
    <double>
      <name>OutValue</name>
      <label>OutValue</label>
      <default>0</default>
    </double>

When the function name to set the parameter is not the standard one ("Set<parameter>"), you need to specify directly the function name:

    void vtkImageThreshold::ThresholdByLower  ( double thresh )
    <double>
      <name>ThresholdByLower</name>
      <label>ThresholdByLower</label>
      <function>ThresholdByLower</function>
      <default>10</default>
    </double>

The allowed parameters are:

  • double: SetParam ( double )
  • integer: SetParam( int )
  • uinteger: SetParam( unsigned int )
  • float: SetParam( float )
  • string: SetParam( const char* )
  • boolean: SetParam( bool )
  • point: SetParam( double,double,double )

Input/Output Parameters

In this last part you will set the inputs and outputs of the filter, the input will be displayed in the GUI with the label you will give to him, and it could only be of the specifieddataType. The output won't be visible in the GUI but it will be automatically created in the processor, then added to the data list with the given name, and automatically rendered.

  <parameters>
    <label>IO</label>
    <description>Input/output parameters</description>
    <image>
      <name>InputImage</name>
      <label>InputImage</label>
      <dataType>vtkImageData</dataType>
      <channel>input</channel>
      <index>0</index>
    </image>
    <image>
      <name>OutputImage</name>
      <label>OutputImage</label>
      <dataType>vtkImageData</dataType>
      <channel>output</channel>
      <index>1</index>
    </image>
  </parameters>

The allowed in/out parameters are:

  • image: Will call the function "SetInput(int,[...])", using as second parameter vtkImageData*
  • geometry: Will call the function "SetInput(int,[...])", using as second parameter vtkPolyData*

Go back to Developers