next up previous contents
Next: File Input/Output Plugins Up: Writing Plugins Previous: Writing Plugins   Contents

Volume Processing Plugins

Volume processing plugins are those that perform a certain task on a given volume. For e.g., thresholding would be considered a volume processor (similar to image processing). We have provided a sample plugin which you can use as skeleton for your plugin. Download it from:

http://openvl.sourceforge.net/pub/sample_plugin.tgz

Go to a directory where you have write access, and untar the file using:

tar -xzvf sample_plugin.tgz

Inside the directory you will find myplugin.h and myplugin.cpp files. These are the only files that you need to implement a volume processing plugin.

The header file: You do not need to modify the header file at all unless you want to change the name of the class MyPlugin. The plugin factory can stay the way it is.

The cpp file: At the top of the plugin file you will see:

VL_EXPORT_COMPONENT_FACTORY( myplugin, PluginFactory )

Here, myplugin indicates the name given to the plugin file. The plugin file name should always be the first entry in the above macro prefixed by vl and suffixed by .so. Thus, in this case, the plugin file should be vlmyplugin.so. To change the name from myplugin, change the name in the above macro, and then edit the Makefile and change the $TARGET field. You will have to edit the $CPPFILE and $HEADERFILE fields too if you decide to name your cpp and h file something other than $TARGET.cpp and $TARGET.h respectively.

Every plugin of OpenVL is recognized by two fileds: the service that it provides, and the service group to which this service belongs. The service group for volume processing plugins is set to VolProcessor. Inside your plugin, you need to specify the service that your plugin will provide. The users of your plugin will use the service name you give to your plugin to query for your plugin.

In the constructor of your plugin class, specify the information about the plugin. For e.g., use setVersion(...) to set the version, setService(...) to set the service the plugin provides.

The run() method is the starting point of the plugin. Whenever a user will request this plugin, run() will be called on the volume set by the user. The 3D volume itself can be accessed using vol() function. vol() returns the pointer to the volume. Any configuration parameters set by the user can be accessed using configRef(). This function returns the reference to a vlVarList object which stores the configuration. Use the object returned by resultsRef() to store the results which can be accessed by the users.

In addition to run(), there is another method which you can override. It is the init() function. This function is called whenever the user calls setVolume(...). This is the right place to setup the configuration variables which are dependent on the data type of the volume.

Compiling the plugin: Simply type make to compile the plugin.

Installing the plugin: The makefile provided allows you to locally install the plugin. Plugins can be locally installed in the plugins directory under $HOME/.openvl. The name of the plugin directory will depend on the version of OpenVL you are using (See Section 1.5). Set the correct name of the plugin directory in the makefile. After that, to install the plugin type:

make inst

Make sure that the plugin directory exists before running make inst. You can check if the plugin was properly installed by checking the contents of the plugin directory.


next up previous contents
Next: File Input/Output Plugins Up: Writing Plugins Previous: Writing Plugins   Contents
Sarang Lakare 2003-04-26