https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=Goodwin&feedformat=atomKitwarePublic - User contributions [en]2024-03-28T22:20:54ZUser contributionsMediaWiki 1.38.6https://public.kitware.com/Wiki/index.php?title=Git&diff=45454Git2012-02-04T06:53:27Z<p>Goodwin: </p>
<hr />
<div>Placeholder for future Git information.<br />
See<br />
* [[Git/Download]]<br />
* [[Git/Hooks]]<br />
* [[Git/Publish]]<br />
* [[Git/Resources]]<br />
* [[Git/WorkflowPrimer]]<br />
* [[Git/Workflow]]<br />
** [[Git/Workflow/Topic]]<br />
*** [[Git/Workflow/Topic/Conflicts]]<br />
** [[Git/Workflow/Stage]]<br />
* [[Git/Trouble]]<br />
* [[VTK/Git]]<br />
* [[VTK/Git/Account]]<br />
* [[VTK/Git/Develop]]<br />
* [[VTK/Git/Download]]<br />
* [[VTK/Git/GitHub]]<br />
* [[VTK/Git/Simple]]<br />
* [[VTK/Working With Git]]<br />
* [[ITK/Git]]<br />
* [[ITK/Git/TipsAndTricks]]<br />
* [[ITK/Git/Download]]<br />
* [[ITK/Git/Account]]<br />
* [[ParaView/Git]]<br />
* [[ParaView/Git/Simple]]<br />
* [[ParaView/Gerrit]]<br />
* [[CMake/Git]]<br />
* [[CMake/Git/Develop]]<br />
* [http://www.vtk.org/Wiki/images/8/81/GitVTKCheatSheet.pdf Git VTK Cheat Sheet]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/Git&diff=38650VTK/Git2011-03-25T17:24:45Z<p>Goodwin: </p>
<hr />
<div>__TOC__<br />
<br />
VTK version tracking and development is hosted by [http://git-scm.com Git].<br />
<br />
=Official Repository=<br />
<br />
One may browse the repository online using the [http://git.wiki.kernel.org/index.php/Gitweb Gitweb] interface at http://vtk.org/gitweb.<br />
<br />
==Cloning==<br />
<br />
These instructions assume a command prompt is available with <code>git</code> in the path.<br />
See our Git [[Git/Download|download instructions]] for help installing Git.<br />
<br />
One may clone the repository using [http://www.kernel.org/pub/software/scm/git/docs/git-clone.html git clone] through the native <code>git</code> protocol:<br />
<br />
$ git clone git://vtk.org/VTK.git VTK<br />
<br />
or through the (less efficient) <code>http</code> protocol:<br />
<br />
$ git clone http://vtk.org/VTK.git VTK<br />
<br />
All further commands work inside the local copy of the repository created by the clone:<br />
<br />
$ cd VTK<br />
<br />
For VTKData the URLs are<br />
<br />
git://vtk.org/VTKData.git<br />
http://vtk.org/VTKData.git<br />
<br />
For VTKLargeData the URLs are<br />
<br />
git://vtk.org/VTKLargeData.git<br />
http://vtk.org/VTKLargeData.git<br />
<br />
==Branches==<br />
<br />
At the time of this writing the repository has the following branches:<br />
<br />
* '''master''': Development (default)<br />
* '''release''': Release maintenance<br />
* '''nightly-master''': Follows '''master''', updated at 01:00 UTC<br />
* '''hooks''': Local commit hooks ([[Git/Hooks#Local|place]] in .git/hooks)<br />
<br />
Release branches converted from CVS have been artificially merged into master.<br />
Actual releases have tags named by the release version number.<br />
<br />
=Development=<br />
<br />
We provide here a brief introduction to '''VTK''' development with Git.<br />
See the [[Git/Resources|Resources]] page for further information such as Git tutorials.<br />
<br />
==Quick Start Guide==<br />
<br />
If you would like to get up and running quickly, we recommend you follow the [[VTK/Git/Simple|simple Git guide]]. It will guide you through getting your development environment setup, working on topic branches and merging your changes back into master.<br />
<br />
==Introduction==<br />
<br />
We require all commits in VTK to record valid author/committer name and email information.<br />
Use [http://www.kernel.org/pub/software/scm/git/docs/git-config.html git config] to introduce yourself to Git:<br />
<br />
$ git config --global user.name "Your Name"<br />
$ git config --global user.email "you@yourdomain.com"<br />
<br />
Note that "Your Name" is your ''real name'' (e.g. "John Doe", not "jdoe").<br />
While you're at it, optionally enable color output from Git commands:<br />
<br />
$ git config --global color.ui auto<br />
<br />
The <code>--global</code> option stores the configuration settings in <code>~/.gitconfig</code> in your home directory so that they apply to all repositories.<br />
<br />
==Hooks==<br />
<br />
The '''hooks''' branch provides local commit hooks to be placed in <code>.git/hooks</code>.<br />
It is shared by many <code>public.kitware.com</code> repositories.<br />
<br />
See the general [[Git/Hooks|hooks]] information page to set up your local hooks.<br />
<br />
==Workflow==<br />
<br />
We have now moved to use a branchy workflow, [http://public.kitware.com/Wiki/Git/Workflow/Topic branchy workflow] based on topic branches. We do not have a next integration branch at this point, and so you should ignore any reference to that and merge straight to master. The next section describes use of the topic stage, [[VTK/Git/Simple|simplified guide]] can be followed using supplied scripts and aliases.<br />
<br />
==Topic Stage==<br />
<br />
We provide a "[http://vtk.org/stage/VTK.git VTK Topic Stage]" repository to which developers may publish arbitrary topic branches and request automatic merges. To follow this workflow, you should have git version 1.7 or greater.<br />
<br />
The topic stage URLs are<br />
<br />
* <code>git://vtk.org/stage/VTK.git</code> (clone, fetch)<br />
* <code>http://vtk.org/stage/VTK.git</code> (clone, fetch, gitweb)<br />
* <code>git@vtk.org:stage/VTK.git</code> (push)<br />
<br />
See our [http://public.kitware.com/Wiki/Git/Workflow/Stage Topic Stage Workflow] documentation for general instructions.<br />
''(Currently VTK does not have a '''next''' branch. Just skip that part of the instructions and merge directly to master.)''<br />
When accessing the VTK stage, one may optionally substitute<br />
"<code>ssh git@vtk.org stage VTK ...</code>"<br />
for<br />
"<code>ssh git@public.kitware.com stage <repo> ...</code>"<br />
in the ssh command-line interface.<br />
<br />
{| border="0"<br />
!colspan=2|Stage Usage Summary<br />
|-<br />
|align="center"|<br />
'''Initial Setup:'''<br />
|<br />
$ git remote add stage git://vtk.org/stage/VTK.git<br />
$ git config remote.stage.pushurl git@vtk.org:stage/VTK.git<br />
|-<br />
|align="center"|<br />
'''Fetch Staged Topics:'''<br />
|<br />
$ git fetch stage --prune<br />
|-<br />
|align="center"|<br />
'''Create Local Topic:'''<br />
|<br />
$ git checkout -b ''topic-name'' origin/master<br />
$ edit files<br />
$ git commit<br />
|-<br />
|align="center"|<br />
'''Stage Current Topic:'''<br />
|<br />
$ git push stage HEAD<br />
|-<br />
|align="center"|<br />
'''Print Staged Topics:'''<br />
|<br />
$ ssh git@vtk.org stage VTK print<br />
|-<br />
|align="center"|<br />
'''Merge Staged Topic:'''<br />
|<br />
$ ssh git@vtk.org stage VTK merge ''topic-name''<br />
|-<br />
|align="center"|<br />
'''Check out Staged Topic:'''<br />
|<br />
$ git fetch stage<br />
$ git checkout -b ''topic-name'' remotes/stage/''topic-name''<br />
|-<br />
|align="center"|<br />
'''Abandon/Delete Staged Topic:'''<br />
|<br />
$ git push stage :''topic-name''<br />
<br />
|}<br />
<br />
Note that the stage implementation is not VTK-specific and is used for other projects too.<br />
If the merge attempt conflicts it may print instructions for performing the merge manually.<br />
'''Ignore''' these instructions; you will not be able to push the merge commit directly.<br />
Instead, identify the commit that conflicts with yours, merge it into your topic locally, push the topic to the stage again, and then repeat the merge request.<br />
<br />
==Github==<br />
<br />
The VTK repository is mirrored on github. Experimental branches that are not ready for staging can be published on github for review.<br />
<br />
The first step in creating a github branch is to create an account on github and make a fork of [http://github.com/Kitware/VTK http://github.com/Kitware/VTK]. Since this fork will be a mirror of the VTK master, there is no need to clone it on your local machine. Instead, you will just want to set github as an alternative remote in your existing local copy of the VTK git repository.<br />
<br />
To set github as an alternative remote, use the following commands:<br />
<br />
{| border="0"<br />
!colspan=2|Github Usage Summary<br />
|-<br />
|align="center"|<br />
'''Remote Setup:'''<br />
|<br />
$ git remote add github git@github.com:yourname/VTK.git<br />
$ git config remote.github.pushurl git@github.com:yourname/VTK.git<br />
|-<br />
|align="center"|<br />
'''Update the Remote:'''<br />
|<br />
# update from Kitware's master and push to github<br />
$ git pull<br />
$ git push github HEAD<br />
|-<br />
|align="center"|<br />
'''Push Branch to Github:'''<br />
|<br />
$ git checkout -b some-branch github/master<br />
# edit files and commit changes<br />
$ git push github HEAD<br />
|}<br />
<br />
The second step above should be done regularly on your master, in order to keep your github fork up-to-date with the VTK master. Do not use github's graphical interface for merging commits, it creates new commits by rebasing the commits you select against your VTK fork. These new commits will be very difficult to merge back into VTK master.<br />
<br />
The checkout command in the third step will automatically set github as the default remote for the new branch, but you still must specify "github HEAD" when you push or else you will push to the github master branch, instead of pushing to a new github branch. Also, since it bases the branch on your github fork, you should perform step 2 before creating the branch to make sure that your fork is up-to-date. This is just a suggestion, as it is always possible to rebase or merge at a later time.<br />
<br />
The default remotes for each of your branches are controlled by entries such as this in your .git/config file:<br />
<br />
[branch "my-branch-name"]<br />
remote = github<br />
merge = refs/heads/my-branch-name<br />
<br />
You can edit this file to make github the default remote and to set the remote branch name for your existing branches. Or you can always use "git push github HEAD" to push each branch to github, without changing the defaults.<br />
<br />
=Publishing=<br />
<br />
==Pushing==<br />
<br />
Authorized developers may publish work directly to <code>vtk.org/VTK.git</code> using Git's SSH protocol.<br />
To request access, fill out the [https://www.kitware.com/Admin/SendPassword.cgi Kitware Password] form.<br />
<br />
See the [[Git/Publish#Push_Access|push instructions]] for details.<br />
<br />
For VTK, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@vtk.org:VTK.git<br />
<br />
For VTKData, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@vtk.org:VTKData.git<br />
<br />
===Update Hook===<br />
<br />
The vtk.org repository has an <code>update</code> hook.<br />
When someone tries to push changes to the repository it checks the commits as documented [[Git/Hooks#update|here]].<br />
<br />
==Patches==<br />
<br />
Contributions of bug fixes and features are commonly produced by the community. Patches are a convenient method for managing such contributions.<br />
<br />
One may send patches after subscribing to our mailing list:<br />
<br />
* [http://www.vtk.org/mailman/listinfo/vtk-developers VTK Developers Mailing List]<br />
<br />
See our [[Git/Publish#Patches|patch instructions]] for details.<br />
<br />
= Troubleshooting =<br />
== fatal: The remote end hung up unexpectedly ==<br />
* If <tt>git push</tt> fails with "fatal: The remote end hung up unexpectedly", you probably forgot to set the push url with "git config" see [[#Pushing]].<br />
<br />
== Restoring files locally ==<br />
Q: "I cloned the VTK repository. Now I "rm -rf Hybrid". How do I get it back?"<br><br />
A: git checkout Hybrid<br><br />
Q: "I modified a file locally. I want to revert it."<br><br />
A: git checkout myfile.cxx<br><br />
Q: "I want to get rid of all local changes in this directory and start clean."<br><br />
A: git checkout .<br />
<br />
=Resources=<br />
<br />
Additional information about Git may be obtained at sites listed [[Git/Resources|here]].</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/Git&diff=37871VTK/Git2011-02-23T13:09:25Z<p>Goodwin: Changed github remote to a ssh url to allow push access.</p>
<hr />
<div>__TOC__<br />
<br />
VTK version tracking and development is hosted by [http://git-scm.com Git].<br />
<br />
=Official Repository=<br />
<br />
One may browse the repository online using the [http://git.wiki.kernel.org/index.php/Gitweb Gitweb] interface at http://vtk.org/gitweb.<br />
<br />
==Cloning==<br />
<br />
These instructions assume a command prompt is available with <code>git</code> in the path.<br />
See our Git [[Git/Download|download instructions]] for help installing Git.<br />
<br />
One may clone the repository using [http://www.kernel.org/pub/software/scm/git/docs/git-clone.html git clone] through the native <code>git</code> protocol:<br />
<br />
$ git clone git://vtk.org/VTK.git VTK<br />
<br />
or through the (less efficient) <code>http</code> protocol:<br />
<br />
$ git clone http://vtk.org/VTK.git VTK<br />
<br />
All further commands work inside the local copy of the repository created by the clone:<br />
<br />
$ cd VTK<br />
<br />
For VTKData the URLs are<br />
<br />
git://vtk.org/VTKData.git<br />
http://vtk.org/VTKData.git<br />
<br />
For VTKLargeData the URLs are<br />
<br />
git://vtk.org/VTKLargeData.git<br />
http://vtk.org/VTKLargeData.git<br />
<br />
==Branches==<br />
<br />
At the time of this writing the repository has the following branches:<br />
<br />
* '''master''': Development (default)<br />
* '''release''': Release maintenance<br />
* '''nightly-master''': Follows '''master''', updated at 01:00 UTC<br />
* '''hooks''': Local commit hooks ([[Git/Hooks#Local|place]] in .git/hooks)<br />
<br />
Release branches converted from CVS have been artificially merged into master.<br />
Actual releases have tags named by the release version number.<br />
<br />
=Development=<br />
<br />
We provide here a brief introduction to '''VTK''' development with Git.<br />
See the [[Git/Resources|Resources]] page for further information such as Git tutorials.<br />
<br />
==Quick Start Guide==<br />
<br />
If you would like to get up and running quickly, we recommend you follow the [[VTK/Git/Simple|simple Git guide]]. It will guide you through getting your development environment setup, working on topic branches and merging your changes back into master.<br />
<br />
==Introduction==<br />
<br />
We require all commits in VTK to record valid author/committer name and email information.<br />
Use [http://www.kernel.org/pub/software/scm/git/docs/git-config.html git config] to introduce yourself to Git:<br />
<br />
$ git config --global user.name "Your Name"<br />
$ git config --global user.email "you@yourdomain.com"<br />
<br />
Note that "Your Name" is your ''real name'' (e.g. "John Doe", not "jdoe").<br />
While you're at it, optionally enable color output from Git commands:<br />
<br />
$ git config --global color.ui auto<br />
<br />
The <code>--global</code> option stores the configuration settings in <code>~/.gitconfig</code> in your home directory so that they apply to all repositories.<br />
<br />
==Hooks==<br />
<br />
The '''hooks''' branch provides local commit hooks to be placed in <code>.git/hooks</code>.<br />
It is shared by many <code>public.kitware.com</code> repositories.<br />
<br />
See the general [[Git/Hooks|hooks]] information page to set up your local hooks.<br />
<br />
==Workflow==<br />
<br />
We have now moved to use a branchy workflow, [http://public.kitware.com/Wiki/Git/Workflow/Topic branchy workflow] based on topic branches. We do not have a next integration branch at this point, and so you should ignore any reference to that and merge straight to master. The next section describes use of the topic stage, [[VTK/Git/Simple|simplified guide]] can be followed using supplied scripts and aliases.<br />
<br />
==Topic Stage==<br />
<br />
We provide a "[http://vtk.org/stage/VTK.git VTK Topic Stage]" repository to which developers may publish arbitrary topic branches and request automatic merges. To follow this workflow, you should have git version 1.7 or greater.<br />
<br />
The topic stage URLs are<br />
<br />
* <code>git://vtk.org/stage/VTK.git</code> (clone, fetch)<br />
* <code>http://vtk.org/stage/VTK.git</code> (clone, fetch, gitweb)<br />
* <code>git@vtk.org:stage/VTK.git</code> (push)<br />
<br />
See our [http://public.kitware.com/Wiki/Git/Workflow/Stage Topic Stage Workflow] documentation for general instructions.<br />
''(Currently VTK does not have a '''next''' branch. Just skip that part of the instructions and merge directly to master.)''<br />
When accessing the VTK stage, one may optionally substitute<br />
"<code>ssh git@vtk.org stage VTK ...</code>"<br />
for<br />
"<code>ssh git@public.kitware.com stage <repo> ...</code>"<br />
in the ssh command-line interface.<br />
<br />
{| border="0"<br />
!colspan=2|Stage Usage Summary<br />
|-<br />
|align="center"|<br />
'''Initial Setup:'''<br />
|<br />
$ git remote add stage git://vtk.org/stage/VTK.git<br />
$ git config remote.stage.pushurl git@vtk.org:stage/VTK.git<br />
|-<br />
|align="center"|<br />
'''Fetch Staged Topics:'''<br />
|<br />
$ git fetch stage --prune<br />
|-<br />
|align="center"|<br />
'''Create Local Topic:'''<br />
|<br />
$ git checkout -b ''topic-name'' origin/master<br />
$ edit files<br />
$ git commit<br />
|-<br />
|align="center"|<br />
'''Stage Current Topic:'''<br />
|<br />
$ git push stage HEAD<br />
|-<br />
|align="center"|<br />
'''Print Staged Topics:'''<br />
|<br />
$ ssh git@vtk.org stage VTK print<br />
|-<br />
|align="center"|<br />
'''Merge Staged Topic:'''<br />
|<br />
$ ssh git@vtk.org stage VTK merge ''topic-name''<br />
|-<br />
|align="center"|<br />
'''Check out Staged Topic:'''<br />
|<br />
$ git fetch stage<br />
$ git checkout -b ''topic-name'' remotes/stage/''topic-name''<br />
|-<br />
|align="center"|<br />
'''Abandon/Delete Staged Topic:'''<br />
|<br />
$ git push stage :''topic-name''<br />
<br />
|}<br />
<br />
Note that the stage implementation is not VTK-specific and is used for other projects too.<br />
If the merge attempt conflicts it may print instructions for performing the merge manually.<br />
'''Ignore''' these instructions; you will not be able to push the merge commit directly.<br />
Instead, identify the commit that conflicts with yours, merge it into your topic locally, push the topic to the stage again, and then repeat the merge request.<br />
<br />
==Github==<br />
<br />
The VTK repository is mirrored on github. Experimental branches that are not ready for staging can be published on github for review.<br />
<br />
The first step in creating a github branch is to create an account on github and make a fork of [http://github.com/Kitware/VTK http://github.com/Kitware/VTK]. Since this fork will be a mirror of the VTK master, there is no need to clone it on your local machine. Instead, you will just want to set github as an alternative remote in your existing local copy of the VTK git repository.<br />
<br />
To set github as an alternative remote, use the following commands:<br />
<br />
{| border="0"<br />
!colspan=2|Github Usage Summary<br />
|-<br />
|align="center"|<br />
'''Remote Setup:'''<br />
|<br />
$ git remote add github git@github.com:yourname/VTK.git<br />
$ git config remote.github.pushurl git@github.com:yourname/VTK.git<br />
|-<br />
|align="center"|<br />
'''Update the Remote:'''<br />
|<br />
# update from Kitware's master and push to github<br />
$ git pull<br />
$ git push github HEAD<br />
|-<br />
|align="center"|<br />
'''Push Branch to Github:'''<br />
|<br />
$ git checkout -b some-branch github/master<br />
# edit files and commit changes<br />
$ git push github HEAD<br />
|}<br />
<br />
The second step above should be done regularly on your master, in order to keep your github fork up-to-date with the VTK master. Do not use github's graphical interface for merging commits, it creates new commits by rebasing the commits you select against your VTK fork. These new commits will be very difficult to merge back into VTK master.<br />
<br />
The checkout command in the third step will automatically set github as the default remote for the new branch, but you still must specify "github HEAD" when you push or else you will push to the github master branch, instead of pushing to a new github branch. Also, since it bases the branch on your github fork, you should perform step 2 before creating the branch to make sure that your fork is up-to-date. This is just a suggestion, as it is always possible to rebase or merge at a later time.<br />
<br />
The default remotes for each of your branches are controlled by entries such as this in your .github/config file:<br />
<br />
[branch "my-branch-name"]<br />
remote = github<br />
merge = refs/heads/my-branch-name<br />
<br />
You can edit this file to make github the default remote and to set the remote branch name for your existing branches. Or you can always use "git push github HEAD" to push each branch to github, without changing the defaults.<br />
<br />
=Publishing=<br />
<br />
==Pushing==<br />
<br />
Authorized developers may publish work directly to <code>vtk.org/VTK.git</code> using Git's SSH protocol.<br />
To request access, fill out the [https://www.kitware.com/Admin/SendPassword.cgi Kitware Password] form.<br />
<br />
See the [[Git/Publish#Push_Access|push instructions]] for details.<br />
<br />
For VTK, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@vtk.org:VTK.git<br />
<br />
For VTKData, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@vtk.org:VTKData.git<br />
<br />
===Update Hook===<br />
<br />
The vtk.org repository has an <code>update</code> hook.<br />
When someone tries to push changes to the repository it checks the commits as documented [[Git/Hooks#update|here]].<br />
<br />
==Patches==<br />
<br />
Contributions of bug fixes and features are commonly produced by the community. Patches are a convenient method for managing such contributions.<br />
<br />
One may send patches after subscribing to our mailing list:<br />
<br />
* [http://www.vtk.org/mailman/listinfo/vtk-developers VTK Developers Mailing List]<br />
<br />
See our [[Git/Publish#Patches|patch instructions]] for details.<br />
<br />
= Troubleshooting =<br />
== fatal: The remote end hung up unexpectedly ==<br />
* If <tt>git push</tt> fails with "fatal: The remote end hung up unexpectedly", you probably forgot to set the push url with "git config" see [[#Pushing]].<br />
<br />
== Restoring files locally ==<br />
Q: "I cloned the VTK repository. Now I "rm -rf Hybrid". How do I get it back?"<br><br />
A: git checkout Hybrid<br><br />
Q: "I modified a file locally. I want to revert it."<br><br />
A: git checkout myfile.cxx<br><br />
Q: "I want to get rid of all local changes in this directory and start clean."<br><br />
A: git checkout .<br />
<br />
=Resources=<br />
<br />
Additional information about Git may be obtained at sites listed [[Git/Resources|here]].</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Git&diff=37869Git2011-02-23T12:03:59Z<p>Goodwin: Add cheat cheat</p>
<hr />
<div>Placeholder for future Git information.<br />
See<br />
* [[Git/Download]]<br />
* [[Git/Hooks]]<br />
* [[Git/Publish]]<br />
* [[Git/Resources]]<br />
* [[Git/WorkflowPrimer]]<br />
* [[Git/Workflow]]<br />
** [[Git/Workflow/Topic]]<br />
** [[Git/Workflow/Stage]]<br />
* [[Git/Trouble]]<br />
* [[VTK/Git]]<br />
* [[VTK/Git/Simple]]<br />
* [[VTK/Working With Git]]<br />
* [[ITK/Git]]<br />
* [[ITK/Git/TipsAndTricks]]<br />
* [[ITK/Git/Download]]<br />
* [[ITK/Git/Account]]<br />
* [[ParaView/Git]]<br />
* [[ParaView/Git/Simple]]<br />
* [[ParaView/Gerrit]]<br />
* [[CMake/Git]]<br />
* [http://www.vtk.org/Wiki/images/8/81/GitVTKCheatSheet.pdf Git VTK Cheat Sheet]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Git&diff=37868Git2011-02-23T11:27:29Z<p>Goodwin: Added more links to git pages around the wiki</p>
<hr />
<div>Placeholder for future Git information.<br />
See<br />
* [[Git/Download]]<br />
* [[Git/Hooks]]<br />
* [[Git/Publish]]<br />
* [[Git/Resources]]<br />
* [[Git/WorkflowPrimer]]<br />
* [[Git/Workflow]]<br />
** [[Git/Workflow/Topic]]<br />
** [[Git/Workflow/Stage]]<br />
* [[Git/Trouble]]<br />
* [[VTK/Git]]<br />
* [[VTK/Git/Simple]]<br />
* [[VTK/Working With Git]]<br />
* [[ITK/Git]]<br />
* [[ITK/Git/TipsAndTricks]]<br />
* [[ITK/Git/Download]]<br />
* [[ITK/Git/Account]]<br />
* [[ParaView/Git]]<br />
* [[ParaView/Git/Simple]]<br />
* [[ParaView/Gerrit]]<br />
* [[CMake/Git]]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=37847User:Goodwin2011-02-21T08:56:16Z<p>Goodwin: </p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com/software/vtkbioeng here]<br />
<br />
All VTK wiki pages: [http://www.vtk.org/Wiki/index.php?title=Special%3AAllpages&from=VTK&namespace=0]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/3DConnexion_Devices_Support&diff=17101VTK/3DConnexion Devices Support2009-10-28T09:36:50Z<p>Goodwin: /* Windows */</p>
<hr />
<div>Support for 3DConnexion Devices (SpaceNavigator, SpaceExplorer, SpacePilot) inside VTK<br />
<br />
= Implementation =<br />
* [[VTK/3DConnexion Devices Support Implementation Work Sheet | Implementation Work Sheet]]<br />
== Date of Implementation ==<br />
* 2009/08/21: experimental work (Linux and Windows)<br />
* 2009/09/10: Qt on Windows, <tt>vtkTDxInteractorStyle</tt>(s), <tt>vtkTDxInteractorStyleSettings</tt><br />
* Implemented by (any question to) François Bertel.<br />
<br />
== TODO ==<br />
* Support for Qt on Linux<br />
* Support for Mac<br />
<br />
= Naming convention =<br />
We pick the name <b>TDx</b> to refer to classes or types to support 3DConnexion Devices. "T" stands for "Three", "x" stands for "connexion". <b>Why?</b> because 3DConnexion calls its software 3DxWare but we cannot have types and classes starting with a number in C++, so we chose "T" instead of "3".<br />
<br />
= Supported Platform =<br />
* Linux: yes (tested with Ubuntu GNU/Linux 9.04 x86_64, gcc, with a 3DConnexion SpaceNavigator)<br />
* Linux with Qt: not yet<br />
* Windows: yes (tested with Windows Vista Ultimate SP2 64-bit, Visual Studio 9 SP1, with a 3DConnexion SpaceNavigator)<br />
* Windows with Qt: yes<br />
* Mac: not yet<br />
* Mac with Qt: not yet<br />
<br />
= How to use it=<br />
== Install the 3DConnexion Device driver ==<br />
=== Linux ===<br />
==== Download ====<br />
* Download the driver from the 3DConnexion wesbite: http://www.3dconnexion.com/support/downloads.php<br />
** Select the product, (example SpaceNavigator SE),<br />
** select the OS (Linux),<br />
** select the driver file for the architecture (3DxWare for Linux (i386) for 32-bit, 3DxWare for Linux (x86_64) for 64-bit )<br />
<br />
For example, for Linux 64-bit, we will get the 3 following files:<br />
* 3dxware-linux-v1-4-3.x86_64.tar.gz,<br />
* InstallationInstructions_Linux.txt,<br />
* Release_Notes-All_Platforms-20090806.pdf<br />
<br />
==== Install required packages ====<br />
On Ubuntu, install package <b>libmotif3</b>. The GUI of the 3DConnexion device driver uses it.<br />
<br />
==== Install the driver ====<br />
<b>As root</b>, (from InstallationInstructions_Linux.txt):<br />
# $ cd /tmp<br />
# tar xzvf path/to/3dxware-linux-v1-4-3.x86_64.tar.gz<br />
# ./install-3dxunix.sh<br />
<br />
Then, you have to change to permissions of the installed files manually (ref [[http://www.3dconnexion.com/forum/viewtopic.php?t=2727&sid=0bb82b3f29689c5408974e06a0a94962 forum thread]]) in <tt>/etc/3DxWare</tt>:<br />
<pre><br />
sudo chmod go+rx /etc/3DxWare<br />
sudo chmod go+r /etc/3DxWare/*.scg <br />
</pre><br />
<br />
==== Test the driver ====<br />
Launch the daemon (with sudo):<br />
<pre><br />
sudo /etc/3DxWare/daemon/3dxsrv -d usb <br />
</pre><br />
The GUI is created but not on top of the desktop. Check for a 3DxWare window on your desktop.<br />
<br />
If you forgot to change permissions of the installed files, we will have this error message:<br />
<pre><br />
$ sudo /etc/3DxWare/daemon/3dxsrv -d usb<br />
3DxWareUNIX = V1.4.3<br />
Device = SpaceNavigator<br />
Firmware = V3.18<br />
[2009-08-19 12:01:28] Error: Can't find any configuration files! Please reinstall you configurations in /etc/3DxWare properly!<br />
</pre><br />
<br />
<br />
For testing/disgnostic purpose (for fun too), launch of one the programs provided in the archive (uncompressed in /tmp for the first step):<br />
<pre><br />
$ /tmp/xcube<br />
$ /tmp/xvalue<br />
</pre><br />
<br />
=== Windows ===<br />
Easy. Nothing to add about it.<br />
=== Mac OS ===<br />
Easy. Nothing to add about it.<br />
<br />
== Install the 3DConnexion SDK ==<br />
=== Linux ===<br />
* Go the the 3DConnexion SDK webpage: http://www.3dconnexion.com/support/sdk.php <br />
* Register, accept the license<br />
* Download xdevelop.tgz<br />
* Uncompress xdevelop.tgz wherever you want<br />
<pre><br />
$ tar xzvf xdevelop.tgz<br />
</pre><br />
* Prepare a Makefile for Linux from <tt>makefile.dec</tt>:<br />
* a. cp makefile.dec makefile.linux<br />
* b. edit makefile.linux and remove occurrences of -DDEC and -fullwarn . Add a -fPIC option to the build object section. Add a section to build a static library. To sum up, you end up with a <tt>makefile.linux</tt> file like (the big spaces at the beginning of lines are tabs, they <b>must</b> be tabs, not spaces):<br />
<pre><br />
all: xapp xdrvlib.a<br />
ls -al xapp<br />
<br />
xdrvlib.o: xdrvlib.c xdrvlib.h<br />
gcc xdrvlib.c -c -fPIC<br />
<br />
xdrvlib.a: xdrvlib.o<br />
ar rcs xdrvlib.a xdrvlib.o<br />
<br />
xapp: xapp.c xdrvlib.o<br />
gcc xapp.c xdrvlib.o -o xapp -lX11 -lm<br />
</pre><br />
<br />
*Build the static library:<br />
<pre><br />
# 3. make -f makefile.linux<br />
</pre><br />
the result of the build is <b><tt>xdrvlib.a</tt></b>. There is also an application <b><tt>xapp</tt></b>.<br />
<br />
At this point, for testing/diagnostic purpose, you can try to launch xapp.<br />
<br />
=== Windows ===<br />
Easy. There is nothing more to install +.<br />
<br />
(This is because the Windows SDK (TDxInput.dll) installs when you install 3DxSoftware. You can find TDxInput.dll in ..\Program Files\3Dconnexion\3Dconnexion 3DxSoftware\3DxWare\win32 or \win64. )<br />
<br />
+ If you use any of the Visual C++ Express Editions, then you are missing ATL (Active Template Library) which is only available in the "professional" editions. You will notice that your (express) compiler will complain that it can not find "atlbase.h". Follow these steps to remedy the situation:<br />
<br />
1. Install "Microsoft ® Windows Server® 2003 R2 Platform SDK" from [http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en here]. You only need to install the "core" and "redistributable" components, so choose a custom installation and disable everything but these components. (Neither Windows Server 2008 SDK nor Windows 7 SDK include the ATL headers)<br />
<br />
2.1 Find the missing header in, eg, C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\atl<br />
<br />
2.2 You need to comment out line 293 in "atlbase.h", so that it reads:<br />
<pre><br />
//#pragma comment(lib, "atlthunk.lib")<br />
</pre><br />
3.1 Open up Visual C++ Express and click the "Tools" menu button, then the "Options" command.<br />
<br />
3.2 In the left-hand pane, click "Projects and Solutions", then "VC++ Directories"<br />
<br />
3.3 In the drop-down menu "Show directories for", choose "Include files"<br />
<br />
3.4 Add the location of "atlbase.h" (probably the same as in 2.1 above) to the list of directories.<br />
<br />
4 You are ready to compile VTK including the 3DConnexion device support with a VC++ express compiler!<br />
<br />
== Configure VTK ==<br />
Launch cmake and set the advanced option <tt>VTK_USE_TDx</tt> to <tt>TRUE</tt><br />
=== Linux ===<br />
Set the advanced variables:<br />
* <tt>VTK_TDX_INCLUDE_PATH</tt> to point to the path of <tt>xdrvlib.h</tt> (without mentioning <tt>xdrvlib.h</tt>)<br />
* <tt>VTK_TDX_OBJECT_PATH</tt> to the full path to <tt>xdrvlib.a</tt> (mentioning <tt>xdrvlib.a</tt>)<br />
=== Windows ===<br />
Easy. There is nothing else to set.<br />
<br />
== Build VTK ==<br />
Just build vtk.<br />
<br />
== Test it ==<br />
Launch TestTDx in interactive mode<br />
*1. Get the full command line of the test with:<br />
<pre><br />
$ ctest -R TestTDx -V -N<br />
</pre><br />
*2. Copy the full command line in the prompt and add -I at the end, to run the test in interactive mode<br />
<br />
*3. Enjoy<br />
<br />
= How to program it =<br />
You can use the device with a <tt>vtkRenderWindowInteractor</tt> (1a) or a <tt>QVTKWidget</tt> (1b).<br />
* Look at <tt>VTK/Rendering/Testing/Cxx/TestTDx.cxx</tt> for a sample code using a regular <tt>vtkRenderWindowInteractor</tt>.<br />
* Look at <tt>VTK/Examples/GUI/Qt/Events/GUI4.cxx</tt> for a sample code using a <tt>QVTKWidget</tt>. <em>To compile it, you have to enable <tt>BUILD_EXAMPLES</tt>, <tt>VTK_USE_QT</tt>, <tt>VTK_USE_GUISUPPORT</tt>, <tt>VTK_USE_QVTK_QOPENGL</tt> and set <tt>DESIRED_QT_VERSION</tt> to 4 in cmake. On Windows in debug mode, the executable is <tt>qtevents.exe</tt> in <tt>$BUILD/bin/Debug</tt></em><br />
<br />
1a. Once the <tt>vtkRenderWindowInteractor</tt> is created, tell it to listen to the device, when the event loop starts (must be called before the first render).<br />
<pre><br />
vtkRenderWindowInteractor *i=vtkRenderWindowInteractor::New();<br />
i->SetUseTDx(true);<br />
</pre><br />
<br />
1b. Once the <tt>QVTKWidget</tt> is created, and before a <tt>vtkRenderWindow</tt> is assigned to it, tell it <br />
to listen to listen to the device, when the event loop starts:<br />
<pre><br />
qVTK1->SetUseTDx(true);<br />
qVTK1->SetRenderWindow(renwin);<br />
</pre><br />
<br />
You can do step 2a or 2b or both:<br />
<br />
<b>2a. Basic event-driven mechanism</b><br />
<br />
Add an observer to watch for a TDx event:<br />
<pre><br />
vtkCommand *c;<br />
[...]<br />
i->AddObserver(vtkCommand::TDxMotionEvent,c,0);<br />
</pre><br />
There are 3 types of events (defined in VTK/Common/vtkCommand.h), they all return some callData:<br />
<br />
# <tt>vtkCommand::TDxMotionEvent</tt>, is invoked when the ball or knob is actived. the callData is a pointer to a <tt>vtkTDxMotionEventInfo</tt> (defined in <tt>VTK/Rendering</tt>). This structure stores information about a translation (X,Y,Z) and a rotation, represented by an angle and an axis (a unit vector). <em>Tip: use <tt>VTK/Common/vtkTransform::RotateWXYZ()</tt> to convert an angle-axis representation to an orthogonal matrix representation of a rotation.</em><br />
# <tt>vtkCommand::TDxButtonPressEvent</tt>, is invoked when a button is pressed. the callData is a pointer to a <tt>int</tt>, which is the number of the button.<br />
# <tt>vtkCommand::TDxButtonReleaseEvent</tt>, is invoked when a button is released. the callData is a pointer to a <tt>int</tt>, which is the number of the button.<br />
<br />
<b>2b. Use or write a concrete subclass of <tt>vtkTDxInteractorStyle</tt></b><br />
<br />
Initially, the <tt>vtkInteractorStyle</tt> attached to the <tt>vtkRenderWindowInteractor</tt> delegates the processing of the <tt>TDx*Events</tt> to a <tt>vtkTDxInteractorStyleCamera</tt>.<br />
It means that, by default, the 3DConnexion device controls camera motions.<br />
You can access the <tt>vtkTDxInteractorStyle</tt> attached to the <tt>vtkInteractorStyle</tt> with <tt>GetTDxStyle()</tt> and<br />
<tt>SetTDxStyle()</tt>.<br />
<br />
In addition, you can change the sensitivity settings and axe motion filtering/masking of the 3DConnexion device for a <tt>vtkTDxInteractorStyle</tt> with the <tt>vtkTDxInteractorStyleSettings</tt> object attached to it. You can share the same settings between different <tt>vtkTDxInteractorStyle</tt>s. Here is the code sample from <tt>VTK/Rendering/Testing/Cxx/TestTDx.cxx</tt> that demonstrates how to set the sensitivity parameters:<br />
<pre><br />
const double angleSensitivity=0.02;<br />
const double translationSensitivity=0.001;<br />
<br />
vtkRenderWindowInteractor *iren;<br />
[...]<br />
vtkInteractorStyle *s=<br />
static_cast<vtkInteractorStyle *>(iren->GetInteractorStyle());<br />
vtkTDxInteractorStyleCamera *t=<br />
static_cast<vtkTDxInteractorStyleCamera *>(s->GetTDxStyle());<br />
<br />
t->GetSettings()->SetAngleSensitivity(angleSensitivity);<br />
t->GetSettings()->SetTranslationXSensitivity(translationSensitivity);<br />
t->GetSettings()->SetTranslationYSensitivity(translationSensitivity);<br />
t->GetSettings()->SetTranslationZSensitivity(translationSensitivity);<br />
</pre><br />
<em>Note these settings are programmable and are applied on the input coming from the device. Therefore, they come after the device driver sensitivity and masking settings.</em></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/3DConnexion_Devices_Support&diff=17098VTK/3DConnexion Devices Support2009-10-27T14:55:44Z<p>Goodwin: /* Windows */</p>
<hr />
<div>Support for 3DConnexion Devices (SpaceNavigator, SpaceExplorer, SpacePilot) inside VTK<br />
<br />
= Implementation =<br />
* [[VTK/3DConnexion Devices Support Implementation Work Sheet | Implementation Work Sheet]]<br />
== Date of Implementation ==<br />
* 2009/08/21: experimental work (Linux and Windows)<br />
* 2009/09/10: Qt on Windows, <tt>vtkTDxInteractorStyle</tt>(s), <tt>vtkTDxInteractorStyleSettings</tt><br />
* Implemented by (any question to) François Bertel.<br />
<br />
== TODO ==<br />
* Support for Qt on Linux<br />
* Support for Mac<br />
<br />
= Naming convention =<br />
We pick the name <b>TDx</b> to refer to classes or types to support 3DConnexion Devices. "T" stands for "Three", "x" stands for "connexion". <b>Why?</b> because 3DConnexion calls its software 3DxWare but we cannot have types and classes starting with a number in C++, so we chose "T" instead of "3".<br />
<br />
= Supported Platform =<br />
* Linux: yes (tested with Ubuntu GNU/Linux 9.04 x86_64, gcc, with a 3DConnexion SpaceNavigator)<br />
* Linux with Qt: not yet<br />
* Windows: yes (tested with Windows Vista Ultimate SP2 64-bit, Visual Studio 9 SP1, with a 3DConnexion SpaceNavigator)<br />
* Windows with Qt: yes<br />
* Mac: not yet<br />
* Mac with Qt: not yet<br />
<br />
= How to use it=<br />
== Install the 3DConnexion Device driver ==<br />
=== Linux ===<br />
==== Download ====<br />
* Download the driver from the 3DConnexion wesbite: http://www.3dconnexion.com/support/downloads.php<br />
** Select the product, (example SpaceNavigator SE),<br />
** select the OS (Linux),<br />
** select the driver file for the architecture (3DxWare for Linux (i386) for 32-bit, 3DxWare for Linux (x86_64) for 64-bit )<br />
<br />
For example, for Linux 64-bit, we will get the 3 following files:<br />
* 3dxware-linux-v1-4-3.x86_64.tar.gz,<br />
* InstallationInstructions_Linux.txt,<br />
* Release_Notes-All_Platforms-20090806.pdf<br />
<br />
==== Install required packages ====<br />
On Ubuntu, install package <b>libmotif3</b>. The GUI of the 3DConnexion device driver uses it.<br />
<br />
==== Install the driver ====<br />
<b>As root</b>, (from InstallationInstructions_Linux.txt):<br />
# $ cd /tmp<br />
# tar xzvf path/to/3dxware-linux-v1-4-3.x86_64.tar.gz<br />
# ./install-3dxunix.sh<br />
<br />
Then, you have to change to permissions of the installed files manually (ref [[http://www.3dconnexion.com/forum/viewtopic.php?t=2727&sid=0bb82b3f29689c5408974e06a0a94962 forum thread]]) in <tt>/etc/3DxWare</tt>:<br />
<pre><br />
sudo chmod go+rx /etc/3DxWare<br />
sudo chmod go+r /etc/3DxWare/*.scg <br />
</pre><br />
<br />
==== Test the driver ====<br />
Launch the daemon (with sudo):<br />
<pre><br />
sudo /etc/3DxWare/daemon/3dxsrv -d usb <br />
</pre><br />
The GUI is created but not on top of the desktop. Check for a 3DxWare window on your desktop.<br />
<br />
If you forgot to change permissions of the installed files, we will have this error message:<br />
<pre><br />
$ sudo /etc/3DxWare/daemon/3dxsrv -d usb<br />
3DxWareUNIX = V1.4.3<br />
Device = SpaceNavigator<br />
Firmware = V3.18<br />
[2009-08-19 12:01:28] Error: Can't find any configuration files! Please reinstall you configurations in /etc/3DxWare properly!<br />
</pre><br />
<br />
<br />
For testing/disgnostic purpose (for fun too), launch of one the programs provided in the archive (uncompressed in /tmp for the first step):<br />
<pre><br />
$ /tmp/xcube<br />
$ /tmp/xvalue<br />
</pre><br />
<br />
=== Windows ===<br />
Easy. Nothing to add about it.<br />
=== Mac OS ===<br />
Easy. Nothing to add about it.<br />
<br />
== Install the 3DConnexion SDK ==<br />
=== Linux ===<br />
* Go the the 3DConnexion SDK webpage: http://www.3dconnexion.com/support/sdk.php <br />
* Register, accept the license<br />
* Download xdevelop.tgz<br />
* Uncompress xdevelop.tgz wherever you want<br />
<pre><br />
$ tar xzvf xdevelop.tgz<br />
</pre><br />
* Prepare a Makefile for Linux from <tt>makefile.dec</tt>:<br />
* a. cp makefile.dec makefile.linux<br />
* b. edit makefile.linux and remove occurrences of -DDEC and -fullwarn . Add a -fPIC option to the build object section. Add a section to build a static library. To sum up, you end up with a <tt>makefile.linux</tt> file like (the big spaces at the beginning of lines are tabs, they <b>must</b> be tabs, not spaces):<br />
<pre><br />
all: xapp xdrvlib.a<br />
ls -al xapp<br />
<br />
xdrvlib.o: xdrvlib.c xdrvlib.h<br />
gcc xdrvlib.c -c -fPIC<br />
<br />
xdrvlib.a: xdrvlib.o<br />
ar rcs xdrvlib.a xdrvlib.o<br />
<br />
xapp: xapp.c xdrvlib.o<br />
gcc xapp.c xdrvlib.o -o xapp -lX11 -lm<br />
</pre><br />
<br />
*Build the static library:<br />
<pre><br />
# 3. make -f makefile.linux<br />
</pre><br />
the result of the build is <b><tt>xdrvlib.a</tt></b>. There is also an application <b><tt>xapp</tt></b>.<br />
<br />
At this point, for testing/diagnostic purpose, you can try to launch xapp.<br />
<br />
=== Windows ===<br />
Easy. There is nothing more to install +.<br />
<br />
(This is because the Windows SDK (TDxInput.dll) installs when you install 3DxSoftware. You can find TDxInput.dll in ..\Program Files\3Dconnexion\3Dconnexion 3DxSoftware\3DxWare\win32 or \win64. )<br />
<br />
+ If you use any of the Visual C++ Express Editions, then you are missing ATL (Active Template Library) which is only available in the "professional" editions. You will notice that your (express) compiler will complain that it can not find "atlbase.h". Follow these steps to remedy the situation:<br />
<br />
1. Install "Microsoft ® Windows Server® 2003 R2 Platform SDK" from [http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en here]. You only need to install the "core" and "redistributable" components, so choose a custom installation and disable everything but these components. (Neither Windows Server 2008 SDK nor Windows 7 SDK include the ATL headers)<br />
<br />
2.1 Find the missing header in, eg, C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\atl<br />
<br />
2.2 You need to comment out line 293 in "atlbase.h", so that it reads:<br />
<pre><br />
//#pragma comment(lib, "atlthunk.lib")<br />
</pre><br />
4.1 Open up Visual C++ Express and click the "Tools" menu button, then the "Options" command.<br />
<br />
4.2 In the left-hand pane, click "Projects and Solutions", then "VC++ Directories"<br />
<br />
4.3 In the drop-down menu "Show directories for", choose "Include files"<br />
<br />
4.4 Add the location of "atlbase.h" (probably the same as in 2.1 above) to the list of directories.<br />
<br />
5 You are ready to compile VTK including the 3DConnexion device support with a VC++ express compiler!<br />
<br />
== Configure VTK ==<br />
Launch cmake and set the advanced option <tt>VTK_USE_TDx</tt> to <tt>TRUE</tt><br />
=== Linux ===<br />
Set the advanced variables:<br />
* <tt>VTK_TDX_INCLUDE_PATH</tt> to point to the path of <tt>xdrvlib.h</tt> (without mentioning <tt>xdrvlib.h</tt>)<br />
* <tt>VTK_TDX_OBJECT_PATH</tt> to the full path to <tt>xdrvlib.a</tt> (mentioning <tt>xdrvlib.a</tt>)<br />
=== Windows ===<br />
Easy. There is nothing else to set.<br />
<br />
== Build VTK ==<br />
Just build vtk.<br />
<br />
== Test it ==<br />
Launch TestTDx in interactive mode<br />
*1. Get the full command line of the test with:<br />
<pre><br />
$ ctest -R TestTDx -V -N<br />
</pre><br />
*2. Copy the full command line in the prompt and add -I at the end, to run the test in interactive mode<br />
<br />
*3. Enjoy<br />
<br />
= How to program it =<br />
You can use the device with a <tt>vtkRenderWindowInteractor</tt> (1a) or a <tt>QVTKWidget</tt> (1b).<br />
* Look at <tt>VTK/Rendering/Testing/Cxx/TestTDx.cxx</tt> for a sample code using a regular <tt>vtkRenderWindowInteractor</tt>.<br />
* Look at <tt>VTK/Examples/GUI/Qt/Events/GUI4.cxx</tt> for a sample code using a <tt>QVTKWidget</tt>. <em>To compile it, you have to enable <tt>BUILD_EXAMPLES</tt>, <tt>VTK_USE_QT</tt>, <tt>VTK_USE_GUISUPPORT</tt>, <tt>VTK_USE_QVTK_QOPENGL</tt> and set <tt>DESIRED_QT_VERSION</tt> to 4 in cmake. On Windows in debug mode, the executable is <tt>qtevents.exe</tt> in <tt>$BUILD/bin/Debug</tt></em><br />
<br />
1a. Once the <tt>vtkRenderWindowInteractor</tt> is created, tell it to listen to the device, when the event loop starts (must be called before the first render).<br />
<pre><br />
vtkRenderWindowInteractor *i=vtkRenderWindowInteractor::New();<br />
i->SetUseTDx(true);<br />
</pre><br />
<br />
1b. Once the <tt>QVTKWidget</tt> is created, and before a <tt>vtkRenderWindow</tt> is assigned to it, tell it <br />
to listen to listen to the device, when the event loop starts:<br />
<pre><br />
qVTK1->SetUseTDx(true);<br />
qVTK1->SetRenderWindow(renwin);<br />
</pre><br />
<br />
You can do step 2a or 2b or both:<br />
<br />
<b>2a. Basic event-driven mechanism</b><br />
<br />
Add an observer to watch for a TDx event:<br />
<pre><br />
vtkCommand *c;<br />
[...]<br />
i->AddObserver(vtkCommand::TDxMotionEvent,c,0);<br />
</pre><br />
There are 3 types of events (defined in VTK/Common/vtkCommand.h), they all return some callData:<br />
<br />
# <tt>vtkCommand::TDxMotionEvent</tt>, is invoked when the ball or knob is actived. the callData is a pointer to a <tt>vtkTDxMotionEventInfo</tt> (defined in <tt>VTK/Rendering</tt>). This structure stores information about a translation (X,Y,Z) and a rotation, represented by an angle and an axis (a unit vector). <em>Tip: use <tt>VTK/Common/vtkTransform::RotateWXYZ()</tt> to convert an angle-axis representation to an orthogonal matrix representation of a rotation.</em><br />
# <tt>vtkCommand::TDxButtonPressEvent</tt>, is invoked when a button is pressed. the callData is a pointer to a <tt>int</tt>, which is the number of the button.<br />
# <tt>vtkCommand::TDxButtonReleaseEvent</tt>, is invoked when a button is released. the callData is a pointer to a <tt>int</tt>, which is the number of the button.<br />
<br />
<b>2b. Use or write a concrete subclass of <tt>vtkTDxInteractorStyle</tt></b><br />
<br />
Initially, the <tt>vtkInteractorStyle</tt> attached to the <tt>vtkRenderWindowInteractor</tt> delegates the processing of the <tt>TDx*Events</tt> to a <tt>vtkTDxInteractorStyleCamera</tt>.<br />
It means that, by default, the 3DConnexion device controls camera motions.<br />
You can access the <tt>vtkTDxInteractorStyle</tt> attached to the <tt>vtkInteractorStyle</tt> with <tt>GetTDxStyle()</tt> and<br />
<tt>SetTDxStyle()</tt>.<br />
<br />
In addition, you can change the sensitivity settings and axe motion filtering/masking of the 3DConnexion device for a <tt>vtkTDxInteractorStyle</tt> with the <tt>vtkTDxInteractorStyleSettings</tt> object attached to it. You can share the same settings between different <tt>vtkTDxInteractorStyle</tt>s. Here is the code sample from <tt>VTK/Rendering/Testing/Cxx/TestTDx.cxx</tt> that demonstrates how to set the sensitivity parameters:<br />
<pre><br />
const double angleSensitivity=0.02;<br />
const double translationSensitivity=0.001;<br />
<br />
vtkRenderWindowInteractor *iren;<br />
[...]<br />
vtkInteractorStyle *s=<br />
static_cast<vtkInteractorStyle *>(iren->GetInteractorStyle());<br />
vtkTDxInteractorStyleCamera *t=<br />
static_cast<vtkTDxInteractorStyleCamera *>(s->GetTDxStyle());<br />
<br />
t->GetSettings()->SetAngleSensitivity(angleSensitivity);<br />
t->GetSettings()->SetTranslationXSensitivity(translationSensitivity);<br />
t->GetSettings()->SetTranslationYSensitivity(translationSensitivity);<br />
t->GetSettings()->SetTranslationZSensitivity(translationSensitivity);<br />
</pre><br />
<em>Note these settings are programmable and are applied on the input coming from the device. Therefore, they come after the device driver sensitivity and masking settings.</em></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=12983VTK Mouse Picking2008-09-07T16:07:59Z<p>Goodwin: Updated the link to the new bug tracker</p>
<hr />
<div>The default way to pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
<br />
if {$::MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
<br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to turn mouse picking on/off and to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... here's the link [http://www.vtk.org/Bug/view.php?id=1054 Bug submission]. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
As of 6th May 2005 CVS (for tcl bindings), you can use a double click of a mouse button to pick. In tcl you could have:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
style AddObserver LeftButtonReleaseEvent {style OnLeftButtonUp}<br />
<br />
proc cbLBR {} {<br />
<br />
if {[iren GetRepeatCount] == 1} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
<br />
}<br />
</pre><br />
<br />
For a double click the iren's RepeatCount var is set to 1. For a single click it's set to 0.<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
'''To perform a pick in the example below: move the cursor to the position in the render window you want to pick, then press and release the left mouse button without moving the mouse in between'''. This may seem tricky at first but you'll get used to it!<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre><br />
<br />
{{VTK/Template/Footer}}</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=12863User:Goodwin2008-08-15T00:16:13Z<p>Goodwin: </p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com/vtk here]<br />
<br />
All VTK wiki pages: [http://www.vtk.org/Wiki/index.php?title=Special%3AAllpages&from=VTK&namespace=0]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Talk:Open_Source_Book&diff=12291Talk:Open Source Book2008-05-08T03:23:11Z<p>Goodwin: </p>
<hr />
<div>"Wikinomics" by Don Tapscott and Anthony D. Williams is a good reference, for open source/science and mass collaboration. [http://www.wikinomics.com/ Wikinomics]<br />
<br />
"We-Think" by Charles Leadbeater is recently out, but it seems to have less emphasis on open source and more on mass innovation- haven't read it yet! [http://www.wethinkthebook.net/home.aspx We-Think]<br />
<br />
--[[User:Goodwin|Goodwin]] 20:39, 7 May 2008 (EDT)</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Talk:Open_Source_Book&diff=12290Talk:Open Source Book2008-05-08T00:41:12Z<p>Goodwin: </p>
<hr />
<div>"Wikinomics" by Don Tapscott and Anthony D. Williams is a good reference, for open source/science and mass collaboration. [http://www.wikinomics.com/ Wikinomics]<br />
<br />
"We-Think" by Charles Leadbeatter is recently out, but it seems to have less emphasis on open source and more on mass innovation- haven't read it yet! [http://www.wethinkthebook.net/home.aspx We-Think]<br />
<br />
--[[User:Goodwin|Goodwin]] 20:39, 7 May 2008 (EDT)</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Talk:Open_Source_Book&diff=12289Talk:Open Source Book2008-05-08T00:40:01Z<p>Goodwin: </p>
<hr />
<div>"Wikinomics" by Don Tapscott and Anthony D. Williams is a good reference, for open source/science and mass collaboration. [http://www.wikinomics.com/ Wikinomics]<br />
<br />
"We-Think" by Charles Leadbeatter is recently out, but ive seems to has less emphasis on open source and more on mass innovation- haven't read it yet! [http://www.wethinkthebook.net/home.aspx We-Think]<br />
--[[User:Goodwin|Goodwin]] 20:39, 7 May 2008 (EDT)</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Talk:Open_Source_Book&diff=12288Talk:Open Source Book2008-05-08T00:39:32Z<p>Goodwin: New page: "Wikinomics" by Don Tapscott and Anthony D. Williams is a good reference, for open source/science and mass collaboration. [http://www.wikinomics.com/ Wikinomics] "We-Think" by Charles Lea...</p>
<hr />
<div>"Wikinomics" by Don Tapscott and Anthony D. Williams is a good reference, for open source/science and mass collaboration. [http://www.wikinomics.com/ Wikinomics]<br />
"We-Think" by Charles Leadbeatter is recently out, but ive seems to has less emphasis on open source and more on mass innovation- haven't read it yet! [http://www.wethinkthebook.net/home.aspx We-Think]<br />
--[[User:Goodwin|Goodwin]] 20:39, 7 May 2008 (EDT)</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Tcl_Stubs&diff=11438VTK Tcl Stubs2008-01-23T17:52:37Z<p>Goodwin: Changed the link to the new bug tracker location.</p>
<hr />
<div>To create stubs enabled vtk tcl libraries:<br />
<ul><br />
<li>patch the vtk source with [http://www.vtk.org/Bug/view.php?id=1376 these].</li><br />
<li>run cmake</li><br />
<li>set the advanced flag TCL_TK_STUBS</li><br />
<li>link against tclstub84.lib and tkstub84.lib</li><br />
<li>download a tclkit for your platform from [http://www.equi4.com here]</li><br />
<br />
{{VTK/Template/Footer}}</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/FAQ&diff=6551VTK/FAQ2006-05-30T18:44:47Z<p>Goodwin: /* What is the current release? */ Updated current release to 5.0</p>
<hr />
<div>== General information and availability ==<br />
<br />
=== What is the Visualization Toolkit? ===<br />
<br />
The '''Visualization ToolKit (vtk)''' is a software system for 3D Computer<br />
Graphics and Visualization.<br />
<br />
VTK includes a textbook published by Kitware Inc. ([http://www.kitware.com/products/vtktextbook.html The Visualization<br />
Toolkit, An Object-Oriented Approach to 3D Graphics]),<br />
a C++ class library, and Tcl, Python and Java implementations based on<br />
the class library.<br />
<br />
For more information, see http://www.vtk.org and http://www.kitware.com.<br />
<br />
=== What is the current release? ===<br />
<br />
The current release of vtk is 5.0. This release is available at:<br />
<br />
http://www.vtk.org/files/release/5.0/<br />
<br />
Nightly development releases are available at:<br />
<br />
http://www.vtk.org/files/nightly/<br />
<br />
See http://www.vtk.org/get-software.php for more information.<br />
<br />
=== Can I contribute code or bug fixes? ===<br />
<br />
We encourage people to contribute bug fixes as well as new contributions<br />
to the code. We will try to incorporate these into future releases so<br />
that the entire user community will benefit from them.<br />
<br />
See http://www.vtk.org/contribute.php for information on contributing to<br />
VTK.<br />
<br />
For some ideas take a look at some of the entries in the "Changes to the<br />
VTK API" FAQ section, for example: <br />
[[VTK_FAQ#Roadmap:_What_changes_are_being_considered_for_VTK|What changes are being considered for VTK]]<br />
<br />
We now have a bug tracker that allow keeping track of any bug you could find. See [http://www.vtk.org/Bug BugTracker].<br />
You'll need an email to report a bug.<br />
To improve the chance of a bug being fixed, do not hesisitate to add as many details as possible, a demo sample code + sample data is always a good idea.<br />
Providing a patch almost guarantees that your patch will be incorporated into VTK.<br />
<br />
=== Can I contribute money? ===<br />
<br />
Please don't send money. Not that we think you're going to send in<br />
unsolicited money. But if you were thinking about it, stop. It would<br />
just complicate our lives and make for all sorts of tax problems.<br />
<br />
(Note: if you are a company or funding institution, and would like to fund<br />
features or development, please contact Kitware http://www.kitware.com .)<br />
<br />
=== Is there a mailing list or Usenet newsgroup for VTK? ===<br />
<br />
There is a mailing list: vtkusers@vtk.org<br />
<br />
To subscribe or unsubscribe to the mailing list, go to:<br />
http://www.vtk.org/mailman/listinfo/vtkusers<br />
<br />
To search the list archives go to: http://www.kitware.com/search.html<br />
<br />
There is also a newsgroup that mirrors the mailinglist. At this point it<br />
seems that mirror is down. Mail to the mailinglist used to be posted the<br />
newsgroup, but posts on the newsgroup were not sent to the mailinglist.<br />
The newsgroup was located at:<br />
news://scully.esat.kuleuven.ac.be/vtk.mailinglist<br />
<br />
http://www.gmane.org is a bidirectional mail-to-news gateway that carries the vtkusers mailing list. Its located here: news://news.gmane.org/gmane.comp.lib.vtk.user or here: http://news.gmane.org/gmane.comp.lib.vtk.user. vtkusers mails have been archived since April 2002 and they never expire. You can read and send mails to the vtkusers list but sent mail will bounce back without having subscribed to the list first.<br />
<br />
=== Is the VTK mailing list archived anywhere? ===<br />
<br />
The mailing list is archived at:<br />
http://www.vtk.org/pipermail/vtkusers/<br />
<br />
You can search the archive at: http://www.kitware.com/search.html<br />
<br />
=== Are answers for the exercises in the VTK book available? ===<br />
<br />
Not anymore.<br />
<br />
The answers to the exercises of the textbook used to be maintained by<br />
Martin Stoufer (kudos), and will be made available by Kitware in the<br />
near future.<br />
<br />
=== Is VTK regression tested on a regular basis? Can I help? ===<br />
<br />
Yes, it is.<br />
<br />
You can view the current regression test results at:<br />
http://public.kitware.com/dashboard.php?name=vtk<br />
<br />
VTK uses Dart to perform builds, run tests, and generate dashboards. You<br />
can find more information about Dart at: http://public.kitware.com/Dart/<br />
<br />
You can help improve the quality of VTK by supplying the authors with<br />
Tcl scripts that can be used as or turned into regression tests. A good<br />
regression test will:<br />
<br />
# Cover code that is not already covered.<br />
# Illustrate a bug that is occuring now or that has occurred in the past.<br />
# Use data that is on the 2nd Edition book CDROM or use "small" data files or use no data at all.<br />
# Optionally, produce an interesting result. <br />
<br />
Currently almost all regression tests are written in Tcl.<br />
<br />
Please send your Tcl regression tests to:<br />
mailto:wlorens1@mail.nycap.rr.com<br />
<br />
Bill will evaluate them for applicability and integrate them into the<br />
nightly test process.<br />
<br />
=== What's the best way to learn VTK? ===<br />
<br />
There are five things you might want to try:<br />
<br />
# Purchase the book [http://www.kitware.com/products/vtktextbook.html The Visualization Toolkit] from Kitware Inc.<br />
# Purchase the book [http://www.kitware.com/products/vtkguide.html VTK Users Guide] from Kitware Inc. <br />
# [http://www.vtk.org/get-software.php Download the source code and/or binaries] (available on Windows) and work through the examples (there are 400-500 examples). <br />
# To learn the innards of VTK, you can attend a [http://www.kitware.com/products/proftrain.html#VTKCourse VTK course] or [http://www.kitware.com/products/proftrain.html sponsor a VTK course at your site] through Kitware. http://www.kitware.com/products/index.html<br />
# Buy Bill a beer and get him talking about VTK<br />
<br />
=== How should I ask questions on the mailing lists? ===<br />
<br />
The best online resource for this question is Eric S. Raymond's<br />
excellent guide on the topic titled "How to ask questions the smart<br />
way". Read it here:<br />
<br />
http://www.catb.org/~esr/faqs/smart-questions.html<br />
<br />
Please do read it and follow his advice. Thanks!<br />
<br />
Please also remember the following when you post your messages to the<br />
VTK mailing lists.<br />
<br />
* Mention the version of VTK you are using and the version of the compiler or scripting language you are using.<br />
<br />
* Mention your platform, OS and their versions.<br />
<br />
* Include hardware details if relevant.<br />
<br />
* Include all relevant error messages (appropriately trimmed of course).<br />
<br />
* The lists have a very large number of subscribers (in the thousands), so please keep messages to the point.<br />
<br />
* Avoid HTML emails.<br />
<br />
* Use a sensible and descriptive subject line.<br />
<br />
* Do NOT post large data files or images to the list. Instead put them in your web page and mention the URLs.<br />
<br />
* Quote the messages you reply to appropriately. Remove unnecessary details.<br />
<br />
When asking a question or reporting a problem try to include a small<br />
example program that demonstrates the problem. Make sure that this<br />
example program is as small as you can make it, simple (and uses VTK<br />
alone), complete and demonstrates the problem adequately. Doing this<br />
will go a *long way* towards getting a quick and meaningful response.<br />
<br />
Sometimes you might not get any acceptable response. This happens<br />
bacause the others think the question has either been already answered<br />
elsewhere (the archives, FAQ and google are your friends), or believe<br />
that you have not done enough homework to warrant their attention, or<br />
they don't know the answer or simply don't have the time to answer.<br />
Please do be patient and understanding. Most questions are answered by<br />
people volunteering their time to help you.<br />
<br />
Happy posting!<br />
<br />
=== How NOT to go about a programming assignment ===<br />
<br />
This is really a link you should read before posting to the mailing list. <br />
[This article is an attempt to show these irrational attitudes in an ironical way, <br />
intending to make our students aware of bad habits without admonishing them.]<br />
<br />
http://www.di.uniovi.es/~cernuda/noprog_ENG.html<br />
<br />
=== Is VTK FDA-Approved ? ===<br />
<br />
Given the fact that VTK is a software toolkit, it cannot be the<br />
subject of FDA approval as a medical device. We have discussed<br />
this topic in several occasions and received advice from FDA<br />
representatives, that can be summarized as follow:<br />
<br />
<br />
VTK is to be considered as an off-the-shelf (OTS) product that<br />
is used for supporting a higher level medical application/product.<br />
The developer of such application/product will be responsible for<br />
performing the validation processes described in FDA published<br />
guidelines for the development of software-related medical devices.<br />
<br />
For mode details see the page [[FDA Guidelines for Software Developement]]<br />
<br />
=== Accessing VTK CVS from behind a firewall ===<br />
<br />
Use the sourceforge project:<br />
<br />
http://cvsgrab.sourceforge.net/<br />
<br />
Just download the script and type something like:<br />
<br />
cvsgrab -rootUrl http://public.kitware.com/cgi-bin/cvsweb.cgi/ -packagePath VTK -destDir . <br />
-proxyUser xxx -proxyPassword xxx -proxyHost xxx -proxyPort xx<br />
<br />
(Thanks to Ingo H. de Boer)<br />
<br />
Also cvsgrab support the following option to access a particular branch:<br />
<br />
-tag <version tag> [optional] The version tag of the files to download<br />
<br />
For example to get the latest 4.4 branch:<br />
<br />
cvsgrab -rootUrl http://public.kitware.com/cgi-bin/cvsweb.cgi/ -packagePath VTK -destDir . <br />
-proxyUser xxx -proxyPassword xxx -proxyHost xxx -proxyPort xxx<br />
-tag release-4-4<br />
<br />
== Language bindings ==<br />
<br />
=== Are there bindings to languages other than Tcl? ===<br />
<br />
Aside from C++ (which it's written in) and Tcl, vtk is also bound into<br />
Java as of JDK 1.1 and Python 1.5, 1.6 and 2.X. All of the<br />
Tcl/Java/Python wrapper code is generated from some LEX and YACC code<br />
that parses our classes and extracts the required information to<br />
generate the wrapper code.<br />
<br />
=== What version of Tcl/Tk should I use with VTK? ===<br />
<br />
Currently we recommend that you use Tcl/Tk 8.2.3 with VTK. This is the<br />
best-supported version combination at this time.<br />
<br />
VTK has also been tested with Tcl/Tk 8.3.2 and works well.<br />
<br />
Tcl/Tk 8.3.4 has been tested to a limited extent but seems to have more<br />
memory leaks that Tcl 8.3.2 has.<br />
<br />
Tcl/Tk 8.4.x seems to work well with VTK too, but you might have to<br />
change a couple of configuration settings depending on the version of<br />
VTK you are using. Check the [[VTK_FAQ#Does_VTK_support_Tcl.2FTk_8.4_.3F|Does VTK support Tcl/Tk 8.4?]].<br />
<br />
=== Where can I find Python 2.x binaries? ===<br />
<br />
All of the Python binaries available on the kitware site are built for<br />
Python 1.5.2. This includes the official release VTK3.2 and the nightly<br />
builds (as at 2001-07-16).<br />
<br />
For Python 2.x binaries, you will have to compile your own from source.<br />
It is worth checking the mailing list archives for comments by others<br />
who have been through this process.<br />
<br />
There are some user-contributed binaries available at other sites. Check<br />
the mailing list archives for possible leads. Some win32 binaries for<br />
Python 2.1 are available at;<br />
<br />
http://basic.netmeg.net/godzilla/<br />
<br />
YMMV...<br />
<br />
=== Why do I get the Python error -- ValueError: method requires a VTK object? ===<br />
<br />
You just built VTK with Python support and everything went smoothly.<br />
After you install everything and try running a Python-VTK script you get<br />
a traceback with this error:<br />
<br />
ValueError: method requires a VTK object.<br />
<br />
This error occurs if you have two copies of the VTK libraries on your<br />
system. These copies need not be in your linkers path. The VTK libraries<br />
are usually built with an rpath flag (under *nix). This is necessary to<br />
be able to test the build in place. When you install VTK into another<br />
directory in your linkers path and then run a Python script the Python<br />
modules remember the old path and load the libraries in the build<br />
directory as well. This triggers the above error since the object you<br />
passed the method was instantiated from the other copy.<br />
<br />
So how do you fix it? The easiest solution is to simply delete the copy<br />
of the libraries inside your build directory or move the build directory<br />
to another place. For example, if you build the libraries in VTK/bin<br />
then move VTK/bin to VTK/bin1 or remove all the VTK/bin/*.so files. The<br />
error should no longer occur.<br />
<br />
Another way to fix the error is to turn the CMAKE_SKIP_RPATH boolean to<br />
ON in your CMakeCache.txt file and then rebuild VTK. You shouldn't have<br />
to rebuild all of VTK, just delete the libraries (*.so files) and then<br />
re-run cmake and make. The only trouble with this approach is that you<br />
cannot have BUILD_TESTING to ON when you do this.<br />
<br />
Alternatively, starting with recent VTK CVS versions (post Dec. 6, 2002)<br />
and with VTK versions greater than 4.1 (i.e. 4.2 and beyond) there is a<br />
special VTK-Python interpreter built as part of VTK called 'vtkpython'<br />
that should eliminate this problem. Simply use vtkpython in place of the<br />
usual python interpreter when you use VTK-Python scripts and the problem<br />
should not occur. This is because vtkpython uses the libraries inside<br />
the build directory.<br />
<br />
2002 by Prabhu Ramachandran<br />
<br />
=== Does VTK support Tcl/Tk 8.4 ? ===<br />
<br />
Short answer: yes, but it might require some adjustments, depending on<br />
the VTK and CMake versions you are using.<br />
<br />
# The VTK 4.x CVS nightly/development distribution supports Tcl/Tk 8.4 as long as you use a release version of CMake > 1.4.5. Since VTK 4.2 will require CMake 1.6, the next release version will support Tcl/Tk 8.4.<br />
# The VTK 4.0 release distribution does not support Tcl/Tk 8.4 out-of-the-box.<br />
<br />
In either cases, the following solutions will adress the problem. This<br />
basically involves setting two definition symbols that will make Tcl/Tk<br />
8.4 backward compatible with previous versions of Tcl/Tk (i.e. discard<br />
the "const correctness" and Tk_PhotoPutBlock compositing rule features) :<br />
<br />
a) Edit your C/C++ flags:<br />
<br />
Run your favorite CMake cache editor (i.e. CMakeSetup, or ccmake),<br />
display the advanced values and add the USE_NON_CONST and<br />
USE_COMPOSITELESS_PHOTO_PUT_BLOCK definition symbols to the end of any<br />
of the following CMake variables (if they exist): CMAKE_CXX_FLAGS,<br />
CMAKE_C_FLAGS.<br />
<br />
Example: On Unix your CMAKE_CXX_FLAGS will probably look like:<br />
<br />
-g -O2 -DUSE_NON_CONST -DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
On Windows (Microsoft MSDev nmake mode):<br />
<br />
/W3 /Zm1000 /GX /GR /YX /DUSE_NON_CONST /DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
b) or a more intrusive solution:<br />
<br />
Edit the top VTK/CMakeList.txt file and the following lines add '''at the<br />
top''' of this file:<br />
<br />
ADD_DEFINITIONS(<br />
-DUSE_NON_CONST<br />
-DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
)<br />
<br />
== Using VTK ==<br />
<br />
=== The C++ compiler cannot convert some pointer type to another pointer type in my little program ===<br />
<br />
For instance, the C++ compiler cannot convert a vtkDataSet * type to a vtkImageData * type.<br />
<br />
It means the compiler does not know the relationship between a vtkDataSet and a vtkImageData.<br />
This relationship is actually inheritance: vtkImageData is a subclass of vtkDataSet. The only way for the compiler to know this relationship is to include<br />
the header file of the subclass, that is:<br />
<br />
#include "vtkImageData.h"<br />
<br />
If you wonder why the compiler did not complain about an unknown type, it is because somewhere (probably in a filter header file) there is forward class declaration, like:<br />
<br />
class vtkImageData;<br />
<br />
=== What object/filter should I use to do ??? ===<br />
<br />
Frequently when starting out with a large visualization system people<br />
are not sure what object to use to achieve a desired effect.<br />
<br />
The most up-to-date information can be found in the VTK User's Guide<br />
(http://www.kitware.com/products/vtkguide.html).<br />
<br />
Alternative sources for information are the appendix of the book which<br />
has nice one line descriptions of what the different objects do and the<br />
VTK man pages (http://www.vtk.org/doc/nightly/html/classes.html).<br />
<br />
Additionally, the VTK man pages feature a "Related" section that provide<br />
links from each class to all the examples or tests using that class<br />
(http://www.vtk.org/doc/nightly/html/pages.html). This information is<br />
also provided in each class man page under the "Tests" or "Examples"<br />
sub-section.<br />
<br />
Some useful books are listed at http://www.vtk.org/buy-books.php<br />
<br />
=== What 3D file formats can VTK import and export? ===<br />
<br />
The following table identifies the file formats that VTK can read and<br />
write. Importer and Exporter classes move full scene information into or<br />
out of VTK. Reader and Writer classes move just geometry.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! File Format !! Read !! Write<br />
|-<br />
| 3D Studio || vtk3DSImporter || <br />
|-<br />
| AVS "UCD" format || vtkAVSucdReader || <br />
|-<br />
| Movie BYU || vtkBYUReader || vtkBYUWriter<br />
|-<br />
| Renderman || || vtkRIBExporter<br />
|-<br />
| Open Inventor 2.0 || || vtkIVExporter/vtkIVWriter<br />
|-<br />
| CAD STL || vtkSTLReader || vtkSTLWriter<br />
|-<br />
| Fluent GAMBIT ASCII || vtkGAMBITReader || <br />
|-<br />
| Unigraphics Facet Files || vtkUGFacetReader || <br />
|-<br />
| Marching Cubes || vtkMCubesReader || vtkMCubesWriter<br />
|-<br />
| Wavefront OBJ || || vtkOBJExporter<br />
|-<br />
| VRML 2.0 || || vtkVRMLExporter<br />
|-<br />
| VTK Structured Grid &dagger; || vtkStructuredGridReader || vtkStructuredWriter<br />
|-<br />
| VTK Poly Data &dagger; || vtkPolyDataReader || vtkPolyDataWriter<br />
|-<br />
| PLOT3D || vtkPLOT3DReader || <br />
|-<br />
| CGM || || vtkCGMWriter<br />
|-<br />
| OBJ || vtkOBJReader || <br />
|-<br />
| Particle || vtkParticleReader || <br />
|-<br />
| PDB || vtkPDBReader || <br />
|-<br />
| PLY || vtkPLYReader || vtkPLYWriter<br />
|-<br />
| Gaussian || vtkGaussianCubeReader || <br />
|-<br />
| Facet || vtkFacetReader || vtkFacetWriter<br />
|-<br />
| XYZ || vtkXYZMolReader || <br />
|-<br />
| Ensight &Dagger; || vtkGenericEnSightReader || <br />
|}<br />
<br />
&dagger; See the books [http://www.kitware.com/products/vtktextbook.html The<br />
Visualization Toolkit, An Object-Oriented Approach to 3D Graphics] or<br />
[http://www.kitware.com/products/vtkguide.html the User's Guide] for details<br />
about structured grid and poly data file formats.<br />
<br />
&Dagger; The class vtkGenericEnSightReader allows the user to read an EnSight<br />
data set without a priori knowledge of what type of EnSight data set it<br />
is (among vtkEnSight6BinaryReader, vtkEnSight6Reader,<br />
vtkEnSightGoldBinaryReader, vtkEnSightGoldReader,<br />
vtkEnSightMasterServerReader, vtkEnSightReader).<br />
<br />
For any other file format you may want to search for a converter to a<br />
known VTK file format, more info on:<br />
http://www.tech-edv.co.at/lunix/UTILlinks.html<br />
<br />
=== Why can't I find vtktcl (vtktcl.c)? ===<br />
<br />
In versions of VTK prior to 4.0 VTK Tcl scripts would require a:<br />
<br />
catch {load vtktcl} <br />
<br />
so that they could be executed directly from wish. In VTK 4.0 the<br />
correct mechanism is to use:<br />
<br />
package require vtk<br />
<br />
For people using versions earlier than 4.0, vtktcl is a shared library<br />
that is built only on the PC. Most examples used the "catch" notation so<br />
that they will work on UNIX and on the PC. On UNIX you must use the vtk<br />
executable/shell which should be in vtk/tcl/vtk.<br />
<br />
=== Why does this filter not produce any output? eg. GetPoints()==0 ===<br />
<br />
This is a very common question for VTK users. VTK uses a pipeline mechanism for rendering, which has multiple benefits, including the fact that filters that aren't used don't get called. This means that when you call a function such as x->GetOutput()->GetPoints() this will return 0 if the filter has not yet been executed. Just call x->Update() beforehand to make the pipeline update everything up to that point and it should work. -timh<br />
<br />
=== Problems with vtkDecimate and vtkDecimatePro ===<br />
<br />
''vtkDecimate'' and ''vtkDecimatePro'' have been tested fairly heavily so<br />
all known bugs have been removed. However, there are three situations<br />
where you can encounter weird behavior:<br />
<br />
# The mesh is not all triangles. Solution: use ''vtkTriangleFilter'' to triangulate polygons.<br />
# The mesh consists of independent triangles (i.e., not joined at vertices - no decimation occurs). Solution: use ''vtkCleanPolyData'' to link triangles.<br />
# Bad triangles are present: e.g., triangles with duplicate vertices such as (1,2,1) or (100,100,112), or (57,57,57), and so on. Solution: use ''vtkCleanPolyData''.<br />
<br />
=== How can I read DICOM files ? ===<br />
<br />
VTK does not support the DICOM protocol/format directly, although VTK is<br />
able to read 2D and 3D ''raw'' files, i.e. slices or volumes (see<br />
''vtkImageReader'', ''vtkVolumeReader'', and derived classes). Hence, one<br />
solution is to convert DICOM files to a suitable raw format.<br />
<br />
DICOM is a huge protocol, thus we would suggest you to look for any<br />
existing converters before coding your own DICOM reader. Some of them<br />
are listed in the The Medical Image Format FAQ (Part 8):<br />
http://www.dclunie.com/medical-image-faq/html/part8.html<br />
<br />
Sebastien BARRE wrote a free DICOM converter, named dicom2, that can be<br />
used to convert medical images to raw format. This tool is a command<br />
line program and does not provide any GUI at the moment.<br />
http://dicom2.barre.nom.fr/<br />
<br />
There is a special section dedicated to the VTK:<br />
http://dicom2.barre.nom.fr/how-to.html, then "Convert to raw (vtk)"<br />
<br />
The following page also provide links to several other DICOM converters:<br />
http://www.barre.nom.fr/medical/samples/index.html#links<br />
<br />
Finally in VTK 4.4 you have access to a simple vtkDICOMImageReader [http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html]<br />
<br />
For a more elaborate DICOM library that support compressed jpeg, go to [http://www.creatis.insa-lyon.fr/Public/Gdcm/]<br />
<br />
=== How to handle large data sets in VTK ===<br />
<br />
One of the challenges in VTK is to efficiently handle large datasets. By<br />
default VTK is tuned towards smaller datasets. For large datasets there<br />
are a couple of changes you can make that should yield a much smaller<br />
memory footprint (less swapping) and also improve rendering performance.<br />
The solution is to:<br />
<br />
# Use ReleaseDataFlag,<br />
# Turn on ImmediateModeRendering<br />
# Use triangle strips via vtkStripper<br />
# Use a different filter or mapper<br />
<br />
Each of these will be discussed below.<br />
<br />
1) Using ReleaseDataFlag<br />
<br />
By default VTK keeps a copy of all intermediate results between filters<br />
in a pipeline. For a pipeline with five filters this can result in<br />
having six copies of the data in memory at once. This can be controlled<br />
using ReleaseDataFlag and GlobalReleaseDataFlag. If ReleaseDataFlag is<br />
set to one on a data object, then once a filter has finished using that<br />
data object, it will release its memory. Likewise, if<br />
GlobalReleaseDataFlag is set on ANY data object, all data objects will<br />
release their memory once their dependent filter has finished executing.<br />
For example in Tcl and C++<br />
<br />
# Tcl<br />
vtkPolyDataReader reader<br />
[reader GetOutput] ReleaseDataFlagOn<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->GlobalReleaseDataFlagOn();<br />
<br />
While turning on the ReleaseDataFlag will reduce your memory footprint,<br />
the disadvantage is that none of the intermediate results are kept in<br />
memory. So if you interactively change a parameter of a filter (such as<br />
the isosurface value), all the filters will have to re-execute to<br />
produce the new result. When the intermediate results are stored in<br />
memory, only the downstream filters would have to re-execute.<br />
<br />
One hint for good interactive performance. If only one stage of the<br />
pipeline can have its parameters changed interactively (such as the<br />
target reduction in a decimation filter), only retain the data just<br />
prior to that step (which is the default) and turn ReleaseDataFlag on<br />
for all other steps.<br />
<br />
2) Use ImmediateModeRendering<br />
<br />
By default, VTK uses OpenGL display lists which results in another copy<br />
of the data being stored in memory. For most large datasets you will be<br />
better off saving memory by not using display lists. You can turn off<br />
display lists by turning on ImmediateModeRendering. This can be<br />
controlled on a mapper by mapper basis using ImmediateModeRendering, or<br />
globally for all mappers in a process by using<br />
GlobalImmediateModeRendering. For example:<br />
<br />
# Tcl<br />
vtkPolyDataMapper mapper<br />
mapper ImmediateModeRenderingOn<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->GlobalImmediateModeRenderingOn();<br />
<br />
The disadvantage to using ImmediateModeRendering is that if memory is<br />
not a problem, your rendering rates will typically be slower with<br />
ImmediateModeRendering turned on.<br />
<br />
3) Use triangle strips via vtkStripper.<br />
<br />
Most filters in VTK produce independent triangles or polygons which are<br />
not the most compact or efficient to render. To create triangle strips<br />
from polydata you can first use vtkTriangleFilter to convert any<br />
polygons to triangles (not required if you only have triangles to start<br />
with) then run it through a vtkStipper to convert the triangles into<br />
triangle strips. For example in C++<br />
<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->SetFileName("yourdatafile.vtk");<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkTriangleFilter *tris = vtkTriangleFilter::New();<br />
tris->SetInput(reader->GetOutput());<br />
tris->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkStripper *strip = vtkStripper::New();<br />
strip->SetInput(tris->GetOutput());<br />
strip->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
mapper->SetInput(tris->GetOutput());<br />
<br />
The only disadvantage to using triangle strips is that they require time<br />
to compute, so if your data is changing every time you render, it could<br />
actually be slower.<br />
<br />
4) Use a different filter or mapper<br />
<br />
This is a tough issue. In VTK there are typically a couple of ways to<br />
solve any problem. For example an image can be rendered as a polygon for<br />
each pixel, or it can be rendered as a single polygon with a texture map<br />
on it. For almost all cases the second approach will be much faster than<br />
the first event though VTK supports both. There isn't a single good<br />
answer for how to find the best approach. If you suspect that it is<br />
running more slowly than it should, try posting to the mailing list or<br />
looking for other ways to achieve the same result.<br />
<br />
=== VTK is slow, what is wrong? ===<br />
<br />
We have heard people say that VTK is really slow. In many of these<br />
cases, changing a few parameters can make a huge difference in performance.<br />
<br />
If you find that VTK is slower than other visualization systems running<br />
the same problem first take a look at the FAQ section dealing with large<br />
data: [[VTK_FAQ#How_to_handle_large_data_sets_in_VTK|How to handle large data sets in VTK]]. Many of its suggestions<br />
will improve VTK's performance significantly for many datasets.<br />
<br />
If you still find VTK slow, please let us know and send us an example<br />
(to mailto:kitware@kitware.com). In the past there<br />
have been some filters that simply were not written to be fast. When we<br />
come across one of these we frequently can make minor changes to the<br />
filter that will make it run much more quickly. In fact many changes in<br />
the past couple years have been this type of performance improvement.<br />
<br />
=== Is VTK thread-safe ? ===<br />
<br />
The short answer is no.<br />
<br />
Many VTK sources and filters cache information and will not perform as<br />
expected when used in multiple threads. When writing a multithreaded<br />
filter, the developer has to be very careful about how she accesses data.<br />
<br />
For example, GetXXX() methods which return a pointer should only be used<br />
to read. If the pointer returned by these methods are used to change<br />
data in multiple threads (without mutex locks), the result will most<br />
probably be wrong and unpredictable. In many cases, there are<br />
alternative methods which copy the data referred by the pointer. For<br />
example:<br />
<br />
float* vtkDataArray::GetTuple(const vtkIdType i);<br />
<br />
is thread-safe only for reading whereas:<br />
<br />
void vtkDataArray::GetTuple (const vtkIdType i, float * tuple);<br />
<br />
copies the requested tuple and is thread safe even if tuple is modified<br />
afterwards (as long as the same pointer is not passed as the argument<br />
tuple simultaneously by different threads).<br />
<br />
Unfortunately, only very few methods are clearly marked as<br />
thread-(un)safe and, in many situations, the developer has to dig into<br />
the source code to figure out whether an accessor is thread safe or not.<br />
<br />
''vtkDataSet'' and most of it's sub-classes are well documented and almost<br />
all methods are marked thread-safe or not thread-safe. This might be a<br />
good place to start. Most of the filters in imaging and some filters in<br />
graphics (like ''vtkStreamer'') are good examples of how a multi-threaded<br />
filter can be written in VTK.<br />
<br />
However, if you are not interested in developing multithreaded filters<br />
but want to process some data in parallel using the same (or similar)<br />
pipeline, your job is much easier. To do this, create a different copy<br />
of the pipeline on each thread and execute them in parallel on a<br />
different piece of the data. This is best accomplished by using<br />
''vtkThreadedController'' (instead of ''vtkMultiThreader''). See the<br />
documentation of ''vtkMultiProcessController'' and ''vtkThreadedController''<br />
and the examples in the parallel directory for details on how this can<br />
be done.<br />
<br />
Also, note that most of the OpenGL libraries are not thread-safe.<br />
Therefore, if you are rendering to multiple render windows from<br />
different threads, you are likely to get in trouble, even if you have<br />
mutex locks around the render calls.<br />
<br />
=== Can I use STL with VTK? ===<br />
<br />
As of VTK version 4.2, you can use STL. However, the following policy<br />
applies.<br />
<br />
# STL is for implementation, not interface. All STL references should be contained in a .cxx class or the private section of the .h header file.<br />
# Use the PIMPL idiom to forward reference/contain STL classes in heavily used superclasses. STL is big, fat, and slow to compile so we do not want to include STL headers in any .h files that are included by most of VTK, e.g. vtkObject.h vtkSource.h etc.<br />
# Include the VTK wrapper header files: vtkstd/map instead of map.<br />
# Use the vtkstd:: namespace to refer to STL classes and functions.<br />
<br />
Here's an example (from vtkInterpolateVelocityField):<br />
<br />
In the .h file (the PIMPL) forward declare<br />
<br />
class vtkInterpolatedVelocityFieldDataSetsType;<br />
//<br />
class VTK_COMMON_EXPORT vtkInterpolatedVelocityField : public vtkFunctionSet<br />
{<br />
private:<br />
vtkInterpolatedVelocityFieldDataSetsType* DataSets;<br />
};<br />
<br />
In the .cxx file define the class (here deriving from the STL vector<br />
container)<br />
<br />
# include <vtkstd/vector><br />
typedef vtkstd::vector< vtkSmartPointer<vtkDataSet> > DataSetsTypeBase;<br />
class vtkInterpolatedVelocityFieldDataSetsType: public DataSetsTypeBase<br />
{};<br />
<br />
In the .cxx file construct and destruct the class:<br />
<br />
vtkInterpolatedVelocityField::vtkInterpolatedVelocityField()<br />
{<br />
this->DataSets = new vtkInterpolatedVelocityFieldDataSetsType;<br />
}<br />
vtkInterpolatedVelocityField::~vtkInterpolatedVelocityField()<br />
{<br />
delete this->DataSets;<br />
}<br />
<br />
And in the .cxx file use the container as you would any STL container:<br />
<br />
for ( DataSetsTypeBase::iterator i = this->DataSets->begin();<br />
i != this->DataSets->end(); ++i)<br />
{<br />
ds = i->GetPointer();<br />
....<br />
}<br />
<br />
=== What image file formats can VTK read and write? ===<br />
<br />
The following table identifies the image file formats that VTK can read<br />
and write.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! Image File !! Read !! Write<br />
|-<br />
| Bitmap || vtkBMPReader || vtkBMPWriter<br />
|-<br />
| Digital Elevation Model (DEM) || vtkDEMReader || <br />
|-<br />
| DICOM || vtkDICOMImageReader || <br />
|-<br />
| GE Signal || vtkGESignaReader || <br />
|-<br />
| JPEG || vtkJPEGReader || vtkJPEGWriter<br />
|-<br />
| Binary UNC meta image data || vtkMetaImageReader || vtkMetaImageWriter<br />
|-<br />
| PNG || vtkPNGReader || vtkPNGWriter<br />
|-<br />
| PNM || vtkPNMReader || vtkPNMWriter<br />
|-<br />
| PostScript || || vtkPostScriptWriter <br />
|-<br />
| SLC || vtkSLCReader || <br />
|-<br />
| TIFF || vtkTIFFReader || vtkTIFFWriter<br />
|-<br />
| RAW files &dagger; || vtkImageReader, vtkVolumeReader || <br />
|}<br />
<br />
&dagger; A typical example of use is:<br />
<br />
# Image pipeline<br />
reader = vtkImageReader()<br />
reader.SetDataByteOrderToBigEndian()<br />
reader.SetDataExtent(0,511,0,511,0,511)<br />
reader.SetFilePrefix("Ser397")<br />
reader.SetFilePattern("%s/I.%03d")<br />
reader.SetDataScalarTypeToUnsignedShort()<br />
reader.SetHeaderSize(5432)<br />
<br />
=== Printing an object. ===<br />
<br />
Sometimes when debugging you need to print an object to a string, either<br />
for logging purposes, or in the case of windows applications, to a window.<br />
<br />
Here is a way to do this:<br />
<br />
std::ostringstream os;<br />
//<br />
// "SomeVTKObject" could be, for example, <br />
// declared somewhere as: vtkCamera *SomeVTKObject;<br />
//<br />
SomeVTKObject->Print(os);<br />
vtkstd::string str = os.str();<br />
//<br />
// Process the string as you want<br />
<br />
=== Writing a simple CMakeLists.txt. ===<br />
<br />
If you get something that looks like:<br />
<br />
undefined reference to<br />
`__imp___ZN13vtkTIFFReader3NewEv'<br />
collect2: ld returned 1 exit status <br />
<br />
You certainly forgot to pass in a library to your executable. The easisest way is to use CMakeLists.txt file.<br />
<br />
For example the minimal project is:<br />
<br />
FIND_PACKAGE(VTK)<br />
IF (VTK_FOUND)<br />
INCLUDE (${VTK_USE_FILE})<br />
ENDIF (VTK_FOUND)<br />
ADD_EXECUTABLE(tiff tiff.cxx )<br />
TARGET_LINK_LIBRARIES (tiff<br />
vtkRendering<br />
)<br />
<br />
Since vtkRendering is link against all other vtk lib. Except if you are building VTK with Hybrid or Parallel in that case you need to explicitely specify which library you want to link against.<br />
<br />
=== Testing for VTK within a configure script ===<br />
<br />
VTK uses CMake as build tool but if you VTK-based application wants to use autoconf and/or automake, then you will find very useful an M4 macro file which detects from your configure script the presence/absence of VTK on the user system. VTK won't add such file into the official distribution but you can always write your own, as I did.<br />
Look in [[VTK_Autoconf]] page for more info.<br />
<br />
=== How do I get my C++ code editor to do VTK-style indentation? ===<br />
<br />
If you are writing code with VTK, you may want to follow the [[VTK Coding Standards]]. This is particularly important if you plan to contribute back to VTK. Most C++ code editors will help you with indenting, but the indenting may differ significantly from that prescribed by the [[VTK Coding Standards]]. Fortunately, most editors have enough options to allow you to change the indention enough to get at least close to the VTK-style indentation.<br />
<br />
Below is a list of C++ editors and some suggestions on getting the indentation VTK compliant. If you use a popular editor that is not listed here, please feel free to contribute.<br />
<br />
==== Microsoft Visual C++ .NET indentation ====<br />
<br />
Under the "Tools" menu, select "Options". Go to the options under "Text Editor" and then "C/C++". Click the "Tabs" options. Set "Indenting" to "Smart", "Indent Size" to 2, and select "Insert spaces". Click the "Formatting" options enable "Indent braces".<br />
<br />
This will make most of the indentation correct. However, it will indent all of the braces. In VTK classes, most of the braces are indented, but those starting a class, method, or function are typically flush left. You will have to correct this on your own.<br />
<br />
==== Emacs indentation ====<br />
<br />
Place the [[Elisp Code for VTK-Style C Indentation]] in your .emacs file.<br />
<br />
== Platform-specific questions ==<br />
<br />
=== What platforms does vtk run on? ===<br />
<br />
VTK should compile and run on most versions of Unix, Linux, Windows, and Mac OS X.<br />
It has been tested on Suns, SGIs, HPs, Alphas, RS6000s and many Windows<br />
workstations.<br />
<br />
=== What Graphics Cards work with VTK ===<br />
<br />
VTK uses OpenGL to perform almost all of its rendering and some graphics cards/drivers have better support for OpenGL than others. This is not a listing of what cards perform well. It is a listing of what cards actually produce correct results. Here is a list of cards and their status roughly in best to worst order.<br />
<br />
Any Nvidia desktop card on Windows -- 100% compatible<br /> <br />
Any ATI desktop cards on Windows -- 100% compatible<br /><br />
Mesa -- most releases pass all VTK tests<br /><br />
Microsoft Software OpenGL -- passes all VTK tests but does have a couple bugs <br /><br />
Non-linux UNIX cards (Sun HP SGI) -- These generally work<br /><br />
Any Nvidia card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Any ATI card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Nvidia laptop graphics cards under Windows -- known to have some issues, newer cards pass all tests<br /><br />
ATI laptop graphcis cards under Windows -- known to have some issues, newer cards pass all tests (e.g. [http://public.kitware.com/pipermail/vtkusers/2004-August/075966.html ATI Mobility Radeon 9600])<br /><br />
MacOSX graphics cards -- fails some VTK tests<br /><br />
Intel Extreme Graphics -- fails some VTK tests<br /><br />
<br />
<br />
<br />
=== How do I build the examples on the PC running Windows? ===<br />
<br />
Since building the C++ examples on the PC isn't all that easy, here are<br />
some instructions from Jack McInerney.<br />
<br />
Steps for creating a VTK C++ project 8/14/96<br />
<br />
This is based on what I learned creating a project to run the Mace<br />
example. These steps allowed me to successfully built and run this example.<br />
<br />
# Create a console project (File, New, then select Console application).<br />
# Add the files of interest to the project. (e.g., Mace.cxx)<br />
# Under Build, select Update all Dependencies. A long list of .hh files will show up under dependencies<br /> For this to work, Visual C++ needs to know where to look to find the include files. In my case they are at C:\VTK\VTK12SRC\INCLUDE. To tell Visual C++ to look there, go to Tools, Options. Select the tab Directories. Under the list for Include files add: C:\VTK\VTK12SRC\INCLUDE<br />
# Compile the file Mace.cxx. This will lead to many warnings about data possibly lost as double variables are converted to float variables. These can be gotten rid of by going to Build, Settings, and select the C++ tab. Under the General catagory, set Warning Level to 1* (instead of 3).<br />
# Before linking, some additional settings must be modified. Go to Build, Settings, and select the Link tab. In the General catagory, add the libraries opengl32.lib and glaux.lib to the Object/Library Modules. Put a space between each file name. Then select the C++ tab and the Category: Code Generation. Under Use Run-Time Library, select Debug Multithreaded DLL. Select OK to exit the dialog box. The above libraries are available from Microsoft's Web site at: http://www.microsoft.com/softlib/mslfiles/Opengl95.exe or ftp://ftp.microsoft.com/softlib/mslfiles/Opengl95.exe <br /> This is a self extracting archive which contains these files. Simply place them in your windows system directory.<br />
# Link the code by selecting Build, Build MaceProject.exe. I still get one warning when I do this, but it appears to be harmless<br /><br />
<br />
When you go to run the program, it will bomb out unless it can find 2<br />
DLLs: Opengl32.dll and Glu32.dll. These need to be located either in the<br />
project directory or the C:\WINDOWS directory. These files are supplied<br />
on the vtk CD-ROM (in the vtk\bin directory).<br />
<br />
=== How do I build the Java examples on the PC running Windows? ===<br />
One common issue building the examples is missing one or all of vtkPanel, vtkCanvas and AxesActor<br />
classes. For whatever reason these are not in the vtk.jar (at least for 4.2.2).<br />
But you can get them from the source distribution (just unzip the source and extract<br />
these needed .java files, and point your Java-compiler to them).<br />
<br />
Another common issue appears to be class loading dependency errors. Make sure the<br />
directory with the .dll files is in your classpath when you run (default location<br />
is C:\Program Files\vtk42\bin\). Yet this still seems insufficient for some of the<br />
libraries. One possible solution is to copy the Java awt.dll to this directory as<br />
well.<br />
<br />
=== 64-bit System Issues ===<br />
<br />
vtk does run on the DEC Alpha but vtk binary files are not compatible<br />
between 32-bit and 64-bit systems. For portability, use the default file<br />
type, ascii, for vtkPolyDataWriter, etc. You may be able to write a<br />
binary file on a 64-bit system and read it back in.<br />
<br />
=== What size swap space should I use on a PC? ===<br />
<br />
Building vtk on the PC requires a significant amount of memory (at least<br />
when using Visual C++)... but the final product is nice and compact. To<br />
build vtk on the PC, we recommend setting the min/max swap space to at<br />
least 400MB/500MB (depending on how much RAM you have... the sum of RAM<br />
and swap space should be roughly 500+ MB).<br />
<br />
=== Are there any benchmarks of VTK and/or the hardware it runs on? ===<br />
<br />
Take a look at the "Simple Sphere Benchmark":<br />
<br />
http://www.barre.nom.fr/vtk/bench.html<br />
<br />
It is not a "real world" benchmark, but provide synthetic results<br />
comparing different hardware running VTK:<br />
<br />
http://purl.oclc.org/NET/rriv/vtk/sphere-bench<br />
<br />
=== Why is XtString undefined when using VTK+Python on Unix? ===<br />
<br />
This is a side effect of dynamic linking on (some?) Unix systems. It<br />
appears often on Linux with the Mesa libraries at least. The solution is<br />
to make sure your Mesa libraries are linked with the Xt library. One way<br />
to do this is to add "-lXt" to MESA_LIB in your user.make file.<br />
<br />
=== How do I get the Python bindings to work when building VTK with Borland C++? ===<br />
<br />
If you've built VTK with the freely downloadable Borland C++ 5.5 (or its<br />
commercial counterpart) and you're using the Python binaries from<br />
http://www.python.org/, you'll note that when you try to run a VTK<br />
Python example you get something similar to the following error message:<br />
<br />
from vtkCommonPython import * <br />
ImportError: dynamic module does not define init function<br />
(initvtkCommonPython)<br />
<br />
This is because BCC32 prepends an underscore ("_") to all exported<br />
functions, so (in this case) the vtkCommonPython.dll contains a symbol<br />
_initvtkCommonPython which Python does not find. All kits (e.g.<br />
Rendering, Filtering, Patented) will suffer from this problem.<br />
<br />
The solution is to create Borland module definition in the VTK binary<br />
(output) directory, in my case VTK/bin. You have to do this for all kits<br />
that you are planning to use in Python. Each .def file must have the<br />
same basename as the DLL, e.g. "vtkCommonPython.def" for<br />
vtkCommonPython.dll and it must be present at VTK link time. The def<br />
file contains an export alias, e.g.:<br />
<br />
EXPORTS<br />
initvtkCommonPython=_initvtkCommonPython<br />
<br />
The Borland compiler will create an underscore-less alias in the DLL<br />
file and Python will be able to load it as a module.<br />
<br />
=== How do I build Python bindings on AIX ? ===<br />
<br />
There is a problem with dynamic loading on AIX. Old AIX did not have<br />
dlopen/dlsym, but they used load mechanism. Python still reflects this.<br />
VTK is however not compatible with the old load mechanism.<br />
<br />
The following patch to Python 2.2.2 makes python use dlopen/dlsym on AIX<br />
5 or greater.<br />
<br />
http://www.vtk.org/files/misc/python_aix.diff<br />
<br />
=== How to build VTK for offscreen rendering? ===<br />
<br />
Struggled a few hours to get VTK to do offscreen rendering. I use it to<br />
batch process medical images. Without actually producing output on the<br />
screen, I still print resulting images in a report to easily review the<br />
results of an experiment.<br />
<br />
Here is how I solved this problem for VTK version 4.2.2.<br />
<br />
1. Download Mesa-4.0.4 source<br />
<br />
Modify Mesa-4.0.4/Make-config in the 'linux:' target the following vars:<br />
<br />
GL_LIB = libVTKMesaGL.so<br />
GLU_LIB = libVTKMesaGLU.so<br />
GLUT_LIB = libVTKMesaglut.so<br />
GLW_LIB = libVTKMesaGLw.so<br />
OSMESA_LIB = libOSVTKMesa.so<br />
<br />
In Mesa 6.2.1 you need to edit Mesa/configs/default instead:<br />
<br />
# Library names (base name)<br />
GL_LIB = VTKMesaGL<br />
GLU_LIB = VTKMesaGLU<br />
GLUT_LIB = VTKMesaglut<br />
GLW_LIB = VTKMesaGLw<br />
OSMESA_LIB = VTKMesaOSMesa<br />
<br />
<br />
And then export this env var:<br />
<br />
export CFLAGS="-O -g -ansi -pedantic -fPIC -ffast-math-DUSE_MGL_NAMESPACE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L-D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include"<br />
<br />
then<br />
<br />
For Mesa 4.0.4<br />
<br />
make -f Makefile.X11 linux <br />
cp Mesa-4.0.4/lib/* /data/usr/mesa404/lib/<br />
<br />
in Mesa 6.2.1:<br />
<br />
make linux-x86<br />
make install<br />
(I generally use /opt/VTKMesa/*)<br />
<br />
I use 'VTKMesa' name extension to avoid conflicts with my RH9.0 libs<br />
(especially OSMesa lib in XFree!). I'm using shared libraries, because<br />
that allows me to use dynamic libs from VTK and not the vtk program<br />
itself without explicitly having to load VTKMesaGL with my app. I copied<br />
the 'VTKMesa' libs in /data/usr/mesa404/lib/, but any odd place probably<br />
will work. Avoid /usr/lib /usr/local/lib for now.<br />
<br />
2. Follow normal instructions to get a proper working vtk, then<br />
<br />
ccmake <br />
<br />
with the following options:<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
| VTK_USE_MANGLED_MESA || ON<br />
|-<br />
| MANGLED_MESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_MESA_LIBRARY || /data/usr/mesa404/lib/libVTKMesaGL.so<br />
|-<br />
| MANGLED_OSMESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_OSMESA_LIBRARY || /data/usr/mesa404/lib/libOSVTKMesa.so<br />
|-<br />
| OPENGL_xmesa_INCLUDE_DIR || /data/usr/mesa404/include<br />
|}<br />
<br />
test using /data/prog/VTK-4.2.2/Examples/MangledMesa/Tcl scripts<br />
<br />
<br />
If you're doing things on UNIX, you should also look at [[VTK Classes]]. It has links to RenderWindow objects that are probably easier to use than rebuilding VTK with Mesa.<br />
<br />
=== How to get keyboard events working on Mac OS X ? ===<br />
<br />
From: http://vtk.org/pipermail/vtkusers/2004-February/072155.html<br />
<br />
You need to do one of two things to get your executable to properly <br />
register with the Mac OS X window manager:<br />
<br />
1) Add a resource fork to the file using the command "Rez Carbon.r -o <br />
foo". This will add some resources to your file, but note that this <br />
means that you now have a unique Mac OS X file. You cannot back it up <br />
with tar or zip without losing information. Resource forks are <br />
depreciated in the current Mac OS in favor of...<br />
<br />
2) Package your executable within a Mac OS X application package:<br />
mkdir -p foo.app/Contents/MacOS<br />
cp foo foo.app/Contents/MacOS<br />
<br />
<br />
Everything can now be done through the use of ADD_EXECUTABLE + BUNDLE if using cmake 2.0.5.<br />
<br />
On a side note here is a link to apple website on how to [http://developer.apple.com/darwin/runningx11.html install X11 on Mac OS X]<br />
<br />
== Changes to the VTK API ==<br />
<br />
=== What is the policy on Changes to the API ===<br />
<br />
Between patch releases maintain the API unless there is a really strong reason not to. <br />
<br />
Between regular releases maintain backwards compatibility to the API with prior releases of VTK when doing so does not increase the complexity or readability of the current VTK or when the benefits of breaking the API are negligible.<br />
<br />
Clearly these statements have a lot of wiggle room. For example in vtkLightKit BackLight and Headlight were used and released. Now BackLight and HeadLight might make more sense and probably will be easier for non-native English speakers, but is it worth breaking the API for it, probably not. Another factor is how long the API has been around and how widely used it is. These all indicate how painful it will be to change the API which is half of the cost/benefit decision.<br />
<br />
=== Change to vtkIdList::IsId() ===<br />
<br />
vtkIdList::IsId(int id) used to return a 0 or 1 to indicate whether the<br />
specified id is in the list. Now it returns -1 if the id is not in the<br />
list; or a non-negative number indicating the position in the list.<br />
<br />
=== Changes vtkEdgeTable ===<br />
<br />
vtkEdgeTable had two changes. The constructor now takes no arguments,<br />
and you use InitEdgeInsertion() to tell the class how many points are in<br />
the dataset. Also, IsEdge(p1,p2) now returns a -1 if the edge (defined<br />
by points p1,p2) is not defined. otherwise a non-negative integer value<br />
is returned.<br />
<br />
These changes were made to support the association of attributes with<br />
edges.<br />
<br />
=== Changes between VTK 4.2 and VTK 4.4 (and how to update) ===<br />
<br />
We have removed the CVS date, revision, and the language from the<br />
copyright on all the files. This information wasn't being used much and<br />
it created extra work for developers. For example you edit vtkObject.h<br />
rebuild all of VTK, check in you change, then you must rebuild all of<br />
VTK again because commiting the header file causes it to be changed by<br />
CVS (because the revision number changed) This change will also make it<br />
easier to compare different branches of VTK since these revision number<br />
differences will no longer show up. The CVS revision number is still in<br />
the cxx file in the RevisionMacro. You don't need to make any changes to<br />
your code for this.<br />
<br />
The DataArray classes now use a templated intermediate class to share<br />
their implementation. Again there is no need for you to make changes to<br />
your code.<br />
<br />
Legacy code has been removed. Specifically none of the old style<br />
callbacks are supported and observers should be used instead. So where<br />
you used a filter->SetStartMethod(myFunc) you should do a<br />
filter->AddObserver(vtkCommand::StartEvent,myCommand) Usually this will<br />
require you to create a small class for the observer.<br />
vtkImageOpenClose3D.cxx has an example of using an observer and there<br />
are a few other examples in VTK. If you switch to using Observers your<br />
code should also work with versions of VTK from 3.2 or later since the<br />
Observers have been in VTK since VTK 3.2.<br />
<br />
Many functions that previously took or returned float now take or return<br />
double. To change your code to work with VTK 4.4 or later you can just<br />
replace float with double for the appropriate calls and variables. If<br />
you want your code to work with both old and new versions of VTK you can<br />
use vtkFloatingPointType which is defined to be double in VTK 4.4 and<br />
later and it is float in vtk 4.2.5. In versions of VTK prior to 4.2.5<br />
you can use something like:<br />
<br />
#ifndef vtkFloatingPointType<br />
#define vtkFloatingPointType vtkFloatingPointType<br />
typedef float vtkFloatingPointType;<br />
#endif<br />
<br />
at the beginning of your code. That will set it to the correct value for<br />
all versions of VTK old and new.<br />
<br />
=== Use of New() and Delete() now enforced (vs. new & delete) ===<br />
<br />
Constructors and destructors in VTK are now protected. This means you<br />
can no longer use little "new" or "delete" to create VTK instances.<br />
You'll have to use the methods ::New() and ::Delete() (as has been<br />
standard practice for some time).<br />
<br />
The reason for this is to enforce the use of New() and Delete(). Not<br />
using New() and Delete() can lead to bad mojo, mainly reference counting<br />
problems or not taking advantage of special procedures incorporated into<br />
the New() method (e.g., selecting the appropriate hardware interface<br />
during instance creation time).<br />
<br />
If you've used New() and Delete() in your code, these changes will not<br />
affect you at all. If you're using little "new" or "delete", your code<br />
will no longer and compile and you'll have to switch to New() and Delete().<br />
<br />
=== Changes between VTK 4.4 and VTK 4.6 ===<br />
<br />
Collection Changes<br />
<br />
Collections have had some small changes (originally started by Chris<br />
Volpe) to better support reentrant iteration. Specifically all the<br />
collection have an InitTraversal(sit) and GetNextFoobar(sit) methods.<br />
(where Foobar is what the collection contains, for example<br />
GetNextActor(sit)) The argument to both of these methods is a<br />
vtkCollectionSimpleIterator. Most of the collection use in VTK has been<br />
modified to use these new methods. The advantage is that these new<br />
methods support having the same collection be iterated through in a<br />
reentrant safe manner. In the past this was not true and led to a number<br />
of problems. In the future for C++ class development please use this<br />
approach to iterating through a collection. These changes are fully<br />
backwards compatible and no old APIs were harmed in the making of these<br />
changes. So in summary, for the future, where you would have written:<br />
<br />
for (actors->InitTraversal();<br />
(actor = actors->GetNextActor());)<br />
<br />
you would now have:<br />
<br />
vtkCollectionSimpleIterator actorIt;<br />
for (actors->InitTraversal(actorIt);<br />
(actor = actors->GetNextActor(actorIt));)<br />
<br />
=== Changes in VTK between 3.2 and 4.0 ===<br />
<br />
* Changes to vtkDataSetAttributes, vtkFieldData and vtkDataArray: All attributes (scalars, vectors...) are now stored in the field data as vtkDataArray's. vtkDataSetAttributes became a sub-class of vtkFieldData. For backwards compatibility, the interface which allows setting/getting the attributes the old way (by passing in a sub-class of vtkAttributeData such as vtkScalars) is still supported but it will be removed in the future. Therefore, the developers should use the new interface which requires passing in a vtkDataArray to set an attribute. vtkAttributeData and it's sub-classes (vtkScalars, vtkVectors...) will be deprectated in the near future; developers should use vtkDataArray and it's sub-classes instead. We are in the process of removing the use of these classes from vtk filters.<br />
<br />
* Subclasses of vtkAttributeData (vtkScalars, vtkVectors, vtkNormals, vtkTCoords, vtkTensors) were removed. As of VTK 4.0, vtkDataArray and it's sub-classes should be used to represent attributes and fields. Detailed description of the changes and utilities for upgrading from 3.2 to 4.0 can be found in the package: http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
* Added special methods to data arrays to replace methods like<br />
<br />
tc SetTCoord i x y 0<br />
<br />
or<br />
<br />
vc SetVector i vx vy vz<br />
<br />
in interpreted languages (Tcl, Python, Java). Use:<br />
<br />
tc SetTuple2 i x y<br />
<br />
or<br />
<br />
vc SetTuple3 i vx vy vz<br />
<br />
* Improved support for parallel visualization: vtkMultiProcessController and it's sub-classes have been re-structured and mostly re-written. The functionality of vtkMultiProcessController have been re-distributed between vtkMultiProcessController and vtkCommunicator. vtkCommunicator is responsible of sending/receiving messages whereas vtkMultiProcessController (and it's subclasses) is responsible of program flow/control (for example processing rmi's). New classes have been added to the Parallel directory. These include vtkCommunicator, vtkMPIGroup, vtkMPICommunicator, vtkSharedMemoryCommunicator, vtkMPIEventLog... There is now a tcl interpreter which supports parallel scripts. It is called pvtk and can be build on Windows and Unix. Examples for both Tcl and C++ can be found in the examples directories.<br />
<br />
* vtkSocketCommunicator and vtkSocketController have been added. These support message passing via BSD sockets. Best used together with input-output ports.<br />
<br />
* Since it was causing very long compile times (it essentially includes every vtk header file) and it was hard to maintain (you had to add a line whenever you added a class to VTK) vtk.h was removed. You will have to identify the header files needed by your application and include them one by one.<br />
<br />
* vtkIterativeClosestPointTransform has been added. This class is an implementation of the ICP algorithm. It matches two surfaces using the iterative closest point (ICP) algorithm. The core of the algorithm is to match each vertex in one surface with the closest surface point on the other, then apply the transformation that modify one surface to best match the other (in a least square sense).<br />
<br />
* The SetFileName, SaveImageAsPPM and related methods in vtkRenderWindow have been removed. vtkWindowToImageFilter combined with any of the image writers provides greater functionality.<br />
<br />
* Support for reading and writing PGM and JPEG images has been included.<br />
<br />
* Methods with parameters of the form "type param[n]" are wrapped. Previously, these methods were only wrapped if the array was declared 'const'. The python wrappers will allow values to be returned in the array.<br />
<br />
* The directory structure was completely reorganized. There are now subdirectories for Common (core common classes) Filtering (superclasses for filtering operations) Imaging (filters and sources that produce images or structured points) Graphics (filters or sources that produce data types other than ImageData and StructuredPoints) IO (file IO classes that do not require Rendering support) Rendering (all actors mappers annotation and rendering classes) Hybrid (typically filters and sources that require support from Rendering or both Imaging and Graphics) Parallel (parallel visualization support classes) Patented (patented classes) Examples (documented examples) Wrapping (support for the language wrappers). In many directories you will see a Testing subdirectory. The Testing subdirectories contain tests used to validate VTKs operation. Some tests may be useful as examples but they are not well documented.<br />
<br />
* The Build process for VTK now uses CMake (found at www.cmake.org) This replaces pcmaker on windows and configure on UNIX. This resolves some longstanding problems and limitation we were having with pcmaker and configure, and unifies the build process into one place.<br />
<br />
=== Changes to VTK between 4.0 and 4.2 ===<br />
<br />
* Use of macros to support serialization, standardize the New method, and provide the Superclass typedef.<br />
<br />
* Subclassing of VTK classes in the python wrappers (virtual method hooks are not provided).<br />
<br />
* vtkImageWindow, vtkImager, vtkTkImageWindowWidget and their subclasses have been removed to reduce duplicated code and enable interation in ImageWindows. Now people should use vtkRenderer and vtkRenderWindow instead. vtkImageViewer still works as a turn key image viewing class although it now uses vtkRenderWindow and vtkRenderer internally instead of vtkImageWindow and vtkImager.<br />
<br />
* New class: vtkBandedPolyDataContourFilter. Creates solid colored bands (like you find on maps) of scalar value.<br />
<br />
* Event processing: Several new events to VTK were added (see vtkCommand.h). Also event processing can now be prioritized and aborted. This allows applications to manage who processes which events, and terminates the processing of a particular event if desired.<br />
<br />
* 3D Widgets: A new class vtkInteractorObserver was added to observe events on vtkRenderWindowInteractor. Using the new event processing infrastructure, multiple 3D widgets (subclasses of vtkInteractorObserver) can be used simultaneously to process interactions. Several new 3D widgets have been added including:<br />
** vtkLineWidget<br />
** vtkPlaneWidget<br />
** vtkImagePlaneWidget<br />
** vtkBoxWidget<br />
** vtkSphereWidget<br />
<br />
* Besides providing a representation, widgets also provide auxiliary functionality such as providing transforms, implicit functions, plane normals, sphere radius and center, etc.<br />
<br />
* New class: vtkInstantiator provides a means by which one can create an instance of a VTK class using only the name of the class as a string.<br />
<br />
* New class: vtkXMLParser provides a wrapper around the Expat XML parsing library. A new parser can be written by subclassing from vtkXMLParser and providing a few simple virtual method implementations.<br />
<br />
* TIFF reader is now implemented using libtiff, which makes it capable of reading almost all available TIFF formats. The libtiff is also available internally as vtktiff.<br />
<br />
* New method (all sub-classes of vtkObject): Added a virtual function called NewInstance to vtkTypeMacro. NewInstance creates and returns an object of the same type as the current one. It does not copy any properties. The returned pointer is of the same type as the pointer the method was invoked with. This method should replace all the MakeObject methods scattered through VTK.<br />
<br />
* vtkSetObject macro is depricated for use inside the VTK. It is still a valid construct in projects that use VTK. Instead use vtkCxxSetObjectMacro which does the same thing.<br />
<br />
* vtkPLOT3DReader have been improved. It now supports:<br />
** multigrid (each block is one output)<br />
** ascii<br />
** fortran-style byte counts<br />
** little/big endian<br />
** i-blanking (partial)<br />
<br />
* A new vtkTextProperty class has been created, and duplicated text API s have been obsoleted accordingly. Check the<br />
[[VTK_FAQ#Text_properties_in_VTK_4.2|Text properties in VTK 4.2]] FAQ entry for a full description of the change.<br />
<br />
=== How do I upgrade my existing C++ code from 3.2 to 4.x? ===<br />
<br />
This is (a corrected version of) an email that was posted to vtkusers.<br />
Please feel free to correct or add anything.<br />
<br />
{| cellspacing="3" <br />
|- valign="top"<br />
|width="55%" bgcolor="#f0f0ff" style="border:1px solid #ffc9c9;padding:1em;padding-top:0.5em;"|<br />
<br />
I've just ported my medium-sized (40K lines) application from vtk3.2 to<br />
vtk4.x. I thought I would share my experiences with you, in case there<br />
were people out there contemplating it but a bit scared.<br />
<br />
One source of information for upgrading code is:<br />
<br />
http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
I'm using VC++6 + MFC on Win2K and was unable/unwilling to run the<br />
script in the zip file.<br />
<br />
So,<br />
<br />
I switched all my include directories to the new VTK ones and<br />
recompiled. 337 errors, not unexpectedly. Most concerned vtkScalars and<br />
vtkTCoords which have both been removed. Where I was using single value<br />
scalars, like this:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetNumberOfScalars(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetScalar(i,2.3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *scalars = vtkFloatArray::New();<br />
scalars->SetNumberOfComponents(1);<br />
scalars->SetNumberOfTuples(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetTuple1(i,2.3);<br />
...<br />
<br />
OK so far, far fewer errors.<br />
<br />
Where I had 2D texture coordinates:<br />
<br />
vtkTCoords *tcoords = vtkTCoords::New();<br />
tcoords->SetNumberOfTCoords(N);<br />
...<br />
float p[3];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTCoord(i,p);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *tcoords = vtkFloatArray::New();<br />
tcoords->SetNumberOfComponents(2);<br />
tcoords->SetNumberOfTuples(N);<br />
...<br />
float p[2];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTuple(i,p);<br />
....<br />
<br />
All well and good, still fewer errors. Make sure you call<br />
SetNumberOfComponents *before* SetNumberOfTuples else you'll get<br />
problems (I did!).<br />
<br />
Where I was creating 0-255 image data and had been using:<br />
<br />
vtkScalars* scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
...<br />
<br />
Going well!<br />
<br />
When creating RGB images, I had been using:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfScalars(X*Y);<br />
...<br />
scalars->SetActiveComponent(0);<br />
scalars->SetScalar(i,val1);<br />
scalars->SetActiveComponent(1);<br />
scalars->SetScalar(i,val2);<br />
scalars->SetActiveComponent(2);<br />
scalars->SetScalar(i,val3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfTuples(X*Y);<br />
...<br />
scalars->SetComponent(i,0,val1);<br />
scalars->SetComponent(i,1,val2);<br />
scalars->SetComponent(i,2,val3);<br />
...<br />
<br />
My remaining errors concerned vtkWin32OffscreenRenderWindow that has<br />
been removed. Where I had been using:<br />
<br />
vtkWin32OffscreenRenderWindow *offscreen = vtkWin32OffscreenRenderWindow::New();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkWin32OpenGLRenderWindow *offscreen = vtkWin32OpenGLRenderWindow::New();<br />
offscreen->SetOffScreenRendering(1);<br />
...<br />
<br />
All done. I'd had to throw in some #include "vtkFloatArray.h" and things<br />
like that of course. Zero compile errors.<br />
<br />
Had to remember to link against the new vtk lib files, so I removed<br />
<br />
vtkdll.lib <br />
<br />
and added<br />
<br />
vtkCommon.lib<br />
vtkGraphics.lib<br />
<br />
etc.<br />
<br />
Zero link errors. My program is up and running again, no apparant<br />
problems. Plus now I can use all the new features of vtk4. (And I'm sure<br />
it's faster but maybe that's my imagination.)<br />
<br />
All this took me about three hours.<br />
<br />
Bye!<br />
<br />
Tim.<br />
|}<br />
<br />
=== What is the release schedule for VTK ===<br />
<br />
VTK has a formal release every eight to sixteen months. VTK 4.0 was cut<br />
in December of 2001 and released in March 2002. VTK 4.2 was releaseed in<br />
February of 2003. VTK 4.4 (which is an interim release) was released at the end of 2003. The next version of VTK 5.0 will probably be released in early 2005. It now looks like 5.0 should be branched in early June 2005 and released shortly after that.<br />
<br />
=== Roadmap: What changes are being considered for VTK ===<br />
<br />
This is a list of changes that are being considered for inclusion into<br />
VTK. Some of these changes will happen while other changes we would like<br />
to see happen but may not due to funding or time issues. For each change<br />
we try to list what the change is, when we hope to complete it, if it is<br />
actively being developed. Detailed discussion on changes is limited to<br />
the vtk-developers mailing list.<br />
<br />
# Modify existing image filters to use the new vtkImageIterator etc. Most simple filters have been modified to use ithe iterator in VTK 4.2. It would be nice to have some sort of efficient neighborhood iterators but so far we haven't come up with any.<br />
# Rework the polydata and unstructured grid structures (vtkMesh ??). Related ideas include:<br />
#* Make UnstructuredGrid more compact by removing the cell point count from the vtkCellArray. This will reduce the storage required by each cell by 4 bytes.<br />
#* Make vtkPolyData an empty subclass of vtkUnstructuredGrid. There are a number of good reasons for this but it is a tricky task and backwards compatibility needs to be maintained.<br />
# More parallel support, including parallel compositing algorithms<br />
# Algorithms like LIC (http://www-courses.cs.uiuc.edu/~cs419/lic.pdf), maybe a couple terrain-decimation algorithms<br />
# Further integration of STL and other important C++ constructs (like templates)<br />
<br />
VTK 4.4 (intermediate release, end of 2003)<br />
<br />
* convert APIs to double (done)<br />
* remove old callbacks (done)<br />
* blanking<br />
* ref count observers (done)<br />
* switch collections to use iterators (done)<br />
* improve copyright (done)<br />
<br />
VTK 5.0 (major release, early 2005)<br />
<br />
* new pipeline mechanism (see [[Media:Pipeline.pdf|Pipeline.pdf]])<br />
* time support<br />
* true AMR support<br />
<br />
=== Changes to Interactors ===<br />
<br />
The Interactors have been updated to use the Command/Observer events of<br />
vtk. The vtkRenderWindowInteractor now has ivars for all the event<br />
information. There is a new class called<br />
vtkGenericRenderWindowInteractor that can be used to set up the bindings<br />
from other languages like python, Java or TCl.<br />
<br />
A new class vtkInteractorObserver was also added. It has a<br />
SetInteractor() method. It observes the keypress and delete events<br />
invoked by the render window interactor. The keypress activation value<br />
for a widget is now 'i' (although this can be programmed).<br />
vtkInteractorObserver has the state ivar Enabled. All subclasses must<br />
have the SetEnabled(int) method. Convenience methods like On(), Off(),<br />
EnabledOn(), and EnabledOff() are available. The state of the interactor<br />
observer is obtained using GetEnabled(). The SetEnabled(1) method adds<br />
observers to watch the interactor (appropriate to the particular<br />
interactor observer) ; SetEnabled(0) removes the observers . There are<br />
two new events: EnableEvent and DisableEvent which are invoked by the<br />
SetEnabled() method.<br />
<br />
The events also support the idea of priority now. When you add an<br />
observer, you can specify a priority from 0 to 1. Higher values will be<br />
called back first. An observer can also tell the object not to call any<br />
more observers. This way you can handle an event, and stop further<br />
processing. In this way you can add handlers to InteractorStyles without<br />
sub-classing and from wrapped languages.<br />
<br />
For more information see: vtkGenericRenderWindowInteractor,<br />
vtkRenderWindowInteractor, vtkInteractorObserver.<br />
<br />
=== Header files and vtkSetObjectMacro ===<br />
<br />
On some platforms such as MS Visual Studio .NET, compiler is not capable<br />
of handling too big input files. Some VTK files with all includes do<br />
become big enough to overwhelm the compiler. The solution is to minimize<br />
the amount of includes. This especially goes for header files, because<br />
they propagate to other files. Every class header file should include<br />
only the parent class header file. If there is no other alternative, you<br />
should put a comment next to include file explaining why the file has to<br />
be included.<br />
<br />
The related issue is with vtkSetObjectMacro. This file calles some<br />
methods on an argument class, which implies that the argument class<br />
header file has to be included. The result is bloat on the header files.<br />
The solution is to not use vtkSetObjectMacro but vtkCxxSetObjectMacro.<br />
The difference is that vtkCxxSetObjectMacro goes in the Cxx file and not<br />
in the header file.<br />
<br />
Example: Instead of<br />
<br />
#include "vtkBar.h"<br />
class vtkFoo : public vtkObject<br />
{ ...<br />
vtkSetObjectMacro(Bar, vtkBar);<br />
...<br />
};<br />
<br />
Do:<br />
<br />
class vtkBar;<br />
class vtkFoo : public vtkObject<br />
{<br />
...<br />
virtual void SetBar(vtkBar*);<br />
...<br />
};<br />
<br />
and add the following line to vtkFoo.cxx<br />
<br />
vtkCxxSetObjectMacro(vtkFoo,Bar,vtkBar);<br />
<br />
=== Text properties in VTK 4.2 ===<br />
<br />
A new<br />
[http://public.kitware.com/VTK/doc/nightly/html/classvtkTextProperty.html vtkTextProperty]<br />
class has been added to VTK 4.2.<br />
<br />
This class factorizes text attributes that used to be spread out and<br />
duplicated in many different classes (mostly 2D actors and text<br />
mappers). Among those attributes, font family, font size,<br />
bold/italic/shadow properties, horizontal and vertical justification,<br />
line spacing and offset have been retained, whereas new attributes like<br />
color and opacity have been introduced.<br />
<br />
We tried to make sure that you can use a vtkTextProperty to modify text<br />
properties in the same way a vtkProperty can be used to modify the<br />
surface properties of a geometric object. In that regard, you should be<br />
able to share a vtkTextProperty between different actors or assign the<br />
same vtkTextProperty to an actor that offers multiple vtkTextProperty<br />
attributes ([http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlot]<br />
for example).<br />
<br />
Here is a quick example:<br />
<br />
vtkTextActor *actor0 = vtkTextActor::New();<br />
actor0->GetTextProperty()->SetItalic(1);<br />
//<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
//<br />
vtkTextActor *actor1 = vtkTextActor::New();<br />
actor1->SetTextProperty(tprop);<br />
//<br />
vtkTextActor *actor2 = vtkTextActor::New();<br />
actor2->SetTextProperty(tprop);<br />
<br />
*Backward compatibility issues*:<br />
<br />
1) Color and Opacity:<br />
<br />
The text color and text opacity settings are now controlled by the<br />
vtkTextProperty Color and Opacity attributes instead of the<br />
corresponding actor's color and opacity attributes. In the following<br />
example, those settings were controlled by the attributes of the<br />
vtkProperty2D attached to the vtkActor2D (vtkTextActor). The<br />
vtkTextProperty attributes should be used instead:<br />
<br />
vtkTextActor *actor = vtkActor::New();<br />
actor->GetProperty()->SetColor(...);<br />
actor->GetProperty()->SetOpacity(...);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetColor(...);<br />
actor->GetTextProperty()->SetOpacity(...);<br />
<br />
To make migration easier for a while, we have set the vtkTextProperty<br />
default color to ''(-1.0, -1.0, -1.0)'' and the default opacity to ''-1.0''.<br />
These "magic" values are checked by the underlying text mappers at<br />
rendering time. If they are found, the color and opacity of the 2D<br />
actor's vtkProperty2D are used, just as it was in VTK 4.1.<br />
<br />
2) API (i.e. SetBold(), SetItalic(), etc)<br />
<br />
Most of the VTK classes involving text used to provide their own text<br />
attributes like Bold, Italic, Shadow, FontFamily. Thus, each of those<br />
classes would duplicate the vtkTextMapper API through methods like<br />
SetItalic(), SetBold(), SetFontFamily(), etc.<br />
<br />
Moreover, if one class had different text elements (say, for example,<br />
the title and the labels of a scalar bar), there was no way to modify<br />
the text properties of these elements separately.<br />
<br />
The vtkTextProperty class has been created to address both issues, by<br />
obsoleting those duplicated attributes and methods and providing a<br />
unified way to access text properties, and by allowing each class to<br />
associate different vtkTextProperty to different text elements.<br />
<br />
Migrating your code basically involves using the old API on your actor's<br />
vtkTextProperty instead of the actor itself. For example:<br />
<br />
actor->SetBold(1);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetBold(1);<br />
<br />
When a class provides different vtkTextProperty for different text<br />
elements, the TextProperty attribute is usually prefixed with that<br />
element type. Example: AxisTitleTextProperty, or AxisLabelTextProperty.<br />
This allows you to set different aspect for each text elements. If you<br />
want to use the same properties, you can either set the same values on<br />
each vtkTextProperty, or make both vtkTextProperty point to the same<br />
vtkTextProperty object. Example:<br />
<br />
actor->GetAxisLabelTextProperty()->SetBold(1);<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
or:<br />
<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
actor->SetAxisLabelTextProperty(tprop);<br />
actor->SetAxisTitleTextProperty(tprop);<br />
<br />
or:<br />
<br />
actor->SetAxisLabelTextProperty(actor->GetAxisTitleTextProperty());<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
The following list specifies the name of the text properties used in the<br />
VTK classes involving text.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html vtkTextMapper]:<br />
* you can still use the vtkTextMapper + vtkActor2D combination, but we would advise you to use a single vtkTextActor instead, this will give you maximum flexibility.<br />
* has 1 text prop: TextProperty, but although you have access to it, do not twwak it unless you are using vtkTextMapper with a vtkActor2D. In all other cases, use the text prop provided by the actor (see below).<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextActor.html vtkTextActor]:<br />
* has 1 text prop: TextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLabeledDataMapper.html vtkLabeledDataMapper]:<br />
* has 1 text prop: LabelTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCaptionActor2D.html vtkCaptionActor2D]:<br />
* has 1 text prop: CaptionTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLegendBoxActor.html vtkLegendBoxActor]:<br />
* has 1 text prop: EntryTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkAxisActor2D.html vtkAxisActor2D],<br />
[http://www.vtk.org/doc/nightly/html/classvtkParallelCoordinatesActor.html vtkParallelCoordinatesActor], and<br />
[http://www.vtk.org/doc/nightly/html/classvtkScalarBarActor.html vtkScalarBarActor]:<br />
* have 2 text props: TitleTextProperty, LabelTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlotActor]:<br />
* has 3 text prop: TitleTextProperty (plot title), AxisTitleTextProperty, AxisLabelTextProperty (title and labels of all axes)<br />
* the legend box text prop (i.e. entry text prop) can be retrieved through actor->GetLegendBoxActor()->GetEntryTextProperty()<br />
* the X (or Y) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/YAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCubeAxesActor2D.html vtkCubeAxesActor2D]:<br />
* has 2 text props: AxisTitleTextProperty, AxisLabelTextProperty (title and label of all axes)<br />
* the X (Y or Z) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/Y/ZAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched.<br />
<br />
=== Forward declaration in VTK 4.x ===<br />
<br />
Since VTK 4.x all classes have been carefully inspected to only include the necessesary headers, and do what is called 'forward declaration' for all other needed classes. Thus, when you compile your projects using a filter that takes as input a dataset and you are passing an imagedata: you need to explicitely include imagedata within your implementation file. This is true for all data types.<br />
<br />
For example, if you get this error:<br />
<br />
no matching function for call to `vtkContourFilter::SetInput(vtkImageData*)'<br />
VTK/Filtering/vtkDataSetToPolyDataFilter.h:44:<br />
candidates are: virtual void vtkDataSetToPolyDataFilter::SetInput(vtkDataSet*)<br />
<br />
This means you need to add in your code : #include "vtkImageData.h"<br />
<br />
=== Using Volume Rendering in VTK ===<br />
<br />
I recently updated my VTK CVS version. And my c++ code that use to work fine are now complaining about:<br />
<br />
undefined reference to `vtkUnstructuredGridAlgorithm::SetInput(vtkDataObject*)'<br />
undefined reference to `vtkUnstructuredGridAlgorithm::GetOutput()' <br />
<br />
There is now a new subfolder and a new option to enable building the VolumeRendering library. You have to turn VTK_USE_VOLUMERENDERING to ON in order to use it. Also make sure that your executable is linking properly to this new library:<br />
<br />
ADD_EXECUTABLE(foo foo.cxx)<br />
TARGET_LINK_LIBRARIES(foo vtkVolumeRendering)<br />
<br />
== Miscellaneous questions ==<br />
<br />
=== What are the legal issues? ===<br />
<br />
The Visualization Toolkit software is provided under the following<br />
copyright. We think it's pretty reasonable. We do restrict the<br />
distribution of modified code. This is primarily a revision control<br />
issue. We don't want a bunch of renegade vtks running around without us<br />
having some idea why the changes were made and giving us a chance to<br />
incorporate them into the general release.<br />
<br />
Copyright &copy; 1993-2004 Ken Martin, Will Schroeder, Bill Lorensen All<br />
rights reserved.<br />
<br />
Redistribution and use in source and binary forms, with or without<br />
modification, are permitted provided that the following conditions are met:<br />
<br />
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.<br />
<br />
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.<br />
<br />
* Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.<br />
<br />
* Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software.<br />
<br />
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS<br />
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br />
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br />
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR<br />
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br />
<br />
=== Can't you split up the data file? ===<br />
<br />
The data is now in one file that is about 15 Megabytes. This is smaller<br />
than the original data files VTK used and we hope that this size is not<br />
a problem for people anymore. If it is please let us know.<br />
<br />
=== Do you have any shared library tips? ===<br />
<br />
VTK version 4.0 and later supports both shared and static libraries on<br />
most all platforms. For development we typically use shared libraries<br />
since they are faster to link when making small changes. You can control<br />
how VTK builds by setting the BUILD_SHARED_LIBS option in CMake.<br />
<br />
=== What is the deal with the patents ===<br />
<br />
As the copyright mentions there are some patents used in VTK. If you use<br />
any code in the Patented/ directory for commercial application you<br />
should contact the patent holder and obtain a license.<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by General Electric Company: vtkDecimate, vtkMarchingCubes,<br />
vtkMarchingSquares, vtkDividingCubes, vtkSliceCubes and vtkSweptSurface.<br />
The GE contact is:<br />
<br />
Carl B. Horton<br />
Sr. Counsel, Intellectual Property<br />
3000 N. Grandview Blvd., W-710<br />
Waukesha, WI 53188<br />
Phone: (262) 513-4022<br />
E-Mail: mailto:Carl.Horton@med.ge.com<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by Kitware, Inc.: vtkGridSynchronizedTemplates3D,<br />
vtkKitwareContourFilter.h, vtkSynchronizedTemplates2D, and<br />
vtkSynchronizedTemplates3D. The Kitware contact is:<br />
<br />
Ken Martin<br />
Kitware<br />
28 Corporate Drive, Suite 204,<br />
Clifton Park, NY 12065<br />
Phone:1-518-371-3971<br />
E-Mail: mailto:kitware@kitware.com<br />
<br />
{{VTK/Template/Footer}}</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=4196User:Goodwin2006-03-13T18:02:34Z<p>Goodwin: remove the link spam</p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com/vtk here]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=3519User:Goodwin2006-03-12T16:38:43Z<p>Goodwin: revert the link spam!</p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com/vtk here]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=2752VTK Mouse Picking2005-05-06T10:44:08Z<p>Goodwin: Double click picking</p>
<hr />
<div>The default way to pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
<br />
if {$::MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
<br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to turn mouse picking on/off and to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... here's the link [http://www.vtk.org/Bug/bug.php?op=show&bugid=1054&pos=3 Bug submission]. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
As of 6th May 2005 CVS (for tcl bindings), you can use a double click of a mouse button to pick. In tcl you could have:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
style AddObserver LeftButtonReleaseEvent {style OnLeftButtonUp}<br />
<br />
proc cbLBR {} {<br />
<br />
if {[iren GetRepeatCount] == 1} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
<br />
}<br />
</pre><br />
<br />
For a double click the iren's RepeatCount var is set to 1. For a single click it's set to 0.<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
'''To perform a pick in the example below: move the cursor to the position in the render window you want to pick, then press and release the left mouse button without moving the mouse in between'''. This may seem tricky at first but you'll get used to it!<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=ITK/MS_Free_Tool&diff=2684ITK/MS Free Tool2005-02-02T11:59:25Z<p>Goodwin: typos</p>
<hr />
<div>Microsoft has release a free version of its command-line compiler.<br />
Here is a little tutorial on how to get the MS Free Tool working and how to compile ITK with it.<br />
<br />
== Getting the tool ==<br />
<br />
First you have to download the MS Free tool from Microsoft website:<br />
<br />
http://msdn.microsoft.com/visualc/vctoolkit2003/<br />
<br />
However the free MS VC++ toolkit is missing some important tools like "lib.exe", "nmake.exe", "cvtres.exe".<br />
To get them you can download the free SDK from microsoft:<br />
<br />
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/<br />
<br />
You just need the Core SDK. After installing you need to modify the environement variables on your computer:<br />
<br />
* Right click on My Computer -> Properties<br />
<br />
* Go to the 'Advanced' tab and click on ' Environment Variables'<br />
<br />
* Set the variables as follow:<br />
**'''INCLUDE:''' C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft SDK\include\Win64\mfc<br />
**'''LIB:''' C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib;C:\Program Files\Microsoft SDK\Lib<br />
<br />
* Move ''link.exe'' and ''nmake.exe'' from C:\Program Files\Microsoft SDK\Bin\Win64 to C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin<br />
'' (Another approach is to append (after all other bin path), the path: C:\Program Files\Microsoft SDK\Bin\Win64 since nmake depends on another lib from this directory).''<br />
'' Also on a side note you can only compile in Release mode and not Debug mode since Visual C++ Toolkit 2003 is only shipped with libcmt.lib and not libcmtd.lib ''<br />
<br />
You should now be able to compile an application using the free compiler.<br />
<br />
== Compiling ITK with CMake 2.0.4 ==<br />
Only the next release of CMake (2.0.4) will support the Free MS compiler. However, you can get the cvs version of CMake and compile it using your favorite windows compiler and run it.<br />
<br />
* Select 'NMake Makefiles' under Build for:<br />
* Generate the makefiles (Configure/OK)<br />
* Using the console type ''nmake'' at the top of the binary tree<br />
<br />
== Links ==<br />
http://www.wxwindows.org/lnk_msw.htm<br />
<br />
http://www.winprog.org/tutorial/msvc.html</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/FAQ&diff=775VTK/FAQ2005-01-27T17:31:13Z<p>Goodwin: /* Is there a mailing list or Usenet newsgroup for VTK? */</p>
<hr />
<div>== General information and availability ==<br />
<br />
=== What is the Visualization Toolkit? ===<br />
<br />
The '''Visualization ToolKit (vtk)''' is a software system for 3D Computer<br />
Graphics and Visualization.<br />
<br />
VTK includes a textbook published by Kitware Inc. ([http://www.kitware.com/products/vtktextbook.html The Visualization<br />
Toolkit, An Object-Oriented Approach to 3D Graphics]),<br />
a C++ class library, and Tcl, Python and Java implementations based on<br />
the class library.<br />
<br />
For more information, see http://www.vtk.org and http://www.kitware.com.<br />
<br />
=== What is the current release? ===<br />
<br />
The current release of vtk is 4.4. This release is available at:<br />
<br />
http://www.vtk.org/files/release/4.4/<br />
<br />
Nightly development releases are available at:<br />
<br />
http://www.vtk.org/files/nightly/<br />
<br />
See http://www.vtk.org/get-software.php for more information.<br />
<br />
=== Can I contribute code or bug fixes? ===<br />
<br />
We encourage people to contribute bug fixes as well as new contributions<br />
to the code. We will try to incorporate these into future releases so<br />
that the entire user community will benefit from them.<br />
<br />
See http://www.vtk.org/contribute.php for information on contributing to<br />
VTK.<br />
<br />
For some ideas take a look at some of the entries in the "Changes to the<br />
VTK API" FAQ section, for example: <br />
[[VTK_FAQ#Roadmap:_What_changes_are_being_considered_for_VTK|What changes are being considered for VTK]]<br />
<br />
We now have a bug tracker that allow keeping track of any bug you could find. See [http://www.vtk.org/Bug BugTracker].<br />
You'll need an email to report a bug.<br />
To improve the chance of a bug being fixe do not hesisitate to add as much details as possible, a demo sample code + sample data is alwyas a good idea.<br />
Providing a patch almost garantee that your patch will be incorporated into VTK.<br />
<br />
=== Can I contribute money? ===<br />
<br />
Please don't send money. Not that we think you're going to send in<br />
unsolicited money. But if you were thinking about it, stop. It would<br />
just complicate our lives and make for all sorts of tax problems.<br />
<br />
(Note: if you are a company or funding institution, and would like to fund<br />
features or development, please contact Kitware http://www.kitware.com.<br />
<br />
<br />
=== Is there a mailing list or Usenet newsgroup for VTK? ===<br />
<br />
There is a mailing list: vtkusers@vtk.org<br />
<br />
To subscribe or unsubscribe to the mailing list, go to:<br />
http://www.vtk.org/mailman/listinfo/vtkusers<br />
<br />
To search the list archives go to: http://www.kitware.com/search.html<br />
<br />
There is also a newsgroup that mirrors the mailinglist. At this point it<br />
seems that mirror is down. Mail to the mailinglist used to be posted the<br />
newsgroup, but posts on the newsgroup were not sent to the mailinglist.<br />
The newsgroup was located at:<br />
news://scully.esat.kuleuven.ac.be/vtk.mailinglist<br />
<br />
http://www.gmane.org is a bidirectional mail-to-news gateway that carries the vtkusers mailing list. Its located here: news://news.gmane.org/gmane.comp.lib.vtk.user or here: http://news.gmane.org/gmane.comp.lib.vtk.user. vtkusers mails have been archived since April 2002 and they never expire. You can read and send mails to the vtkusers list but sent mail will bounce back without having subscribed to the list first.<br />
<br />
=== Is the VTK mailing list archived anywhere? ===<br />
<br />
The mailing list is archived at:<br />
http://www.vtk.org/pipermail/vtkusers/<br />
<br />
You can search the archive at: http://www.kitware.com/search.html<br />
<br />
=== Are answers for the exercises in the VTK book available? ===<br />
<br />
Not anymore.<br />
<br />
The answers to the exercises of the textbook used to be maintained by<br />
Martin Stoufer (kudos), and will be made available by Kitware in the<br />
next future.<br />
<br />
=== Is VTK regression tested on a regular basis? Can I help? ===<br />
<br />
Yes, it is.<br />
<br />
You can view the current regression test results at:<br />
http://public.kitware.com/dashboard.php?name=vtk<br />
<br />
VTK uses Dart to perform builds, run tests, and generate dashboards. You<br />
can find more information about Dart at: http://public.kitware.com/Dart/<br />
<br />
You can help improve the quality of VTK by supplying the authors with<br />
Tcl scripts that can be used as or turned into regression tests. A good<br />
regression test will:<br />
<br />
# Cover code that is not already covered.<br />
# Illustrate a bug that is occuring now or that has occurred in the past.<br />
# Use data that is on the 2nd Edition book CDROM or use "small" data files or use no data at all.<br />
# Optionally, produce an interesting result. <br />
<br />
Currently almost all regression tests are written in Tcl.<br />
<br />
Please send your Tcl regression tests to:<br />
mailto:wlorens1@mail.nycap.rr.com<br />
<br />
Bill will evaluate them for applicability and integrate them into the<br />
nightly test process.<br />
<br />
=== What's the best way to learn VTK? ===<br />
<br />
There are five things you might want to try:<br />
<br />
# Purchase the book [http://www.kitware.com/products/vtktextbook.html The Visualization Toolkit] from Kitware Inc.<br />
# Purchase the book [http://www.kitware.com/products/vtkguide.html VTK Users Guide] from Kitware Inc. <br />
# [http://www.vtk.org/get-software.php Download the source code and/or binaries] (available on Windows) and work through the examples (there are 400-500 examples). <br />
# To learn the innards of VTK, you can attend a [http://www.kitware.com/products/proftrain.html#VTKCourse VTK course] or [http://www.kitware.com/products/proftrain.html sponsor a VTK course at your site] through Kitware. http://www.kitware.com/products/index.html<br />
# Buy Bill a beer and get him talking about VTK<br />
<br />
=== How should I ask questions on the mailing lists? ===<br />
<br />
The best online resource for this question is Eric S. Raymond's<br />
excellent guide on the topic titled "How to ask questions the smart<br />
way". Read it here:<br />
<br />
http://www.catb.org/~esr/faqs/smart-questions.html<br />
<br />
Please do read it and follow his advice. Thanks!<br />
<br />
Please also remember the following when you post your messages to the<br />
VTK mailing lists.<br />
<br />
* Mention the version of VTK you are using and the version of the compiler or scripting language you are using.<br />
<br />
* Mention your platform, OS and their versions.<br />
<br />
* Include hardware details if relevant.<br />
<br />
* Include all relevant error messages (appropriately trimmed of course).<br />
<br />
* The lists have a very large number of subscribers (in the thousands), so please keep messages to the point.<br />
<br />
* Avoid HTML emails.<br />
<br />
* Use a sensible and descriptive subject line.<br />
<br />
* Do NOT post large data files or images to the list. Instead put them in your web page and mention the URLs.<br />
<br />
* Quote the messages you reply to appropriately. Remove unnecessary details.<br />
<br />
When asking a question or reporting a problem try to include a small<br />
example program that demonstrates the problem. Make sure that this<br />
example program is as small as you can make it, simple (and uses VTK<br />
alone), complete and demonstrates the problem adequately. Doing this<br />
will go a *long way* towards getting a quick and meaningful response.<br />
<br />
Sometimes you might not get any acceptable response. This happens<br />
bacause the others think the question has either been already answered<br />
elsewhere (the archives, FAQ and google are your friends), or believe<br />
that you have not done enough homework to warrant their attention, or<br />
they don't know the answer or simply don't have the time to answer.<br />
Please do be patient and understanding. Most questions are answered by<br />
people volunteering their time to help you.<br />
<br />
Happy posting!<br />
<br />
=== How NOT to go about a programming assignment ===<br />
<br />
This is really a link you should read before posting to the mailing list. <br />
[This article is an attempt to show these irrational attitudes in an ironical way, <br />
intending to make our students aware of bad habits without admonishing them.]<br />
<br />
http://www.di.uniovi.es/~cernuda/noprog_ENG.html<br />
<br />
=== Is VTK FDA-Approved ? ===<br />
<br />
Given the fact that VTK is a software toolkit, it cannot be the<br />
subject of FDA approval as a medical device. We have discussed<br />
this topic in several occasions and received advice from FDA<br />
representatives, that can be summarized as follow:<br />
<br />
<br />
VTK is to be considered as an off-the-shelf (OTS) product that<br />
is used for supporting a higher level medical application/product.<br />
The developer of such application/product will be responsible for<br />
performing the validation processes described in FDA published<br />
guidelines for the development of software-related medical devices.<br />
<br />
For mode details see the page [[FDA Guidelines for Software Developement]]<br />
<br />
== Language bindings ==<br />
<br />
=== Are there bindings to languages other than Tcl? ===<br />
<br />
Aside from C++ (which it's written in) and Tcl, vtk is also bound into<br />
Java as of JDK 1.1 and Python 1.5, 1.6 and 2.X. All of the<br />
Tcl/Java/Python wrapper code is generated from some LEX and YACC code<br />
that parses our classes and extracts the required information to<br />
generate the wrapper code.<br />
<br />
=== What version of Tcl/Tk should I use with VTK? ===<br />
<br />
Currently we recommend that you use Tcl/Tk 8.2.3 with VTK. This is the<br />
best-supported version combination at this time.<br />
<br />
VTK has also been tested with Tcl/Tk 8.3.2 and works well.<br />
<br />
Tcl/Tk 8.3.4 has been tested to a limited extent but seems to have more<br />
memory leaks that Tcl 8.3.2 has.<br />
<br />
Tcl/Tk 8.4.x seems to work well with VTK too, but you might have to<br />
change a couple of configuration settings depending on the version of<br />
VTK you are using. Check the [[VTK_FAQ#Does_VTK_support_Tcl.2FTk_8.4_.3F|Does VTK support Tcl/Tk 8.4?]].<br />
<br />
=== Where can I find Python 2.x binaries? ===<br />
<br />
All of the Python binaries available on the kitware site are built for<br />
Python 1.5.2. This includes the official release VTK3.2 and the nightly<br />
builds (as at 2001-07-16).<br />
<br />
For Python 2.x binaries, you will have to compile your own from source.<br />
It is worth checking the mailing list archives for comments by others<br />
who have been through this process.<br />
<br />
There are some user-contributed binaries available at other sites. Check<br />
the mailing list archives for possible leads. Some win32 binaries for<br />
Python 2.1 are available at;<br />
<br />
http://basic.netmeg.net/godzilla/<br />
<br />
YMMV...<br />
<br />
=== Why do I get the Python error -- ValueError: method requires a VTK object? ===<br />
<br />
You just built VTK with Python support and everything went smoothly.<br />
After you install everything and try running a Python-VTK script you get<br />
a traceback with this error:<br />
<br />
ValueError: method requires a VTK object.<br />
<br />
This error occurs if you have two copies of the VTK libraries on your<br />
system. These copies need not be in your linkers path. The VTK libraries<br />
are usually built with an rpath flag (under *nix). This is necessary to<br />
be able to test the build in place. When you install VTK into another<br />
directory in your linkers path and then run a Python script the Python<br />
modules remember the old path and load the libraries in the build<br />
directory as well. This triggers the above error since the object you<br />
passed the method was instantiated from the other copy.<br />
<br />
So how do you fix it? The easiest solution is to simply delete the copy<br />
of the libraries inside your build directory or move the build directory<br />
to another place. For example, if you build the libraries in VTK/bin<br />
then move VTK/bin to VTK/bin1 or remove all the VTK/bin/*.so files. The<br />
error should no longer occur.<br />
<br />
Another way to fix the error is to turn the CMAKE_SKIP_RPATH boolean to<br />
ON in your CMakeCache.txt file and then rebuild VTK. You shouldn't have<br />
to rebuild all of VTK, just delete the libraries (*.so files) and then<br />
re-run cmake and make. The only trouble with this approach is that you<br />
cannot have BUILD_TESTING to ON when you do this.<br />
<br />
Alternatively, starting with recent VTK CVS versions (post Dec. 6, 2002)<br />
and with VTK versions greater than 4.1 (i.e. 4.2 and beyond) there is a<br />
special VTK-Python interpreter built as part of VTK called 'vtkpython'<br />
that should eliminate this problem. Simply use vtkpython in place of the<br />
usual python interpreter when you use VTK-Python scripts and the problem<br />
should not occur. This is because vtkpython uses the libraries inside<br />
the build directory.<br />
<br />
2002 by Prabhu Ramachandran<br />
<br />
=== Does VTK support Tcl/Tk 8.4 ? ===<br />
<br />
Short answer: yes, but it might require some adjustments, depending on<br />
the VTK and CMake versions you are using.<br />
<br />
# The VTK 4.x CVS nightly/development distribution supports Tcl/Tk 8.4 as long as you use a release version of CMake > 1.4.5. Since VTK 4.2 will require CMake 1.6, the next release version will support Tcl/Tk 8.4.<br />
# The VTK 4.0 release distribution does not support Tcl/Tk 8.4 out-of-the-box.<br />
<br />
In either cases, the following solutions will adress the problem. This<br />
basically involves setting two definition symbols that will make Tcl/Tk<br />
8.4 backward compatible with previous versions of Tcl/Tk (i.e. discard<br />
the "const correctness" and Tk_PhotoPutBlock compositing rule features) :<br />
<br />
a) Edit your C/C++ flags:<br />
<br />
Run your favorite CMake cache editor (i.e. CMakeSetup, or ccmake),<br />
display the advanced values and add the USE_NON_CONST and<br />
USE_COMPOSITELESS_PHOTO_PUT_BLOCK definition symbols to the end of any<br />
of the following CMake variables (if they exist): CMAKE_CXX_FLAGS,<br />
CMAKE_C_FLAGS.<br />
<br />
Example: On Unix your CMAKE_CXX_FLAGS will probably look like:<br />
<br />
-g -O2 -DUSE_NON_CONST -DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
On Windows (Microsoft MSDev nmake mode):<br />
<br />
/W3 /Zm1000 /GX /GR /YX /DUSE_NON_CONST /DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
b) or a more intrusive solution:<br />
<br />
Edit the top VTK/CMakeList.txt file and the following lines add '''at the<br />
top''' of this file:<br />
<br />
ADD_DEFINITIONS(<br />
-DUSE_NON_CONST<br />
-DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
)<br />
<br />
== Using VTK ==<br />
<br />
=== What object/filter should I use to do ??? ===<br />
<br />
Frequently when starting out with a large visualization system people<br />
are not sure what object to use to achieve a desired effect.<br />
<br />
The most up-to-date information can be found in the VTK User's Guide<br />
(http://www.kitware.com/products/vtkguide.html).<br />
<br />
Alternative sources for information are the appendix of the book which<br />
has nice one line descriptions of what the different objects do and the<br />
VTK man pages (http://www.vtk.org/doc/nightly/html/classes.html).<br />
<br />
Additionally, the VTK man pages feature a "Related" section that provide<br />
links from each class to all the examples or tests using that class<br />
(http://www.vtk.org/doc/nightly/html/pages.html). This information is<br />
also provided in each class man page under the "Tests" or "Examples"<br />
sub-section.<br />
<br />
Some useful books are listed at http://www.vtk.org/buy-books.php<br />
<br />
=== What 3D file formats can VTK import and export? ===<br />
<br />
The following table identifies the file formats that VTK can read and<br />
write. Importer and Exporter classes move full scene information into or<br />
out of VTK. Reader and Writer classes move just geometry.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! File Format !! Read !! Write<br />
|-<br />
| 3D Studio || vtk3DSImporter || <br />
|-<br />
| AVS "UCD" format || vtkAVSucdReader || <br />
|-<br />
| Movie BYU || vtkBYUReader || vtkBYUWriter<br />
|-<br />
| Renderman || || vtkRIBExporter<br />
|-<br />
| Open Inventor 2.0 || || vtkIVExporter/vtkIVWriter<br />
|-<br />
| CAD STL || vtkSTLReader || vtkSTLWriter<br />
|-<br />
| Fluent GAMBIT ASCII || vtkGAMBITReader || <br />
|-<br />
| Unigraphics Facet Files || vtkUGFacetReader || <br />
|-<br />
| Marching Cubes || vtkMCubesReader || vtkMCubesWriter<br />
|-<br />
| Wavefront OBJ || || vtkOBJExporter<br />
|-<br />
| VRML 2.0 || || vtkVRMLExporter<br />
|-<br />
| VTK Structured Grid &dagger; || vtkStructuredGridReader || vtkStructuredWriter<br />
|-<br />
| VTK Poly Data &dagger; || vtkPolyDataReader || vtkPolyDataWriter<br />
|-<br />
| PLOT3D || vtkPLOT3DReader || <br />
|-<br />
| CGM || || vtkCGMWriter<br />
|-<br />
| OBJ || vtkOBJReader || <br />
|-<br />
| Particle || vtkParticleReader || <br />
|-<br />
| PDB || vtkPDBReader || <br />
|-<br />
| PLY || vtkPLYReader || vtkPLYWriter<br />
|-<br />
| Gaussian || vtkGaussianCubeReader || <br />
|-<br />
| Facet || vtkFacetReader || vtkFacetWriter<br />
|-<br />
| XYZ || vtkXYZMolReader || <br />
|-<br />
| Ensight &Dagger; || vtkGenericEnSightReader || <br />
|}<br />
<br />
&dagger; See the books [http://www.kitware.com/products/vtktextbook.html The<br />
Visualization Toolkit, An Object-Oriented Approach to 3D Graphics] or<br />
[http://www.kitware.com/products/vtkguide.html the User's Guide] for details<br />
about structured grid and poly data file formats.<br />
<br />
&Dagger; The class vtkGenericEnSightReader allows the user to read an EnSight<br />
data set without a priori knowledge of what type of EnSight data set it<br />
is (among vtkEnSight6BinaryReader, vtkEnSight6Reader,<br />
vtkEnSightGoldBinaryReader, vtkEnSightGoldReader,<br />
vtkEnSightMasterServerReader, vtkEnSightReader).<br />
<br />
For any other file format you may want to search for a converter to a<br />
known VTK file format, more info on:<br />
http://www.tech-edv.co.at/lunix/UTILlinks.html<br />
<br />
=== Why can't I find vtktcl (vtktcl.c)? ===<br />
<br />
In versions of VTK prior to 4.0 VTK Tcl scripts would require a:<br />
<br />
catch {load vtktcl} <br />
<br />
so that they could be executed directly from wish. In VTK 4.0 the<br />
correct mechanism is to use:<br />
<br />
package require vtk<br />
<br />
For people using versions earlier than 4.0, vtktcl is a shared library<br />
that is built only on the PC. Most examples used the "catch" notation so<br />
that they will work on UNIX and on the PC. On UNIX you must use the vtk<br />
executable/shell which should be in vtk/tcl/vtk.<br />
<br />
=== Problems with vtkDecimate and vtkDecimatePro ===<br />
<br />
''vtkDecimate'' and ''vtkDecimatePro'' have been tested fairly heavily so<br />
all known bugs have been removed. However, there are three situations<br />
where you can encounter weird behavior:<br />
<br />
# The mesh is not all triangles. Solution: use ''vtkTriangleFilter'' to triangulate polygons.<br />
# The mesh consists of independent triangles (i.e., not joined at vertices - no decimation occurs). Solution: use ''vtkCleanPolyData'' to link triangles.<br />
# Bad triangles are present: e.g., triangles with duplicate vertices such as (1,2,1) or (100,100,112), or (57,57,57), and so on. Solution: use ''vtkCleanPolyData''.<br />
<br />
=== How can I read DICOM files ? ===<br />
<br />
VTK does not support the DICOM protocol/format directly, although VTK is<br />
able to read 2D and 3D ''raw'' files, i.e. slices or volumes (see<br />
''vtkImageReader'', ''vtkVolumeReader'', and derived classes). Hence, one<br />
solution is to convert DICOM files to a suitable raw format.<br />
<br />
DICOM is a huge protocol, thus we would suggest you to look for any<br />
existing converters before coding your own DICOM reader. Some of them<br />
are listed in the The Medical Image Format FAQ (Part 8):<br />
http://www.dclunie.com/medical-image-faq/html/part8.html<br />
<br />
Sebastien BARRE wrote a free DICOM converter, named dicom2, that can be<br />
used to convert medical images to raw format. This tool is a command<br />
line program and does not provide any GUI at the moment.<br />
http://dicom2.barre.nom.fr/<br />
<br />
There is a special section dedicated to the VTK:<br />
http://dicom2.barre.nom.fr/how-to.html, then "Convert to raw (vtk)"<br />
<br />
The following page also provide links to several other DICOM converters:<br />
http://www.barre.nom.fr/medical/samples/index.html#links<br />
<br />
Finally in VTK 4.4 you have access to a simple vtkDICOMImageReader [http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html]<br />
<br />
For a more elaborate DICOM library that support compressed jpeg, go to [http://www.creatis.insa-lyon.fr/Public/Gdcm/]<br />
<br />
=== How to handle large data sets in VTK ===<br />
<br />
One of the challenges in VTK is to efficiently handle large datasets. By<br />
default VTK is tuned towards smaller datasets. For large datasets there<br />
are a couple of changes you can make that should yield a much smaller<br />
memory footprint (less swapping) and also improve rendering performance.<br />
The solution is to:<br />
<br />
# Use ReleaseDataFlag,<br />
# Turn on ImmediateModeRendering<br />
# Use triangle strips via vtkStripper<br />
# Use a different filter or mapper<br />
<br />
Each of these will be discussed below.<br />
<br />
1) Using ReleaseDataFlag<br />
<br />
By default VTK keeps a copy of all intermediate results between filters<br />
in a pipeline. For a pipeline with five filters this can result in<br />
having six copies of the data in memory at once. This can be controlled<br />
using ReleaseDataFlag and GlobalReleaseDataFlag. If ReleaseDataFlag is<br />
set to one on a data object, then once a filter has finished using that<br />
data object, it will release its memory. Likewise, if<br />
GlobalReleaseDataFlag is set on ANY data object, all data objects will<br />
release their memory once their dependent filter has finished executing.<br />
For example in Tcl and C++<br />
<br />
# Tcl<br />
vtkPolyDataReader reader<br />
[reader GetOutput] ReleaseDataFlagOn<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->GlobalReleaseDataFlagOn();<br />
<br />
While turning on the ReleaseDataFlag will reduce your memory footprint,<br />
the disadvantage is that none of the intermediate results are kept in<br />
memory. So if you interactively change a parameter of a filter (such as<br />
the isosurface value), all the filters will have to re-execute to<br />
produce the new result. When the intermediate results are stored in<br />
memory, only the downstream filters would have to re-execute.<br />
<br />
One hint for good interactive performance. If only one stage of the<br />
pipeline can have its parameters changed interactively (such as the<br />
target reduction in a decimation filter), only retain the data just<br />
prior to that step (which is the default) and turn ReleaseDataFlag on<br />
for all other steps.<br />
<br />
2) Use ImmediateModeRendering<br />
<br />
By default, VTK uses OpenGL display lists which results in another copy<br />
of the data being stored in memory. For most large datasets you will be<br />
better off saving memory by not using display lists. You can turn off<br />
display lists by turning on ImmediateModeRendering. This can be<br />
controlled on a mapper by mapper basis using ImmediateModeRendering, or<br />
globally for all mappers in a process by using<br />
GlobalImmediateModeRendering. For example:<br />
<br />
# Tcl<br />
vtkPolyDataMapper mapper<br />
mapper ImmediateModeRenderingOn<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->GlobalImmediateModeRenderingOn();<br />
<br />
The disadvantage to using ImmediateModeRendering is that if memory is<br />
not a problem, your rendering rates will typically be slower with<br />
ImmediateModeRendering turned on.<br />
<br />
3) Use triangle strips via vtkStripper.<br />
<br />
Most filters in VTK produce independent triangles or polygons which are<br />
not the most compact or efficient to render. To create triangle strips<br />
from polydata you can first use vtkTriangleFilter to convert any<br />
polygons to triangles (not required if you only have triangles to start<br />
with) then run it through a vtkStipper to convert the triangles into<br />
triangle strips. For example in C++<br />
<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->SetFileName("yourdatafile.vtk");<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkTriangleFilter *tris = vtkTriangleFilter::New();<br />
tris->SetInput(reader->GetOutput());<br />
tris->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkStripper *strip = vtkStripper::New();<br />
strip->SetInput(tris->GetOutput());<br />
strip->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
mapper->SetInput(tris->GetOutput());<br />
<br />
The only disadvantage to using triangle strips is that they require time<br />
to compute, so if your data is changing every time you render, it could<br />
actually be slower.<br />
<br />
4) Use a different filter or mapper<br />
<br />
This is a tough issue. In VTK there are typically a couple of ways to<br />
solve any problem. For example an image can be rendered as a polygon for<br />
each pixel, or it can be rendered as a single polygon with a texture map<br />
on it. For almost all cases the second approach will be much faster than<br />
the first event though VTK supports both. There isn't a single good<br />
answer for how to find the best approach. If you suspect that it is<br />
running more slowly than it should, try posting to the mailing list or<br />
looking for other ways to achieve the same result.<br />
<br />
=== VTK is slow, what is wrong? ===<br />
<br />
We have heard people say that VTK is really slow. In many of these<br />
cases, changing a few parameters can make a huge difference in performance.<br />
<br />
If you find that VTK is slower than other visualization systems running<br />
the same problem first take a look at the FAQ section dealing with large<br />
data: [[VTK_FAQ#How_to_handle_large_data_sets_in_VTK|How to handle large data sets in VTK]]. Many of its suggestions<br />
will improve VTK's performance significantly for many datasets.<br />
<br />
If you still find VTK slow, please let us know and send us an example<br />
(to mailto:kitware@kitware.com). In the past there<br />
have been some filters that simply were not written to be fast. When we<br />
come across one of these we frequently can make minor changes to the<br />
filter that will make it run much more quickly. In fact many changes in<br />
the past couple years have been this type of performance improvement.<br />
<br />
=== Is VTK thread-safe ? ===<br />
<br />
The short answer is no.<br />
<br />
Many VTK sources and filters cache information and will not perform as<br />
expected when used in multiple threads. When writing a multithreaded<br />
filter, the developer has to be very careful about how she accesses data.<br />
<br />
For example, GetXXX() methods which return a pointer should only be used<br />
to read. If the pointer returned by these methods are used to change<br />
data in multiple threads (without mutex locks), the result will most<br />
probably be wrong and unpredictable. In many cases, there are<br />
alternative methods which copy the data referred by the pointer. For<br />
example:<br />
<br />
float* vtkDataArray::GetTuple(const vtkIdType i);<br />
<br />
is thread-safe only for reading whereas:<br />
<br />
void vtkDataArray::GetTuple (const vtkIdType i, float * tuple);<br />
<br />
copies the requested tuple and is thread safe even if tuple is modified<br />
afterwards (as long as the same pointer is not passed as the argument<br />
tuple simultaneously by different threads).<br />
<br />
Unfortunately, only very few methods are clearly marked as<br />
thread-(un)safe and, in many situations, the developer has to dig into<br />
the source code to figure out whether an accessor is thread safe or not.<br />
<br />
''vtkDataSet'' and most of it's sub-classes are well documented and almost<br />
all methods are marked thread-safe or not thread-safe. This might be a<br />
good place to start. Most of the filters in imaging and some filters in<br />
graphics (like ''vtkStreamer'') are good examples of how a multi-threaded<br />
filter can be written in VTK.<br />
<br />
However, if you are not interested in developing multithreaded filters<br />
but want to process some data in parallel using the same (or similar)<br />
pipeline, your job is much easier. To do this, create a different copy<br />
of the pipeline on each thread and execute them in parallel on a<br />
different piece of the data. This is best accomplished by using<br />
''vtkThreadedController'' (instead of ''vtkMultiThreader''). See the<br />
documentation of ''vtkMultiProcessController'' and ''vtkThreadedController''<br />
and the examples in the parallel directory for details on how this can<br />
be done.<br />
<br />
Also, note that most of the OpenGL libraries are not thread-safe.<br />
Therefore, if you are rendering to multiple render windows from<br />
different threads, you are likely to get in trouble, even if you have<br />
mutex locks around the render calls.<br />
<br />
=== Can I use STL with VTK? ===<br />
<br />
As of VTK version 4.2, you can use STL. However, the following policy<br />
applies.<br />
<br />
# STL is for implementation, not interface. All STL references should be contained in a .cxx class or the private section of the .h header file.<br />
# Use the PIMPL idiom to forward reference/contain STL classes in heavily used superclasses. STL is big, fat, and slow to compile so we do not want to include STL headers in any .h files that are included by most of VTK, e.g. vtkObject.h vtkSource.h etc.<br />
# Include the VTK wrapper header files: vtkstd/map instead of map.<br />
# Use the vtkstd:: namespace to refer to STL classes and functions.<br />
<br />
Here's an example (from vtkInterpolateVelocityField):<br />
<br />
In the .h file (the PIMPL) forward declare<br />
<br />
class vtkInterpolatedVelocityFieldDataSetsType;<br />
//<br />
class VTK_COMMON_EXPORT vtkInterpolatedVelocityField : public vtkFunctionSet<br />
{<br />
private:<br />
vtkInterpolatedVelocityFieldDataSetsType* DataSets;<br />
};<br />
<br />
In the .cxx file define the class (here deriving from the STL vector<br />
container)<br />
<br />
# include <vtkstd/vector><br />
typedef vtkstd::vector< vtkSmartPointer<vtkDataSet> > DataSetsTypeBase;<br />
class vtkInterpolatedVelocityFieldDataSetsType: public DataSetsTypeBase<br />
{};<br />
<br />
In the .cxx file construct and destruct the class:<br />
<br />
vtkInterpolatedVelocityField::vtkInterpolatedVelocityField()<br />
{<br />
this->DataSets = new vtkInterpolatedVelocityFieldDataSetsType;<br />
}<br />
vtkInterpolatedVelocityField::~vtkInterpolatedVelocityField()<br />
{<br />
delete this->DataSets;<br />
}<br />
<br />
And in the .cxx file use the container as you would any STL container:<br />
<br />
for ( DataSetsTypeBase::iterator i = this->DataSets->begin();<br />
i != this->DataSets->end(); ++i)<br />
{<br />
ds = i->GetPointer();<br />
....<br />
}<br />
<br />
=== What image file formats can VTK read and write? ===<br />
<br />
The following table identifies the image file formats that VTK can read<br />
and write.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! Image File !! Read !! Write<br />
|-<br />
| Bitmap || vtkBMPReader || vtkBMPWriter<br />
|-<br />
| Digital Elevation Model (DEM) || vtkDEMReader || <br />
|-<br />
| DICOM || vtkDICOMImageReader || <br />
|-<br />
| GE Signal || vtkGESignaReader || <br />
|-<br />
| JPEG || vtkJPEGReader || vtkJPEGWriter<br />
|-<br />
| Binary UNC meta image data || vtkMetaImageReader || vtkMetaImageWriter<br />
|-<br />
| PNG || vtkPNGReader || vtkPNGWriter<br />
|-<br />
| PNM || vtkPNMReader || vtkPNMWriter<br />
|-<br />
| PostScript || vtkPostScriptWriter || <br />
|-<br />
| SLC || vtkSLCReader || <br />
|-<br />
| TIFF || vtkTIFFReader || vtkTIFFWriter<br />
|-<br />
| RAW files &dagger; || vtkImageReader, vtkVolumeReader || <br />
|}<br />
<br />
&dagger; A typical example of use is:<br />
<br />
# Image pipeline<br />
reader = vtkImageReader()<br />
reader.SetDataByteOrderToBigEndian()<br />
reader.SetDataExtent(0,511,0,511,0,511)<br />
reader.SetFilePrefix("Ser397")<br />
reader.SetFilePattern("%s/I.%03d")<br />
reader.SetDataScalarTypeToUnsignedShort()<br />
reader.SetHeaderSize(5432)<br />
<br />
=== Printing an object. ===<br />
<br />
Sometimes when debugging you need to print an object to a string, either<br />
for logging purposes, or in the case of windows applications, to a window.<br />
<br />
Here is a way to do this:<br />
<br />
std::ostringstream os;<br />
//<br />
// "SomeVTKObject" could be, for example, <br />
// declared somewhere as: vtkCamera *SomeVTKObject;<br />
//<br />
SomeVTKObject->Print(os);<br />
vtkstd::string str = os.str();<br />
//<br />
// Process the string as you want<br />
<br />
=== Writing a simple CMakeLists.txt. ===<br />
<br />
If you get something that looks like:<br />
<br />
undefined reference to<br />
`__imp___ZN13vtkTIFFReader3NewEv'<br />
collect2: ld returned 1 exit status <br />
<br />
You certainly forgot to pass in a library to your executable. The easisest way is to use CMakeLists.txt file.<br />
<br />
For example the minimal project is:<br />
<br />
FIND_PACKAGE(VTK)<br />
IF (VTK_FOUND)<br />
INCLUDE (${VTK_USE_FILE})<br />
ENDIF (VTK_FOUND)<br />
ADD_EXECUTABLE(tiff tiff.cxx )<br />
TARGET_LINK_LIBRARIES (tiff<br />
vtkRendering<br />
)<br />
<br />
Since vtkRendering is link against all other vtk lib. Except if you are building VTK with Hybrid or Parallel in that case you need to explicitely specify which library you want to link against.<br />
<br />
== Platform-specific questions ==<br />
<br />
=== What platforms does vtk run on? ===<br />
<br />
VTK should compile and run on most versions of Unix, Linux and Windows.<br />
It has been tested on Suns, SGIs, HPs, Alphas, RS6000s and many Windows<br />
workstations. It was also succesfully built on MacOS X.<br />
<br />
=== What Graphics Cards work with VTK ===<br />
<br />
VTK uses OpenGL to perform almost all of its rendering and some graphics cards/drivers have better support for OpenGL than others. This is not a listing of what cards perform well. It is a listing of what cards actually produce correct results. Here is a list of cards and their status roughly in best to worst order.<br />
<br />
Any Nvidia desktop card on Windows -- 100% compatible<br /> <br />
Any ATI desktop cards on Windows -- 100% compatible<br /><br />
Mesa -- most releases pass all VTK tests<br /><br />
Microsoft Software OpenGL -- passes all VTK tests but does have a couple bugs <br /><br />
Non-linux UNIX cards (Sun HP SGI) -- These generally work<br /><br />
Any Nvidia card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Any ATI card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Nvidia laptop graphics cards under Windows -- known to have some issues, newer cards pass all tests<br /><br />
ATI laptop graphcis cards under Windows -- known to have some issues, newer cards pass all tests (e.g. [http://public.kitware.com/pipermail/vtkusers/2004-August/075966.html ATI Mobility Radeon 9600])<br /><br />
MacOSX graphics cards -- fails some VTK tests<br /><br />
Intel Extreme Graphics -- fails some VTK tests<br /><br />
<br />
<br />
<br />
=== How do I build the examples on the PC running Windows? ===<br />
<br />
Since building the C++ examples on the PC isn't all that easy, here are<br />
some instructions from Jack McInerney.<br />
<br />
Steps for creating a VTK C++ project 8/14/96<br />
<br />
This is based on what I learned creating a project to run the Mace<br />
example. These steps allowed me to successfully built and run this example.<br />
<br />
# Create a console project (File, New, then select Console application).<br />
# Add the files of interest to the project. (e.g., Mace.cxx)<br />
# Under Build, select Update all Dependencies. A long list of .hh files will show up under dependencies<br /> For this to work, Visual C++ needs to know where to look to find the include files. In my case they are at C:\VTK\VTK12SRC\INCLUDE. To tell Visual C++ to look there, go to Tools, Options. Select the tab Directories. Under the list for Include files add: C:\VTK\VTK12SRC\INCLUDE<br />
# Compile the file Mace.cxx. This will lead to many warnings about data possibly lost as double variables are converted to float variables. These can be gotten rid of by going to Build, Settings, and select the C++ tab. Under the General catagory, set Warning Level to 1* (instead of 3).<br />
# Before linking, some additional settings must be modified. Go to Build, Settings, and select the Link tab. In the General catagory, add the libraries opengl32.lib and glaux.lib to the Object/Library Modules. Put a space between each file name. Then select the C++ tab and the Category: Code Generation. Under Use Run-Time Library, select Debug Multithreaded DLL. Select OK to exit the dialog box. The above libraries are available from Microsoft's Web site at: http://www.microsoft.com/softlib/mslfiles/Opengl95.exe or ftp://ftp.microsoft.com/softlib/mslfiles/Opengl95.exe <br /> This is a self extracting archive which contains these files. Simply place them in your windows system directory.<br />
# Link the code by selecting Build, Build MaceProject.exe. I still get one warning when I do this, but it appears to be harmless<br /><br />
<br />
When you go to run the program, it will bomb out unless it can find 2<br />
DLLs: Opengl32.dll and Glu32.dll. These need to be located either in the<br />
project directory or the C:\WINDOWS directory. These files are supplied<br />
on the vtk CD-ROM (in the vtk\bin directory).<br />
<br />
=== 64-bit System Issues ===<br />
<br />
vtk does run on the DEC Alpha but vtk binary files are not compatible<br />
between 32-bit and 64-bit systems. For portability, use the default file<br />
type, ascii, for vtkPolyDataWriter, etc. You may be able to write a<br />
binary file on a 64-bit system and read it back in.<br />
<br />
=== What size swap space should I use on a PC? ===<br />
<br />
Building vtk on the PC requires a significant amount of memory (at least<br />
when using Visual C++)... but the final product is nice and compact. To<br />
build vtk on the PC, we recommend setting the min/max swap space to at<br />
least 400MB/500MB (depending on how much RAM you have... the sum of RAM<br />
and swap space should be roughly 500+ MB).<br />
<br />
=== Are there any benchmarks of VTK and/or the hardware it runs on? ===<br />
<br />
Take a look at the "Simple Sphere Benchmark":<br />
<br />
http://www.barre.nom.fr/vtk/bench.html<br />
<br />
It is not a "real world" benchmark, but provide synthetic results<br />
comparing different hardware running VTK:<br />
<br />
http://purl.oclc.org/NET/rriv/vtk/sphere-bench<br />
<br />
=== Why is XtString undefined when using VTK+Python on Unix? ===<br />
<br />
This is a side effect of dynamic linking on (some?) Unix systems. It<br />
appears often on Linux with the Mesa libraries at least. The solution is<br />
to make sure your Mesa libraries are linked with the Xt library. One way<br />
to do this is to add "-lXt" to MESA_LIB in your user.make file.<br />
<br />
=== How do I get the Python bindings to work when building VTK with Borland C++? ===<br />
<br />
If you've built VTK with the freely downloadable Borland C++ 5.5 (or its<br />
commercial counterpart) and you're using the Python binaries from<br />
http://www.python.org/, you'll note that when you try to run a VTK<br />
Python example you get something similar to the following error message:<br />
<br />
from vtkCommonPython import * <br />
ImportError: dynamic module does not define init function<br />
(initvtkCommonPython)<br />
<br />
This is because BCC32 prepends an underscore ("_") to all exported<br />
functions, so (in this case) the vtkCommonPython.dll contains a symbol<br />
_initvtkCommonPython which Python does not find. All kits (e.g.<br />
Rendering, Filtering, Patented) will suffer from this problem.<br />
<br />
The solution is to create Borland module definition in the VTK binary<br />
(output) directory, in my case VTK/bin. You have to do this for all kits<br />
that you are planning to use in Python. Each .def file must have the<br />
same basename as the DLL, e.g. "vtkCommonPython.def" for<br />
vtkCommonPython.dll and it must be present at VTK link time. The def<br />
file contains an export alias, e.g.:<br />
<br />
EXPORTS<br />
initvtkCommonPython=_initvtkCommonPython<br />
<br />
The Borland compiler will create an underscore-less alias in the DLL<br />
file and Python will be able to load it as a module.<br />
<br />
=== How do I build Python bindings on AIX ? ===<br />
<br />
There is a problem with dynamic loading on AIX. Old AIX did not have<br />
dlopen/dlsym, but they used load mechanism. Python still reflects this.<br />
VTK is however not compatible with the old load mechanism.<br />
<br />
The following patch to Python 2.2.2 makes python use dlopen/dlsym on AIX<br />
5 or greater.<br />
<br />
http://www.vtk.org/files/misc/python_aix.diff<br />
<br />
=== How to build VTK for offscreen rendering? ===<br />
<br />
Struggled a few hours to get VTK to do offscreen rendering. I use it to<br />
batch process medical images. Without actually producing output on the<br />
screen, I still print resulting images in a report to easily review the<br />
results of an experiment.<br />
<br />
Here is how I solved this problem for VTK version 4.2.2.<br />
<br />
1. Download Mesa-4.0.4 source<br />
<br />
Modify Mesa-4.0.4/Make-config in the 'linux:' target the following vars:<br />
<br />
GL_LIB = libVTKMesaGL.so<br />
GLU_LIB = libVTKMesaGLU.so<br />
GLUT_LIB = libVTKMesaglut.so<br />
GLW_LIB = libVTKMesaGLw.so<br />
OSMESA_LIB = libOSVTKMesa.so<br />
CFLAGS = -O -g -ansi -pedantic -fPIC -ffast-math-DUSE_MGL_NAMESPACE \<br />
-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L-D_SVID_SOURCE \<br />
-D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include"<br />
<br />
then<br />
<br />
make -f Makefile.X11 linux <br />
cp Mesa-4.0.4/lib/* /data/usr/mesa404/lib/<br />
<br />
I use 'VTKMesa' name extension to avoid conflicts with my RH9.0 libs<br />
(especially OSMesa lib in XFree!). I'm using shared libraries, because<br />
that allows me to use dynamic libs from VTK and not the vtk program<br />
itself without explicitly having to load VTKMesaGL with my app. I copied<br />
the 'VTKMesa' libs in /data/usr/mesa404/lib/, but any odd place probably<br />
will work. Avoid /usr/lib /usr/local/lib for now.<br />
<br />
2. Follow normal instructions to get a proper working vtk, then<br />
<br />
ccmake <br />
<br />
with the following options:<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
| VTK_USE_MANGLED_MESA || ON<br />
|-<br />
| MANGLED_MESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_MESA_LIBRARY || /data/usr/mesa404/lib/libVTKMesaGL.so<br />
|-<br />
| MANGLED_OSMESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_OSMESA_LIBRARY || /data/usr/mesa404/lib/libOSVTKMesa.so<br />
|-<br />
| OPENGL_xmesa_INCLUDE_DIR || /data/usr/mesa404/include<br />
|}<br />
<br />
test using /data/prog/VTK-4.2.2/Examples/MangledMesa/Tcl scripts<br />
<br />
=== How to get keyboard event working on MacOSX ? ===<br />
<br />
From: http://vtk.org/pipermail/vtkusers/2004-February/072155.html<br />
<br />
You need to do one of two things to get your executable to properly <br />
register with the MacOS X window manager:<br />
<br />
1) Add a resource fork to the file using the command "Rez Carbon.r -o <br />
foo". This will add some resources to your file, but note that this <br />
means that you now have a unique MacOS X file. You cannot back it up <br />
with tar or zip without losing information. Resource forks are <br />
depreciated in the current MacOS in favor of...<br />
<br />
2) Package your executable within a MacOS X application package:<br />
mkdir -p foo.app/Contents/MacOS<br />
cp foo foo.app/Contents/MacOS<br />
<br />
<br />
Everything can now be done through the use of ADD_EXECUTABLE + BUNDLE if using cmake 2.0.5.<br />
<br />
On a side note here is a link to apple website on how to [http://developer.apple.com/darwin/runningx11.html install X11 on MacOSX]<br />
<br />
== Changes to the VTK API ==<br />
<br />
=== Change to vtkIdList::IsId() ===<br />
<br />
vtkIdList::IsId(int id) used to return a 0 or 1 to indicate whether the<br />
specified id is in the list. Now it returns -1 if the id is not in the<br />
list; or a non-negative number indicating the position in the list.<br />
<br />
=== Changes vtkEdgeTable ===<br />
<br />
vtkEdgeTable had two changes. The constructor now takes no arguments,<br />
and you use InitEdgeInsertion() to tell the class how many points are in<br />
the dataset. Also, IsEdge(p1,p2) now returns a -1 if the edge (defined<br />
by points p1,p2) is not defined. otherwise a non-negative integer value<br />
is returned.<br />
<br />
These changes were made to support the association of attributes with<br />
edges.<br />
<br />
=== Changes between VTK 4.2 and VTK 4.4 (and how to update) ===<br />
<br />
We have removed the CVS date, revision, and the language from the<br />
copyright on all the files. This information wasn't being used much and<br />
it created extra work for developers. For example you edit vtkObject.h<br />
rebuild all of VTK, check in you change, then you must rebuild all of<br />
VTK again because commiting the header file causes it to be changed by<br />
CVS (because the revision number changed) This change will also make it<br />
easier to compare different branches of VTK since these revision number<br />
differences will no longer show up. The CVS revision number is still in<br />
the cxx file in the RevisionMacro. You don't need to make any changes to<br />
your code for this.<br />
<br />
The DataArray classes now use a templated intermediate class to share<br />
their implementation. Again there is no need for you to make changes to<br />
your code.<br />
<br />
Legacy code has been removed. Specifically none of the old style<br />
callbacks are supported and observers should be used instead. So where<br />
you used a filter->SetStartMethod(myFunc) you should do a<br />
filter->AddObserver(vtkCommand::StartEvent,myCommand) Usually this will<br />
require you to create a small class for the observer.<br />
vtkImageOpenClose3D.cxx has an example of using an observer and there<br />
are a few other examples in VTK. If you switch to using Observers your<br />
code should also work with versions of VTK from 3.2 or later since the<br />
Observers have been in VTK since VTK 3.2.<br />
<br />
Many functions that previously took or returned float now take or return<br />
double. To change your code to work with VTK 4.4 or later you can just<br />
replace float with double for the appropriate calls and variables. If<br />
you want your code to work with both old and new versions of VTK you can<br />
use vtkFloatingPointType which is defined to be double in VTK 4.4 and<br />
later and it is float in vtk 4.2.5. In versions of VTK prior to 4.2.5<br />
you can use something like:<br />
<br />
#ifndef vtkFloatingPointType<br />
#define vtkFloatingPointType vtkFloatingPointType<br />
typedef float vtkFloatingPointType;<br />
#endif<br />
<br />
at the beginning of your code. That will set it to the correct value for<br />
all versions of VTK old and new.<br />
<br />
=== Use of New() and Delete() now enforced (vs. new & delete) ===<br />
<br />
Constructors and destructors in VTK are now protected. This means you<br />
can no longer use little "new" or "delete" to create VTK instances.<br />
You'll have to use the methods ::New() and ::Delete() (as has been<br />
standard practice for some time).<br />
<br />
The reason for this is to enforce the use of New() and Delete(). Not<br />
using New() and Delete() can lead to bad mojo, mainly reference counting<br />
problems or not taking advantage of special procedures incorporated into<br />
the New() method (e.g., selecting the appropriate hardware interface<br />
during instance creation time).<br />
<br />
If you've used New() and Delete() in your code, these changes will not<br />
affect you at all. If you're using little "new" or "delete", your code<br />
will no longer and compile and you'll have to switch to New() and Delete().<br />
<br />
=== Changes between VTK 4.4 and VTK 4.6 ===<br />
<br />
Collection Changes<br />
<br />
Collections have had some small changes (originally started by Chris<br />
Volpe) to better support reentrant iteration. Specifically all the<br />
collection have an InitTraversal(sit) and GetNextFoobar(sit) methods.<br />
(where Foobar is what the collection contains, for example<br />
GetNextActor(sit)) The argument to both of these methods is a<br />
vtkCollectionSimpleIterator. Most of the collection use in VTK has been<br />
modified to use these new methods. The advantage is that these new<br />
methods support having the same collection be iterated through in a<br />
reentrant safe manner. In the past this was not true and led to a number<br />
of problems. In the future for C++ class development please use this<br />
approach to iterating through a collection. These changes are fully<br />
backwards compatible and no old APIs were harmed in the making of these<br />
changes. So in summary, for the future, where you would have written:<br />
<br />
for (actors->InitTraversal();<br />
(actor = actors->GetNextActor());)<br />
<br />
you would now have:<br />
<br />
vtkCollectionSimpleIterator actorIt;<br />
for (actors->InitTraversal(actorIt);<br />
(actor = actors->GetNextActor(actorIt));)<br />
<br />
=== Changes in VTK between 3.2 and 4.0 ===<br />
<br />
* Changes to vtkDataSetAttributes, vtkFieldData and vtkDataArray: All attributes (scalars, vectors...) are now stored in the field data as vtkDataArray's. vtkDataSetAttributes became a sub-class of vtkFieldData. For backwards compatibility, the interface which allows setting/getting the attributes the old way (by passing in a sub-class of vtkAttributeData such as vtkScalars) is still supported but it will be removed in the future. Therefore, the developers should use the new interface which requires passing in a vtkDataArray to set an attribute. vtkAttributeData and it's sub-classes (vtkScalars, vtkVectors...) will be deprectated in the near future; developers should use vtkDataArray and it's sub-classes instead. We are in the process of removing the use of these classes from vtk filters.<br />
<br />
* Subclasses of vtkAttributeData (vtkScalars, vtkVectors, vtkNormals, vtkTCoords, vtkTensors) were removed. As of VTK 4.0, vtkDataArray and it's sub-classes should be used to represent attributes and fields. Detailed description of the changes and utilities for upgrading from 3.2 to 4.0 can be found in the package: http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
* Added special methods to data arrays to replace methods like<br />
<br />
tc SetTCoord i x y 0<br />
<br />
or<br />
<br />
vc SetVector i vx vy vz<br />
<br />
in interpreted languages (Tcl, Python, Java). Use:<br />
<br />
tc SetTuple2 i x y<br />
<br />
or<br />
<br />
vc SetTuple3 i vx vy vz<br />
<br />
* Improved support for parallel visualization: vtkMultiProcessController and it's sub-classes have been re-structured and mostly re-written. The functionality of vtkMultiProcessController have been re-distributed between vtkMultiProcessController and vtkCommunicator. vtkCommunicator is responsible of sending/receiving messages whereas vtkMultiProcessController (and it's subclasses) is responsible of program flow/control (for example processing rmi's). New classes have been added to the Parallel directory. These include vtkCommunicator, vtkMPIGroup, vtkMPICommunicator, vtkSharedMemoryCommunicator, vtkMPIEventLog... There is now a tcl interpreter which supports parallel scripts. It is called pvtk and can be build on Windows and Unix. Examples for both Tcl and C++ can be found in the examples directories.<br />
<br />
* vtkSocketCommunicator and vtkSocketController have been added. These support message passing via BSD sockets. Best used together with input-output ports.<br />
<br />
* Since it was causing very long compile times (it essentially includes every vtk header file) and it was hard to maintain (you had to add a line whenever you added a class to VTK) vtk.h was removed. You will have to identify the header files needed by your application and include them one by one.<br />
<br />
* vtkIterativeClosestPointTransform has been added. This class is an implementation of the ICP algorithm. It matches two surfaces using the iterative closest point (ICP) algorithm. The core of the algorithm is to match each vertex in one surface with the closest surface point on the other, then apply the transformation that modify one surface to best match the other (in a least square sense).<br />
<br />
* The SetFileName, SaveImageAsPPM and related methods in vtkRenderWindow have been removed. vtkWindowToImageFilter combined with any of the image writers provides greater functionality.<br />
<br />
* Support for reading and writing PGM and JPEG images has been included.<br />
<br />
* Methods with parameters of the form "type param[n]" are wrapped. Previously, these methods were only wrapped if the array was declared 'const'. The python wrappers will allow values to be returned in the array.<br />
<br />
* The directory structure was completely reorganized. There are now subdirectories for Common (core common classes) Filtering (superclasses for filtering operations) Imaging (filters and sources that produce images or structured points) Graphics (filters or sources that produce data types other than ImageData and StructuredPoints) IO (file IO classes that do not require Rendering support) Rendering (all actors mappers annotation and rendering classes) Hybrid (typically filters and sources that require support from Rendering or both Imagign and Graphics) Parallel (parallel visualization support classes) Patented (patented classes) Examples (documented examples) Wrapping (support for the language wrappers). In many directories you will see a Testing subdirectory. The Testing subdirectories contain tests used to validate VTKs operation. Some tests may be useful as examples but they are not well documented.<br />
<br />
* The Build process for VTK now uses CMake (found at www.cmake.org) This replaces pcmaker on windows and configure on UNIX. This resolves some longstanding problems and limitation we were having with pcmaker and configure, and unifies the build process into one place.<br />
<br />
=== Changes to VTK between 4.0 and 4.2 ===<br />
<br />
* Use of macros to support serialization, standardize the New method, and provide the Superclass typedef.<br />
<br />
* Subclassing of VTK classes in the python wrappers (virtual method hooks are not provided).<br />
<br />
* vtkImageWindow, vtkImager, vtkTkImageWindowWidget and their subclasses have been removed to reduce duplicated code and enable interation in ImageWindows. Now people should use vtkRenderer and vtkRenderWindow instead. vtkImageViewer still works as a turn key image viewing class although it now uses vtkRenderWindow and vtkRenderer internally instead of vtkImageWindow and vtkImager.<br />
<br />
* New class: vtkBandedPolyDataContourFilter. Creates solid colored bands (like you find on maps) of scalar value.<br />
<br />
* Event processing: Several new events to VTK were added (see vtkCommand.h). Also event processing can now be prioritized and aborted. This allows applications to manage who processes which events, and terminates the processing of a particular event if desired.<br />
<br />
* 3D Widgets: A new class vtkInteractorObserver was added to observe events on vtkRenderWindowInteractor. Using the new event processing infrastructure, multiple 3D widgets (subclasses of vtkInteractorObserver) can be used simultaneously to process interactions. Several new 3D widgets have been added including:<br />
** vtkLineWidget<br />
** vtkPlaneWidget<br />
** vtkImagePlaneWidget<br />
** vtkBoxWidget<br />
** vtkSphereWidget<br />
<br />
* Besides providing a representation, widgets also provide auxiliary functionality such as providing transforms, implicit functions, plane normals, sphere radius and center, etc.<br />
<br />
* New class: vtkInstantiator provides a means by which one can create an instance of a VTK class using only the name of the class as a string.<br />
<br />
* New class: vtkXMLParser provides a wrapper around the Expat XML parsing library. A new parser can be written by subclassing from vtkXMLParser and providing a few simple virtual method implementations.<br />
<br />
* TIFF reader is now implemented using libtiff, which makes it capable of reading almost all available TIFF formats. The libtiff is also available internally as vtktiff.<br />
<br />
* New method (all sub-classes of vtkObject): Added a virtual function called NewInstance to vtkTypeMacro. NewInstance creates and returns an object of the same type as the current one. It does not copy any properties. The returned pointer is of the same type as the pointer the method was invoked with. This method should replace all the MakeObject methods scattered through VTK.<br />
<br />
* vtkSetObject macro is depricated for use inside the VTK. It is still a valid construct in projects that use VTK. Instead use vtkCxxSetObjectMacro which does the same thing.<br />
<br />
* vtkPLOT3DReader have been improved. It now supports:<br />
** multigrid (each block is one output)<br />
** ascii<br />
** fortran-style byte counts<br />
** little/big endian<br />
** i-blanking (partial)<br />
<br />
* A new vtkTextProperty class has been created, and duplicated text API s have been obsoleted accordingly. Check the<br />
[[VTK_FAQ#Text_properties_in_VTK_4.2|Text properties in VTK 4.2]] FAQ entry for a full description of the change.<br />
<br />
=== How do I upgrade my existing C++ code from 3.2 to 4.x? ===<br />
<br />
This is (a corrected version of) an email that was posted to vtkusers.<br />
Please feel free to correct or add anything.<br />
<br />
{| cellspacing="3" <br />
|- valign="top"<br />
|width="55%" bgcolor="#f0f0ff" style="border:1px solid #ffc9c9;padding:1em;padding-top:0.5em;"|<br />
<br />
I've just ported my medium-sized (40K lines) application from vtk3.2 to<br />
vtk4.x. I thought I would share my experiences with you, in case there<br />
were people out there contemplating it but a bit scared.<br />
<br />
One source of information for upgrading code is:<br />
<br />
http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
I'm using VC++6 + MFC on Win2K and was unable/unwilling to run the<br />
script in the zip file.<br />
<br />
So,<br />
<br />
I switched all my include directories to the new VTK ones and<br />
recompiled. 337 errors, not unexpectedly. Most concerned vtkScalars and<br />
vtkTCoords which have both been removed. Where I was using single value<br />
scalars, like this:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetNumberOfScalars(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetScalar(i,2.3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *scalars = vtkFloatArray::New();<br />
scalars->SetNumberOfComponents(1);<br />
scalars->SetNumberOfTuples(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetTuple1(i,2.3);<br />
...<br />
<br />
OK so far, far fewer errors.<br />
<br />
Where I had 2D texture coordinates:<br />
<br />
vtkTCoords *tcoords = vtkTCoords::New();<br />
tcoords->SetNumberOfTCoords(N);<br />
...<br />
float p[3];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTCoord(i,p);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *tcoords = vtkFloatArray::New();<br />
tcoords->SetNumberOfComponents(2);<br />
tcoords->SetNumberOfTuples(N);<br />
...<br />
float p[2];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTuple(i,p);<br />
....<br />
<br />
All well and good, still fewer errors. Make sure you call<br />
SetNumberOfComponents *before* SetNumberOfTuples else you'll get<br />
problems (I did!).<br />
<br />
Where I was creating 0-255 image data and had been using:<br />
<br />
vtkScalars* scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
...<br />
<br />
Going well!<br />
<br />
When creating RGB images, I had been using:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfScalars(X*Y);<br />
...<br />
scalars->SetActiveComponent(0);<br />
scalars->SetScalar(i,val1);<br />
scalars->SetActiveComponent(1);<br />
scalars->SetScalar(i,val2);<br />
scalars->SetActiveComponent(2);<br />
scalars->SetScalar(i,val3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfTuples(X*Y);<br />
...<br />
scalars->SetComponent(i,0,val1);<br />
scalars->SetComponent(i,1,val2);<br />
scalars->SetComponent(i,2,val3);<br />
...<br />
<br />
My remaining errors concerned vtkWin32OffscreenRenderWindow that has<br />
been removed. Where I had been using:<br />
<br />
vtkWin32OffscreenRenderWindow *offscreen = vtkWin32OffscreenRenderWindow::New();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkWin32OpenGLRenderWindow *offscreen = vtkWin32OpenGLRenderWindow::New();<br />
offscreen->SetOffScreenRendering(1);<br />
...<br />
<br />
All done. I'd had to throw in some #include "vtkFloatArray.h" and things<br />
like that of course. Zero compile errors.<br />
<br />
Had to remember to link against the new vtk lib files, so I removed<br />
<br />
vtkdll.lib <br />
<br />
and added<br />
<br />
vtkCommon.lib<br />
vtkGraphics.lib<br />
<br />
etc.<br />
<br />
Zero link errors. My program is up and running again, no apparant<br />
problems. Plus now I can use all the new features of vtk4. (And I'm sure<br />
it's faster but maybe that's my imagination.)<br />
<br />
All this took me about three hours.<br />
<br />
Bye!<br />
<br />
Tim.<br />
|}<br />
<br />
=== What is the release schedule for VTK ===<br />
<br />
VTK has a formal release every eight to sixteen months. VTK 4.0 was cut<br />
in December of 2001 and released in March 2002. VTK 4.2 was releaseed in<br />
February of 2003. VTK 4.4 (which is an interim release) was released at the end of 2003. The next version of VTK 5.0 will probably be released in early 2005.<br />
<br />
=== Roadmap: What changes are being considered for VTK ===<br />
<br />
This is a list of changes that are being considered for inclusion into<br />
VTK. Some of these changes will happen while other changes we would like<br />
to see happen but may not due to funding or time issues. For each change<br />
we try to list what the change is, when we hope to complete it, if it is<br />
actively being developed. Detailed discussion on changes is limited to<br />
the vtk-developers mailing list.<br />
<br />
# Modify existing image filters to use the new vtkImageIterator etc. Most simple filters have been modified to use ithe iterator in VTK 4.2. It would be nice to have some sort of efficient neighborhood iterators but so far we haven't come up with any.<br />
# Rework the polydata and unstructured grid structures (vtkMesh ??). Related ideas include:<br />
#* Make UnstructuredGrid more compact by removing the cell point count from the vtkCellArray. This will reduce the storage required by each cell by 4 bytes.<br />
#* Make vtkPolyData an empty subclass of vtkUnstructuredGrid. There are a number of good reasons for this but it is a tricky task and backwards compatibility needs to be maintained.<br />
# More parallel support, including parallel compositing algorithms<br />
# Algorithms like LIC (http://www-courses.cs.uiuc.edu/~cs419/lic.pdf), maybe a couple terrain-decimation algorithms<br />
# Further integration of STL and other important C++ constructs (like templates)<br />
<br />
VTK 4.4 (intermediate release, end of 2003)<br />
<br />
* convert APIs to double (done)<br />
* remove old callbacks (done)<br />
* blanking<br />
* ref count observers (done)<br />
* switch collections to use iterators (done)<br />
* improve copyright (done)<br />
<br />
VTK 5.0 (major release, early 2005)<br />
<br />
* new pipeline mechanism (see [[Media:Pipeline.pdf|Pipeline.pdf]])<br />
* time support<br />
* true AMR support<br />
<br />
=== Changes to Interactors ===<br />
<br />
The Interactors have been updated to use the Command/Observer events of<br />
vtk. The vtkRenderWindowInteractor now has ivars for all the event<br />
information. There is a new class called<br />
vtkGenericRenderWindowInteractor that can be used to set up the bindings<br />
from other languages like python, Java or TCl.<br />
<br />
A new class vtkInteractorObserver was also added. It has a<br />
SetInteractor() method. It observes the keypress and delete events<br />
invoked by the render window interactor. The keypress activation value<br />
for a widget is now 'i' (although this can be programmed).<br />
vtkInteractorObserver has the state ivar Enabled. All subclasses must<br />
have the SetEnabled(int) method. Convenience methods like On(), Off(),<br />
EnabledOn(), and EnabledOff() are available. The state of the interactor<br />
observer is obtained using GetEnabled(). The SetEnabled(1) method adds<br />
observers to watch the interactor (appropriate to the particular<br />
interactor observer) ; SetEnabled(0) removes the observers . There are<br />
two new events: EnableEvent and DisableEvent which are invoked by the<br />
SetEnabled() method.<br />
<br />
The events also support the idea of priority now. When you add an<br />
observer, you can specify a priority from 0 to 1. Higher values will be<br />
called back first. An observer can also tell the object not to call any<br />
more observers. This way you can handle an event, and stop further<br />
processing. In this way you can add handlers to InteractorStyles without<br />
sub-classing and from wrapped languages.<br />
<br />
For more information see: vtkGenericRenderWindowInteractor,<br />
vtkRenderWindowInteractor, vtkInteractorObserver.<br />
<br />
=== Header files and vtkSetObjectMacro ===<br />
<br />
On some platforms such as MS Visual Studio .NET, compiler is not capable<br />
of handling too big input files. Some VTK files with all includes do<br />
become big enough to overwhelm the compiler. The solution is to minimize<br />
the amount of includes. This especially goes for header files, because<br />
they propagate to other files. Every class header file should include<br />
only the parent class header file. If there is no other alternative, you<br />
should put a comment next to include file explaining why the file has to<br />
be included.<br />
<br />
The related issue is with vtkSetObjectMacro. This file calles some<br />
methods on an argument class, which implies that the argument class<br />
header file has to be included. The result is bloat on the header files.<br />
The solution is to not use vtkSetObjectMacro but vtkCxxSetObjectMacro.<br />
The difference is that vtkCxxSetObjectMacro goes in the Cxx file and not<br />
in the header file.<br />
<br />
Example: Instead of<br />
<br />
#include "vtkBar.h"<br />
class vtkFoo : public vtkObject<br />
{ ...<br />
vtkSetObjectMacro(Bar, vtkBar);<br />
...<br />
};<br />
<br />
Do:<br />
<br />
class vtkBar;<br />
class vtkFoo : public vtkObject<br />
{<br />
...<br />
virtual void SetBar(vtkBar*);<br />
...<br />
};<br />
<br />
and add the following line to vtkFoo.cxx<br />
<br />
vtkCxxSetObjectMacro(vtkFoo,Bar,vtkBar);<br />
<br />
=== Text properties in VTK 4.2 ===<br />
<br />
A new<br />
[http://public.kitware.com/VTK/doc/nightly/html/classvtkTextProperty.html vtkTextProperty]<br />
class has been added to VTK 4.2.<br />
<br />
This class factorizes text attributes that used to be spread out and<br />
duplicated in many different classes (mostly 2D actors and text<br />
mappers). Among those attributes, font family, font size,<br />
bold/italic/shadow properties, horizontal and vertical justification,<br />
line spacing and offset have been retained, whereas new attributes like<br />
color and opacity have been introduced.<br />
<br />
We tried to make sure that you can use a vtkTextProperty to modify text<br />
properties in the same way a vtkProperty can be used to modify the<br />
surface properties of a geometric object. In that regard, you should be<br />
able to share a vtkTextProperty between different actors or assign the<br />
same vtkTextProperty to an actor that offers multiple vtkTextProperty<br />
attributes ([http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlot]<br />
for example).<br />
<br />
Here is a quick example:<br />
<br />
vtkTextActor *actor0 = vtkTextActor::New();<br />
actor0->GetTextProperty()->SetItalic(1);<br />
//<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
//<br />
vtkTextActor *actor1 = vtkTextActor::New();<br />
actor1->SetTextProperty(tprop);<br />
//<br />
vtkTextActor *actor2 = vtkTextActor::New();<br />
actor2->SetTextProperty(tprop);<br />
<br />
*Backward compatibility issues*:<br />
<br />
1) Color and Opacity:<br />
<br />
The text color and text opacity settings are now controlled by the<br />
vtkTextProperty Color and Opacity attributes instead of the<br />
corresponding actor's color and opacity attributes. In the following<br />
example, those settings were controlled by the attributes of the<br />
vtkProperty2D attached to the vtkActor2D (vtkTextActor). The<br />
vtkTextProperty attributes should be used instead:<br />
<br />
vtkTextActor *actor = vtkActor::New();<br />
actor->GetProperty()->SetColor(...);<br />
actor->GetProperty()->SetOpacity(...);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetColor(...);<br />
actor->GetTextProperty()->SetOpacity(...);<br />
<br />
To make migration easier for a while, we have set the vtkTextProperty<br />
default color to ''(-1.0, -1.0, -1.0)'' and the default opacity to ''-1.0''.<br />
These "magic" values are checked by the underlying text mappers at<br />
rendering time. If they are found, the color and opacity of the 2D<br />
actor's vtkProperty2D are used, just as it was in VTK 4.1.<br />
<br />
2) API (i.e. SetBold(), SetItalic(), etc)<br />
<br />
Most of the VTK classes involving text used to provide their own text<br />
attributes like Bold, Italic, Shadow, FontFamily. Thus, each of those<br />
classes would duplicate the vtkTextMapper API through methods like<br />
SetItalic(), SetBold(), SetFontFamily(), etc.<br />
<br />
Moreover, if one class had different text elements (say, for example,<br />
the title and the labels of a scalar bar), there was no way to modify<br />
the text properties of these elements separately.<br />
<br />
The vtkTextProperty class has been created to address both issues, by<br />
obsoleting those duplicated attributes and methods and providing a<br />
unified way to access text properties, and by allowing each class to<br />
associate different vtkTextProperty to different text elements.<br />
<br />
Migrating your code basically involves using the old API on your actor's<br />
vtkTextProperty instead of the actor itself. For example:<br />
<br />
actor->SetBold(1);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetBold(1);<br />
<br />
When a class provides different vtkTextProperty for different text<br />
elements, the TextProperty attribute is usually prefixed with that<br />
element type. Example: AxisTitleTextProperty, or AxisLabelTextProperty.<br />
This allows you to set different aspect for each text elements. If you<br />
want to use the same properties, you can either set the same values on<br />
each vtkTextProperty, or make both vtkTextProperty point to the same<br />
vtkTextProperty object. Example:<br />
<br />
actor->GetAxisLabelTextProperty()->SetBold(1);<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
or:<br />
<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
actor->SetAxisLabelTextProperty(tprop);<br />
actor->SetAxisTitleTextProperty(tprop);<br />
<br />
or:<br />
<br />
actor->SetAxisLabelTextProperty(actor->GetAxisTitleTextProperty());<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
The following list specifies the name of the text properties used in the<br />
VTK classes involving text.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html vtkTextMapper]:<br />
* you can still use the vtkTextMapper + vtkActor2D combination, but we would advise you to use a single vtkTextActor instead, this will give you maximum flexibility.<br />
* has 1 text prop: TextProperty, but although you have access to it, do not twwak it unless you are using vtkTextMapper with a vtkActor2D. In all other cases, use the text prop provided by the actor (see below).<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextActor.html vtkTextActor]:<br />
* has 1 text prop: TextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLabeledDataMapper.html vtkLabeledDataMapper]:<br />
* has 1 text prop: LabelTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCaptionActor2D.html vtkCaptionActor2D]:<br />
* has 1 text prop: CaptionTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLegendBoxActor.html vtkLegendBoxActor]:<br />
* has 1 text prop: EntryTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkAxisActor2D.html vtkAxisActor2D],<br />
[http://www.vtk.org/doc/nightly/html/classvtkParallelCoordinatesActor.html vtkParallelCoordinatesActor], and<br />
[http://www.vtk.org/doc/nightly/html/classvtkScalarBarActor.html vtkScalarBarActor]:<br />
* have 2 text props: TitleTextProperty, LabelTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlotActor]:<br />
* has 3 text prop: TitleTextProperty (plot title), AxisTitleTextProperty, AxisLabelTextProperty (title and labels of all axes)<br />
* the legend box text prop (i.e. entry text prop) can be retrieved through actor->GetLegendBoxActor()->GetEntryTextProperty()<br />
* the X (or Y) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/YAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCubeAxesActor2D.html vtkCubeAxesActor2D]:<br />
* has 2 text props: AxisTitleTextProperty, AxisLabelTextProperty (title and label of all axes)<br />
* the X (Y or Z) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/Y/ZAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched.<br />
<br />
=== Forward declaration in VTK 4.x ===<br />
<br />
Since VTK 4.x all classes have been carefully inspected to only include the necessesary headers, and do what is called 'forward declaration' for all other needed classes. Thus, when you compile your projects using a filter that takes as input a dataset and you are passing an imagedata: you need to explicitely include imagedata within your implementation file. This is true for all data types.<br />
<br />
For example, if you get this error:<br />
<br />
no matching function for call to `vtkContourFilter::SetInput(vtkImageData*)'<br />
VTK/Filtering/vtkDataSetToPolyDataFilter.h:44:<br />
candidates are: virtual void vtkDataSetToPolyDataFilter::SetInput(vtkDataSet*)<br />
<br />
This means you need to add in your code : #include "vtkImageData.h"<br />
<br />
== Miscellaneous questions ==<br />
<br />
=== What are the legal issues? ===<br />
<br />
The Visualization Toolkit software is provided under the following<br />
copyright. We think it's pretty reasonable. We do restrict the<br />
distribution of modified code. This is primarily a revision control<br />
issue. We don't want a bunch of renegade vtks running around without us<br />
having some idea why the changes were made and giving us a chance to<br />
incorporate them into the general release.<br />
<br />
Copyright &copy; 1993-2004 Ken Martin, Will Schroeder, Bill Lorensen All<br />
rights reserved.<br />
<br />
Redistribution and use in source and binary forms, with or without<br />
modification, are permitted provided that the following conditions are met:<br />
<br />
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.<br />
<br />
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.<br />
<br />
* Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.<br />
<br />
* Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software.<br />
<br />
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS<br />
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br />
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br />
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR<br />
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br />
<br />
=== Can't you split up the data file? ===<br />
<br />
The data is now in one file that is about 15 Megabytes. This is smaller<br />
than the original data files VTK used and we hope that this size is not<br />
a problem for people anymore. If it is please let us know.<br />
<br />
=== Do you have any shared library tips? ===<br />
<br />
VTK version 4.0 and later supports both shared and static libraries on<br />
most all platforms. For development we typically use shared libraries<br />
since they are faster to link when making small changes. You can control<br />
how VTK builds by setting the BUILD_SHARED_LIBS option in CMake.<br />
<br />
=== What is the deal with the patents ===<br />
<br />
As the copyright mentions there are some patents used in VTK. If you use<br />
any code in the Patented/ directory for commercial application you<br />
should contact the patent holder and obtain a license.<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by General Electric Company: vtkDecimate, vtkMarchingCubes,<br />
vtkMarchingSquares, vtkDividingCubes, vtkSliceCubes and vtkSweptSurface.<br />
The GE contact is:<br />
<br />
Carl B. Horton<br />
Sr. Counsel, Intellectual Property<br />
3000 N. Grandview Blvd., W-710<br />
Waukesha, WI 53188<br />
Phone: (262) 513-4022<br />
E-Mail: mailto:Carl.Horton@med.ge.com<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by Kitware, Inc.: vtkGridSynchronizedTemplates3D,<br />
vtkKitwareContourFilter.h, vtkSynchronizedTemplates2D, and<br />
vtkSynchronizedTemplates3D. The Kitware contact is:<br />
<br />
Ken Martin<br />
Kitware<br />
28 Corporate Drive, Suite 204,<br />
Clifton Park, NY 12065<br />
Phone:1-518-371-3971<br />
E-Mail: mailto:kitware@kitware.com</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=Main_Page&diff=361Main Page2004-12-04T00:34:59Z<p>Goodwin: rv - getting rid of the link spam</p>
<hr />
<div>{|<br />
| [[CMake|http://www.cmake.org/Testing/Icons/Logo.gif]]<br />
| [[CMake]] is the cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.<br />
|-<br />
|<br />
|<br />
|-<br />
| [[VTK|http://public.kitware.com/images/logos/vtk-logo.jpg]]<br />
| [[VTK|The Visualization ToolKit (VTK)]] is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by [http://www.kitware.com Kitware, Inc.] VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data. <br />
|-<br />
|<br />
|<br />
|-<br />
| [[ITK|http://www.itk.org/Testing/Icons/Logo.gif]]<br />
| [[ITK|National Library of Medicine Insight Segmentation and Registration Toolkit (ITK)]] is an open-source software system to support the Visible Human Project. Currently under active development, ITK employs leading-edge segmentation and registration algorithms in two, three, and more dimensions.<br />
|}</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Tcl_Stubs&diff=2759VTK Tcl Stubs2004-11-22T17:33:17Z<p>Goodwin: </p>
<hr />
<div>To create stubs enabled vtk tcl libraries:<br />
<ul><br />
<li>patch the vtk source with [http://www.vtk.org/Bug/bug.php?op=show&bugid=1376 these].</li><br />
<li>run cmake</li><br />
<li>set the advanced flag TCL_TK_STUBS</li><br />
<li>link against tclstub84.lib and tkstub84.lib</li><br />
<li>download a tclkit for your platform from [http://www.equi4.com here]</li></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Tools&diff=293VTK Tools2004-10-29T15:26:36Z<p>Goodwin: VTK for .NET platform</p>
<hr />
<div><small>This page was based on Sebastien Barre's [http://www.barre.nom.fr/vtk/links-tools.html VTK Links: Tools] page</small>.<br />
<br />
These are not directly integrated to VTK, but might be useful in specific context. If you are using such additional tools in your daily work, then other users might need them too.<br />
<br />
[http://www.barre.nom.fr/medical/dicom2/index.html dicom2]<br />
<br />
''(S. Barré, UTC)''<br />
"dicom2 is a free command-line driven program which allows you to convert medical images and DICOM files to various other formats, while optionally performing some rudimentary image processing tasks... It is not a script, but I've written a section to describe how to convert sets of medical images to a raw format that might be read by VTK."<br />
<br />
[http://www.weihenstephan.de/~syring/vtk/vtk.html A partial COM wrapper for VTK]<br />
<br />
''(K. M. Syring)''<br />
"This is a partial implementation of a COM (Ole) wrapper for the C++ classes of the VTK visualization library . It is intended primarily for use with Visual Basic 5/VBA. Some stuff is still missing and some functions are not working as expected."<br />
<br />
[http://www.quick3d.org/ Quick3d ]<br />
<br />
''(B. Sherman)''<br />
"quick3D is a program intended to be used as a quick viewer of 3D geometry in Windows 95/98/NT. It supports many of the common 3D file formats to provide one quick and easy viewing solution.". Well, I saw it would support the VTK format, but was unable to test it.<br />
<br />
[http://mayavi.sourceforge.net/ MayaVi]<br />
<br />
"MayaVi is a free, easy to use scientific data visualizer. It is written in Python and uses the amazing Visualization Toolkit (VTK) for the graphics. It provides a GUI written using Tkinter. MayaVi is free and distributed under the conditions of the BSD license. It is also cross platform and should run on any platform where both Python and VTK are available (which is almost any *nix, Mac OSX or Windows)."<br />
<br />
[http://www.skippingmouse.co.uk/ RPD (Rapid Pipeline Design)]<br />
<br />
"RPD is a GUI front end for the Visualization Toolkit (VTK). RPD allows the creation of complex visualization pipelines by dragging and dropping connections between VTK classes. Currently around 400 VTK classes are available in the RPD GUI. RPD features a sophisticated RenderWindow control which provides many functions such as easy switching between 3D and 2D views; customized 2D image display; stereo render; and AVI animation capture."<br />
<br />
[http://www.data-visualization-software.com/ Data Visualization Architect]<br />
<br />
"Data Visualization Architect provides a graphical pipeline editor for the widely used and popular Visualization Toolkit (VTK) by encapsulating the VTK C++ classes and providing graphical equivalents. Connections are made by simply clicking on the source graphical component and dragging the connector to the target graphical component."<br />
<br />
[http://www.llnl.gov/visit/ VisIt]<br />
<br />
"VisIt is a free interactive parallel visualization and graphical analysis tool for viewing scientific data on Unix and PC platforms. Users can quickly generate visualizations from their data, animate them through time, manipulate them, and save the resulting images for presentations. VisIt contains a rich set of visualization features so that you can view your data in a variety of ways. It can be used to visualize scalar and vector fields defined on two- and three-dimensional (2D and 3D) structured and unstructured meshes. VisIt was designed to handle very large data set sizes in the terascale range and yet can also handle small data sets in the kilobyte range."<br />
<br />
[http://casa.colorado.edu/~gnedin/IFRIT/ IFRIT Ionization FRont Interactive Tool]<br />
<br />
"IFRIT Ionization FRont Interactive Tool A general purpose visualization tool<br />
<br />
IFRIT is a powerful tool that can be used to visualize 3-dimensional data sets. IFRIT is written in C++ and is based on two state-of-the-art toolkits: the Visualization ToolKit (VTK) and a GUI toolkit QT. VTK is a public domain software, and QT has an open source version for Unix machines. There is also an earlier incarnation of IFRIT written in IDL language (IFRIT 1.2).<br />
<br />
IFRIT has its origins (and hence name) in a specialized utility designed to visualize ionization fronts in cosmological numerical simulations. But IFRIT has outgrown its origins and now can visualize general data sets as well."<br />
<br />
[http://visu.sourceforge.net/home.en.html visu]<br />
<br />
"The Visu program is a lightweight GTK+ interactive visualization tool for 2D or 3D simulation data, rendering through the VTK library. Features include: reading data in a variety of formats, display the data as scalars, vectors, height fields, and lev"<br />
<br />
[http://mbi.dkfz-heidelberg.de/mitk/index.html Medical Imaging Interaction Toolkit (mitk)]<br />
<br />
"Medical Imaging Interaction Toolkit (MITK). Currently under active development, MITK aims at supporting the development of leading-edge medical imaging software with a high degree of interaction. It combines vtk, itk and the pic-based-libraries of the Div. Medical and Biological Informatics of the DKFZ and adds those features that are most important for developing Interactive medical imaging software covered neither by vtk nor itk"<br />
<br />
[http://dunne.uni-hd.de/VisuSimple/ VisuSimple]<br />
<br />
VisuSimple is an interactive visualization and graphics/mpeg-generation program for 2D- and 3D-data in the VTK-format - an easy to implement visual data format.<br />
<br />
[http://herakles.zcu.cz/research/vtk.net/ VTK for .NET platform]<br />
<br />
The aim of this work is straightforward use of visualisation toolkit on .NET platform. This is done by means of .NET wrappers. Each VTK class has its own wrapper. The wrapper contains wrapped Win32 class and provides access to its methods. Data conversion and memory management is also job for wrapper. All wrappers are linked into one dynamic linked library (vtkDotNetWrap.dll).</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=3506User:Goodwin2004-10-27T15:33:24Z<p>Goodwin: </p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com/vtk here]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=279User:Goodwin2004-10-26T21:16:03Z<p>Goodwin: </p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre<br /><br />
205a, Engineering<br /><br />
University College Dublin<br /><br />
Belfield, Dublin 4<br /><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com here]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/FAQ&diff=303VTK/FAQ2004-10-26T21:04:14Z<p>Goodwin: </p>
<hr />
<div>== General information and availability ==<br />
<br />
=== What is the Visualization Toolkit? ===<br />
<br />
The '''Visualization ToolKit (vtk)''' is a software system for 3D Computer<br />
Graphics and Visualization.<br />
<br />
VTK includes a textbook published by Kitware Inc. ([http://www.kitware.com/products/vtktextbook.html The Visualization<br />
Toolkit, An Object-Oriented Approach to 3D Graphics]),<br />
a C++ class library, and Tcl, Python and Java implementations based on<br />
the class library.<br />
<br />
For more information, see http://www.vtk.org and http://www.kitware.com.<br />
<br />
=== What is the current release? ===<br />
<br />
The current release of vtk is 4.2. This release is available at:<br />
<br />
http://www.vtk.org/files/release/4.2/<br />
<br />
Nightly development releases are available at:<br />
<br />
http://www.vtk.org/files/nightly/<br />
<br />
See http://www.vtk.org/get-software.php for more information.<br />
<br />
=== Can I contribute code or bug fixes? ===<br />
<br />
We encourage people to contribute bug fixes as well as new contributions<br />
to the code. We will try to incorporate these into future releases so<br />
that the entire user community will benefit from them.<br />
<br />
See http://www.vtk.org/contribute.php for information on contributing to<br />
VTK.<br />
<br />
For some ideas take a look at some of the entries in the "Changes to the<br />
VTK API" FAQ section, for example: <br />
[[VTK_FAQ#Roadmap:_What_changes_are_being_considered_for_VTK|What changes are being considered for VTK]]<br />
<br />
=== Can I contribute money? ===<br />
<br />
Please don't send money. Not that we think you're going to send in<br />
unsolicited money. But if you were thinking about it, stop. It would<br />
just complicate our lives and make for all sorts of tax problems.<br />
<br />
=== Is there a mailing list or Usenet newsgroup for VTK? ===<br />
<br />
There is a mailing list: vtkusers@vtk.org<br />
<br />
To subscribe or unsubscribe to the mailing list, go to:<br />
http://www.vtk.org/mailman/listinfo/vtkusers<br />
<br />
To search the list archives go to: http://www.kitware.com/search.html<br />
<br />
There is also a newsgroup that mirrors the mailinglist. At this point it<br />
seems that mirror is down. Mail to the mailinglist used to be posted the<br />
newsgroup, but posts on the newsgroup were not sent to the mailinglist.<br />
The newsgroup was located at:<br />
news://scully.esat.kuleuven.ac.be/vtk.mailinglist<br />
<br />
http://www.gmane.org is a bidirectional mail-to-news gateway that carries the vtkusers mailing list. Its located here: news://news.gmane.org/gmane.comp.lib.vtk.user or here: http://news.gmane.org/gmane.comp.lib.vtk.user. vtkusers mails have been archived since April 2002 and they never expire. You can read and send mails to the vtkusers list without having subscribed to the list.<br />
<br />
=== Is the VTK mailing list archived anywhere? ===<br />
<br />
The mailing list is archived at:<br />
http://www.vtk.org/pipermail/vtkusers/<br />
<br />
You can search the archive at: http://www.kitware.com/search.html<br />
<br />
=== Are answers for the exercises in the VTK book available? ===<br />
<br />
Not anymore.<br />
<br />
The answers to the exercises of the textbook used to be maintained by<br />
Martin Stoufer (kudos), and will be made available by Kitware in the<br />
next future.<br />
<br />
=== Is VTK regression tested on a regular basis? Can I help? ===<br />
<br />
Yes, it is.<br />
<br />
You can view the current regression test results at:<br />
http://public.kitware.com/dashboard.php?name=vtk<br />
<br />
VTK uses Dart to perform builds, run tests, and generate dashboards. You<br />
can find more information about Dart at: http://public.kitware.com/Dart/<br />
<br />
You can help improve the quality of VTK by supplying the authors with<br />
Tcl scripts that can be used as or turned into regression tests. A good<br />
regression test will:<br />
<br />
# Cover code that is not already covered.<br />
# Illustrate a bug that is occuring now or that has occurred in the past.<br />
# Use data that is on the 2nd Edition book CDROM or use "small" data files or use no data at all.<br />
# Optionally, produce an interesting result. <br />
<br />
Currently almost all regression tests are written in Tcl.<br />
<br />
Please send your Tcl regression tests to:<br />
mailto:wlorens1@mail.nycap.rr.com<br />
<br />
Bill will evaluate them for applicability and integrate them into the<br />
nightly test process.<br />
<br />
=== What's the best way to learn VTK? ===<br />
<br />
There are five things you might want to try:<br />
<br />
# Purchase the book [http://www.kitware.com/products/vtktextbook.html The Visualization Toolkit] from Kitware Inc.<br />
# Purchase the book [http://www.kitware.com/products/vtkguide.html VTK Users Guide] from Kitware Inc. <br />
# [http://www.vtk.org/get-software.php Download the source code and/or binaries] (available on Windows) and work through the examples (there are 400-500 examples). <br />
# To learn the innards of VTK, you can attend a [http://www.kitware.com/products/proftrain.html#VTKCourse VTK course] or [http://www.kitware.com/products/proftrain.html sponsor a VTK course at your site] through Kitware. http://www.kitware.com/products/index.html<br />
# Buy Bill a beer and get him talking about VTK<br />
<br />
=== How should I ask questions on the mailing lists? ===<br />
<br />
The best online resource for this question is Eric S. Raymond's<br />
excellent guide on the topic titled "How to ask questions the smart<br />
way". Read it here:<br />
<br />
http://www.catb.org/~esr/faqs/smart-questions.html<br />
<br />
Please do read it and follow his advice. Thanks!<br />
<br />
Please also remember the following when you post your messages to the<br />
VTK mailing lists.<br />
<br />
* Mention the version of VTK you are using and the version of the compiler or scripting language you are using.<br />
<br />
* Mention your platform, OS and their versions.<br />
<br />
* Include hardware details if relevant.<br />
<br />
* Include all relevant error messages (appropriately trimmed of course).<br />
<br />
* The lists have a very large number of subscribers (in the thousands), so please keep messages to the point.<br />
<br />
* Avoid HTML emails.<br />
<br />
* Use a sensible and descriptive subject line.<br />
<br />
* Do NOT post large data files or images to the list. Instead put them in your web page and mention the URLs.<br />
<br />
* Quote the messages you reply to appropriately. Remove unnecessary details.<br />
<br />
When asking a question or reporting a problem try to include a small<br />
example program that demonstrates the problem. Make sure that this<br />
example program is as small as you can make it, simple (and uses VTK<br />
alone), complete and demonstrates the problem adequately. Doing this<br />
will go a *long way* towards getting a quick and meaningful response.<br />
<br />
Sometimes you might not get any acceptable response. This happens<br />
bacause the others think the question has either been already answered<br />
elsewhere (the archives, FAQ and google are your friends), or believe<br />
that you have not done enough homework to warrant their attention, or<br />
they don't know the answer or simply don't have the time to answer.<br />
Please do be patient and understanding. Most questions are answered by<br />
people volunteering their time to help you.<br />
<br />
Happy posting!<br />
<br />
=== How NOT to go about a programming assignment ===<br />
<br />
This is really a link you should read before posting to the mailing list. <br />
[This article is an attempt to show these irrational attitudes in an ironical way, <br />
intending to make our students aware of bad habits without admonishing them.]<br />
<br />
http://www.di.uniovi.es/~cernuda/noprog_ENG.html<br />
<br />
== Language bindings ==<br />
<br />
=== Are there bindings to languages other than Tcl? ===<br />
<br />
Aside from C++ (which it's written in) and Tcl, vtk is also bound into<br />
Java as of JDK 1.1 and Python 1.5, 1.6 and 2.X. All of the<br />
Tcl/Java/Python wrapper code is generated from some LEX and YACC code<br />
that parses our classes and extracts the required information to<br />
generate the wrapper code.<br />
<br />
=== What version of Tcl/Tk should I use with VTK? ===<br />
<br />
Currently we recommend that you use Tcl/Tk 8.2.3 with VTK. This is the<br />
best-supported version combination at this time.<br />
<br />
VTK has also been tested with Tcl/Tk 8.3.2 and works well.<br />
<br />
Tcl/Tk 8.3.4 has been tested to a limited extent but seems to have more<br />
memory leaks that Tcl 8.3.2 has.<br />
<br />
Tcl/Tk 8.4.x seems to work well with VTK too, but you might have to<br />
change a couple of configuration settings depending on the version of<br />
VTK you are using. Check the [[VTK_FAQ#Does_VTK_support_Tcl.2FTk_8.4_.3F|Does VTK support Tcl/Tk 8.4?]].<br />
<br />
=== Where can I find Python 2.x binaries? ===<br />
<br />
All of the Python binaries available on the kitware site are built for<br />
Python 1.5.2. This includes the official release VTK3.2 and the nightly<br />
builds (as at 2001-07-16).<br />
<br />
For Python 2.x binaries, you will have to compile your own from source.<br />
It is worth checking the mailing list archives for comments by others<br />
who have been through this process.<br />
<br />
There are some user-contributed binaries available at other sites. Check<br />
the mailing list archives for possible leads. Some win32 binaries for<br />
Python 2.1 are available at;<br />
<br />
http://basic.netmeg.net/godzilla/<br />
<br />
YMMV...<br />
<br />
=== Why do I get the Python error -- ValueError: method requires a VTK object? ===<br />
<br />
You just built VTK with Python support and everything went smoothly.<br />
After you install everything and try running a Python-VTK script you get<br />
a traceback with this error:<br />
<br />
ValueError: method requires a VTK object.<br />
<br />
This error occurs if you have two copies of the VTK libraries on your<br />
system. These copies need not be in your linkers path. The VTK libraries<br />
are usually built with an rpath flag (under *nix). This is necessary to<br />
be able to test the build in place. When you install VTK into another<br />
directory in your linkers path and then run a Python script the Python<br />
modules remember the old path and load the libraries in the build<br />
directory as well. This triggers the above error since the object you<br />
passed the method was instantiated from the other copy.<br />
<br />
So how do you fix it? The easiest solution is to simply delete the copy<br />
of the libraries inside your build directory or move the build directory<br />
to another place. For example, if you build the libraries in VTK/bin<br />
then move VTK/bin to VTK/bin1 or remove all the VTK/bin/*.so files. The<br />
error should no longer occur.<br />
<br />
Another way to fix the error is to turn the CMAKE_SKIP_RPATH boolean to<br />
ON in your CMakeCache.txt file and then rebuild VTK. You shouldn't have<br />
to rebuild all of VTK, just delete the libraries (*.so files) and then<br />
re-run cmake and make. The only trouble with this approach is that you<br />
cannot have BUILD_TESTING to ON when you do this.<br />
<br />
Alternatively, starting with recent VTK CVS versions (post Dec. 6, 2002)<br />
and with VTK versions greater than 4.1 (i.e. 4.2 and beyond) there is a<br />
special VTK-Python interpreter built as part of VTK called 'vtkpython'<br />
that should eliminate this problem. Simply use vtkpython in place of the<br />
usual python interpreter when you use VTK-Python scripts and the problem<br />
should not occur. This is because vtkpython uses the libraries inside<br />
the build directory.<br />
<br />
2002 by Prabhu Ramachandran<br />
<br />
=== Does VTK support Tcl/Tk 8.4 ? ===<br />
<br />
Short answer: yes, but it might require some adjustments, depending on<br />
the VTK and CMake versions you are using.<br />
<br />
# The VTK 4.x CVS nightly/development distribution supports Tcl/Tk 8.4 as long as you use a release version of CMake > 1.4.5. Since VTK 4.2 will require CMake 1.6, the next release version will support Tcl/Tk 8.4.<br />
# The VTK 4.0 release distribution does not support Tcl/Tk 8.4 out-of-the-box.<br />
<br />
In either cases, the following solutions will adress the problem. This<br />
basically involves setting two definition symbols that will make Tcl/Tk<br />
8.4 backward compatible with previous versions of Tcl/Tk (i.e. discard<br />
the "const correctness" and Tk_PhotoPutBlock compositing rule features) :<br />
<br />
a) Edit your C/C++ flags:<br />
<br />
Run your favorite CMake cache editor (i.e. CMakeSetup, or ccmake),<br />
display the advanced values and add the USE_NON_CONST and<br />
USE_COMPOSITELESS_PHOTO_PUT_BLOCK definition symbols to the end of any<br />
of the following CMake variables (if they exist): CMAKE_CXX_FLAGS,<br />
CMAKE_C_FLAGS.<br />
<br />
Example: On Unix your CMAKE_CXX_FLAGS will probably look like:<br />
<br />
-g -O2 -DUSE_NON_CONST -DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
On Windows (Microsoft MSDev nmake mode):<br />
<br />
/W3 /Zm1000 /GX /GR /YX /DUSE_NON_CONST /DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
b) or a more intrusive solution:<br />
<br />
Edit the top VTK/CMakeList.txt file and the following lines add '''at the<br />
top''' of this file:<br />
<br />
ADD_DEFINITIONS(<br />
-DUSE_NON_CONST<br />
-DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
)<br />
<br />
== Using VTK ==<br />
<br />
=== What object/filter should I use to do ??? ===<br />
<br />
Frequently when starting out with a large visualization system people<br />
are not sure what object to use to achieve a desired effect.<br />
<br />
The most up-to-date information can be found in the VTK User's Guide<br />
(http://www.kitware.com/products/vtkguide.html).<br />
<br />
Alternative sources for information are the appendix of the book which<br />
has nice one line descriptions of what the different objects do and the<br />
VTK man pages (http://www.vtk.org/doc/nightly/html/classes.html).<br />
<br />
Additionally, the VTK man pages feature a "Related" section that provide<br />
links from each class to all the examples or tests using that class<br />
(http://www.vtk.org/doc/nightly/html/pages.html). This information is<br />
also provided in each class man page under the "Tests" or "Examples"<br />
sub-section.<br />
<br />
Some useful books are listed at http://www.vtk.org/buy-books.php<br />
<br />
=== What 3D file formats can VTK import and export? ===<br />
<br />
The following table identifies the file formats that VTK can read and<br />
write. Importer and Exporter classes move full scene information into or<br />
out of VTK. Reader and Writer classes move just geometry.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! File Format !! Read !! Write<br />
|-<br />
| 3D Studio || vtk3DSImporter || <br />
|-<br />
| AVS "UCD" format || vtkAVSucdReader || <br />
|-<br />
| Movie BYU || vtkBYUReader || vtkBYUWriter<br />
|-<br />
| Renderman || || vtkRIBExporter<br />
|-<br />
| Open Inventor 2.0 || || vtkIVExporter/vtkIVWriter<br />
|-<br />
| CAD STL || vtkSTLReader || vtkSTLWriter<br />
|-<br />
| Fluent GAMBIT ASCII || vtkGAMBITReader || <br />
|-<br />
| Unigraphics Facet Files || vtkUGFacetReader || <br />
|-<br />
| Marching Cubes || vtkMCubesReader || vtkMCubesWriter<br />
|-<br />
| Wavefront OBJ || || vtkOBJExporter<br />
|-<br />
| VRML 2.0 || || vtkVRMLExporter<br />
|-<br />
| VTK Structured Grid &dagger; || vtkStructuredGridReader || vtkStructuredWriter<br />
|-<br />
| VTK Poly Data &dagger; || vtkPolyDataReader || vtkPolyDataWriter<br />
|-<br />
| PLOT3D || vtkPLOT3DReader || <br />
|-<br />
| CGM || || vtkCGMWriter<br />
|-<br />
| OBJ || vtkOBJReader || <br />
|-<br />
| Particle || vtkParticleReader || <br />
|-<br />
| PDB || vtkPDBReader || <br />
|-<br />
| PLY || vtkPLYReader || vtkPLYWriter<br />
|-<br />
| Gaussian || vtkGaussianCubeReader || <br />
|-<br />
| XYZ || vtkXYZMolReader || <br />
|-<br />
| Ensight &Dagger; || vtkGenericEnSightReader || <br />
|}<br />
<br />
&dagger; See the books [http://www.kitware.com/products/vtktextbook.html The<br />
Visualization Toolkit, An Object-Oriented Approach to 3D Graphics] or<br />
[http://www.kitware.com/products/vtkguide.html the User's Guide] for details<br />
about structured grid and poly data file formats.<br />
<br />
&Dagger; The class vtkGenericEnSightReader allows the user to read an EnSight<br />
data set without a priori knowledge of what type of EnSight data set it<br />
is (among vtkEnSight6BinaryReader, vtkEnSight6Reader,<br />
vtkEnSightGoldBinaryReader, vtkEnSightGoldReader,<br />
vtkEnSightMasterServerReader, vtkEnSightReader).<br />
<br />
For any other file format you may want to search for a converter to a<br />
known VTK file format, more info on:<br />
http://www.tech-edv.co.at/lunix/UTILlinks.html<br />
<br />
=== Why can't I find vtktcl (vtktcl.c)? ===<br />
<br />
In versions of VTK prior to 4.0 VTK Tcl scripts would require a:<br />
<br />
catch {load vtktcl} <br />
<br />
so that they could be executed directly from wish. In VTK 4.0 the<br />
correct mechanism is to use:<br />
<br />
package require vtk<br />
<br />
For people using versions earlier than 4.0, vtktcl is a shared library<br />
that is built only on the PC. Most examples used the "catch" notation so<br />
that they will work on UNIX and on the PC. On UNIX you must use the vtk<br />
executable/shell which should be in vtk/tcl/vtk.<br />
<br />
=== Problems with vtkDecimate and vtkDecimatePro ===<br />
<br />
''vtkDecimate'' and ''vtkDecimatePro'' have been tested fairly heavily so<br />
all known bugs have been removed. However, there are three situations<br />
where you can encounter weird behavior:<br />
<br />
# The mesh is not all triangles. Solution: use ''vtkTriangleFilter'' to triangulate polygons.<br />
# The mesh consists of independent triangles (i.e., not joined at vertices - no decimation occurs). Solution: use ''vtkCleanPolyData'' to link triangles.<br />
# Bad triangles are present: e.g., triangles with duplicate vertices such as (1,2,1) or (100,100,112), or (57,57,57), and so on. Solution: use ''vtkCleanPolyData''.<br />
<br />
=== How can I read DICOM files ? ===<br />
<br />
VTK does not support the DICOM protocol/format directly, although VTK is<br />
able to read 2D and 3D ''raw'' files, i.e. slices or volumes (see<br />
''vtkImageReader'', ''vtkVolumeReader'', and derived classes). Hence, one<br />
solution is to convert DICOM files to a suitable raw format.<br />
<br />
DICOM is a huge protocol, thus we would suggest you to look for any<br />
existing converters before coding your own DICOM reader. Some of them<br />
are listed in the The Medical Image Format FAQ (Part 8):<br />
http://www.dclunie.com/medical-image-faq/html/part8.html<br />
<br />
Sebastien BARRE wrote a free DICOM converter, named dicom2, that can be<br />
used to convert medical images to raw format. This tool is a command<br />
line program and does not provide any GUI at the moment.<br />
http://dicom2.barre.nom.fr/<br />
<br />
There is a special section dedicated to the VTK:<br />
http://dicom2.barre.nom.fr/how-to.html, then "Convert to raw (vtk)"<br />
<br />
The following page also provide links to several other DICOM converters:<br />
http://www.barre.nom.fr/medical/samples/index.html#links<br />
<br />
Finally in VTK 4.4 you have access to a simple vtkDICOMImageReader [http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html]<br />
<br />
For a more elaborate DICOM library that support compressed jpeg, go to [http://www.creatis.insa-lyon.fr/Public/Gdcm/]<br />
<br />
=== How to handle large data sets in VTK ===<br />
<br />
One of the challenges in VTK is to efficiently handle large datasets. By<br />
default VTK is tuned towards smaller datasets. For large datasets there<br />
are a couple of changes you can make that should yield a much smaller<br />
memory footprint (less swapping) and also improve rendering performance.<br />
The solution is to:<br />
<br />
# Use ReleaseDataFlag,<br />
# Turn on ImmediateModeRendering<br />
# Use triangle strips via vtkStripper<br />
# Use a different filter or mapper<br />
<br />
Each of these will be discussed below.<br />
<br />
1) Using ReleaseDataFlag<br />
<br />
By default VTK keeps a copy of all intermediate results between filters<br />
in a pipeline. For a pipeline with five filters this can result in<br />
having six copies of the data in memory at once. This can be controlled<br />
using ReleaseDataFlag and GlobalReleaseDataFlag. If ReleaseDataFlag is<br />
set to one on a data object, then once a filter has finished using that<br />
data object, it will release its memory. Likewise, if<br />
GlobalReleaseDataFlag is set on ANY data object, all data objects will<br />
release their memory once their dependent filter has finished executing.<br />
For example in Tcl and C++<br />
<br />
# Tcl<br />
vtkPolyDataReader reader<br />
[reader GetOutput] ReleaseDataFlagOn<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->GlobalReleaseDataFlagOn();<br />
<br />
While turning on the ReleaseDataFlag will reduce your memory footprint,<br />
the disadvantage is that none of the intermediate results are kept in<br />
memory. So if you interactively change a parameter of a filter (such as<br />
the isosurface value), all the filters will have to re-execute to<br />
produce the new result. When the intermediate results are stored in<br />
memory, only the downstream filters would have to re-execute.<br />
<br />
One hint for good interactive performance. If only one stage of the<br />
pipeline can have its parameters changed interactively (such as the<br />
target reduction in a decimation filter), only retain the data just<br />
prior to that step (which is the default) and turn ReleaseDataFlag on<br />
for all other steps.<br />
<br />
2) Use ImmediateModeRendering<br />
<br />
By default, VTK uses OpenGL display lists which results in another copy<br />
of the data being stored in memory. For most large datasets you will be<br />
better off saving memory by not using display lists. You can turn off<br />
display lists by turning on ImmediateModeRendering. This can be<br />
controlled on a mapper by mapper basis using ImmediateModeRendering, or<br />
globally for all mappers in a process by using<br />
GlobalImmediateModeRendering. For example:<br />
<br />
# Tcl<br />
vtkPolyDataMapper mapper<br />
mapper ImmediateModeRenderingOn<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->GlobalImmediateModeRenderingOn();<br />
<br />
The disadvantage to using ImmediateModeRendering is that if memory is<br />
not a problem, your rendering rates will typically be slower with<br />
ImmediateModeRendering turned on.<br />
<br />
3) Use triangle strips via vtkStripper.<br />
<br />
Most filters in VTK produce independent triangles or polygons which are<br />
not the most compact or efficient to render. To create triangle strips<br />
from polydata you can first use vtkTriangleFilter to convert any<br />
polygons to triangles (not required if you only have triangles to start<br />
with) then run it through a vtkStipper to convert the triangles into<br />
triangle strips. For example in C++<br />
<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->SetFileName("yourdatafile.vtk");<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkTriangleFilter *tris = vtkTriangleFilter::New();<br />
tris->SetInput(reader->GetOutput());<br />
tris->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkStripper *strip = vtkStripper::New();<br />
strip->SetInput(tris->GetOutput());<br />
strip->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
mapper->SetInput(tris->GetOutput());<br />
<br />
The only disadvantage to using triangle strips is that they require time<br />
to compute, so if your data is changing every time you render, it could<br />
actually be slower.<br />
<br />
4) Use a different filter or mapper<br />
<br />
This is a tough issue. In VTK there are typically a couple of ways to<br />
solve any problem. For example an image can be rendered as a polygon for<br />
each pixel, or it can be rendered as a single polygon with a texture map<br />
on it. For almost all cases the second approach will be much faster than<br />
the first event though VTK supports both. There isn't a single good<br />
answer for how to find the best approach. If you suspect that it is<br />
running more slowly than it should, try posting to the mailing list or<br />
looking for other ways to achieve the same result.<br />
<br />
=== VTK is slow, what is wrong? ===<br />
<br />
We have heard people say that VTK is really slow. In many of these<br />
cases, changing a few parameters can make a huge difference in performance.<br />
<br />
If you find that VTK is slower than other visualization systems running<br />
the same problem first take a look at the FAQ section dealing with large<br />
data: [[VTK_FAQ#How_to_handle_large_data_sets_in_VTK|How to handle large data sets in VTK]]. Many of its suggestions<br />
will improve VTK's performance significantly for many datasets.<br />
<br />
If you still find VTK slow, please let us know and send us an example<br />
(to mailto:kitware@kitware.com). In the past there<br />
have been some filters that simply were not written to be fast. When we<br />
come across one of these we frequently can make minor changes to the<br />
filter that will make it run much more quickly. In fact many changes in<br />
the past couple years have been this type of performance improvement.<br />
<br />
=== Is VTK thread-safe ? ===<br />
<br />
The short answer is no.<br />
<br />
Many VTK sources and filters cache information and will not perform as<br />
expected when used in multiple threads. When writing a multithreaded<br />
filter, the developer has to be very careful about how she accesses data.<br />
<br />
For example, GetXXX() methods which return a pointer should only be used<br />
to read. If the pointer returned by these methods are used to change<br />
data in multiple threads (without mutex locks), the result will most<br />
probably be wrong and unpredictable. In many cases, there are<br />
alternative methods which copy the data referred by the pointer. For<br />
example:<br />
<br />
float* vtkDataArray::GetTuple(const vtkIdType i);<br />
<br />
is thread-safe only for reading whereas:<br />
<br />
void vtkDataArray::GetTuple (const vtkIdType i, float * tuple);<br />
<br />
copies the requested tuple and is thread safe even if tuple is modified<br />
afterwards (as long as the same pointer is not passed as the argument<br />
tuple simultaneously by different threads).<br />
<br />
Unfortunately, only very few methods are clearly marked as<br />
thread-(un)safe and, in many situations, the developer has to dig into<br />
the source code to figure out whether an accessor is thread safe or not.<br />
<br />
''vtkDataSet'' and most of it's sub-classes are well documented and almost<br />
all methods are marked thread-safe or not thread-safe. This might be a<br />
good place to start. Most of the filters in imaging and some filters in<br />
graphics (like ''vtkStreamer'') are good examples of how a multi-threaded<br />
filter can be written in VTK.<br />
<br />
However, if you are not interested in developing multithreaded filters<br />
but want to process some data in parallel using the same (or similar)<br />
pipeline, your job is much easier. To do this, create a different copy<br />
of the pipeline on each thread and execute them in parallel on a<br />
different piece of the data. This is best accomplished by using<br />
''vtkThreadedController'' (instead of ''vtkMultiThreader''). See the<br />
documentation of ''vtkMultiProcessController'' and ''vtkThreadedController''<br />
and the examples in the parallel directory for details on how this can<br />
be done.<br />
<br />
Also, note that most of the OpenGL libraries are not thread-safe.<br />
Therefore, if you are rendering to multiple render windows from<br />
different threads, you are likely to get in trouble, even if you have<br />
mutex locks around the render calls.<br />
<br />
=== Can I use STL with VTK? ===<br />
<br />
As of VTK version 4.2, you can use STL. However, the following policy<br />
applies.<br />
<br />
# STL is for implementation, not interface. All STL references should be contained in a .cxx class or the private section of the .h header file.<br />
# Use the PIMPL idiom to forward reference/contain STL classes in heavily used superclasses. STL is big, fat, and slow to compile so we do not want to include STL headers in any .h files that are included by most of VTK, e.g. vtkObject.h vtkSource.h etc.<br />
# Include the VTK wrapper header files: vtkstd/map instead of map.<br />
# Use the vtkstd:: namespace to refer to STL classes and functions.<br />
<br />
Here's an example (from vtkInterpolateVelocityField):<br />
<br />
In the .h file (the PIMPL) forward declare<br />
<br />
class vtkInterpolatedVelocityFieldDataSetsType;<br />
//<br />
class VTK_COMMON_EXPORT vtkInterpolatedVelocityField : public vtkFunctionSet<br />
{<br />
private:<br />
vtkInterpolatedVelocityFieldDataSetsType* DataSets;<br />
};<br />
<br />
In the .cxx file define the class (here deriving from the STL vector<br />
container)<br />
<br />
# include <vtkstd/vector><br />
typedef vtkstd::vector< vtkSmartPointer<vtkDataSet> > DataSetsTypeBase;<br />
class vtkInterpolatedVelocityFieldDataSetsType: public DataSetsTypeBase<br />
{};<br />
<br />
In the .cxx file construct and destruct the class:<br />
<br />
vtkInterpolatedVelocityField::vtkInterpolatedVelocityField()<br />
{<br />
this->DataSets = new vtkInterpolatedVelocityFieldDataSetsType;<br />
}<br />
vtkInterpolatedVelocityField::~vtkInterpolatedVelocityField()<br />
{<br />
delete this->DataSets;<br />
}<br />
<br />
And in the .cxx file use the container as you would any STL container:<br />
<br />
for ( DataSetsTypeBase::iterator i = this->DataSets->begin();<br />
i != this->DataSets->end(); ++i)<br />
{<br />
ds = i->GetPointer();<br />
....<br />
}<br />
<br />
=== What image file formats can VTK read and write? ===<br />
<br />
The following table identifies the image file formats that VTK can read<br />
and write.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! Image File !! Read !! Write<br />
|-<br />
| Bitmap || vtkBMPReader || vtkBMPWriter<br />
|-<br />
| Digital Elevation Model (DEM) || vtkDEMReader || <br />
|-<br />
| DICOM || vtkDICOMImageReader || <br />
|-<br />
| GE Signal || vtkGESignaReader || <br />
|-<br />
| JPEG || vtkJPEGReader || vtkJPEGWriter<br />
|-<br />
| Binary UNC meta image data || vtkMetaImageReader || vtkMetaImageWriter<br />
|-<br />
| PNG || vtkPNGReader || vtkPNGWriter<br />
|-<br />
| PNM || vtkPNMReader || vtkPNMWriter<br />
|-<br />
| PostScript || vtkPostScriptWriter || <br />
|-<br />
| SLC || vtkSLCReader || <br />
|-<br />
| TIFF || vtkTIFFReader || vtkTIFFWriter<br />
|-<br />
| RAW files &dagger; || vtkImageReader, vtkVolumeReader || <br />
|}<br />
<br />
&dagger; A typical example of use is:<br />
<br />
# Image pipeline<br />
reader = vtkImageReader()<br />
reader.SetDataByteOrderToBigEndian()<br />
reader.SetDataExtent(0,511,0,511,0,511)<br />
reader.SetFilePrefix("Ser397")<br />
reader.SetFilePattern("%s/I.%03d")<br />
reader.SetDataScalarTypeToUnsignedShort()<br />
reader.SetHeaderSize(5432)<br />
<br />
=== Printing an object. ===<br />
<br />
Sometimes when debugging you need to print an object to a string, either<br />
for logging purposes, or in the case of windows applications, to a window.<br />
<br />
Here is a way to do this:<br />
<br />
std::ostringstream os;<br />
//<br />
// "SomeVTKObject" could be, for example, <br />
// declared somewhere as: vtkCamera *SomeVTKObject;<br />
//<br />
SomeVTKObject->Print(os);<br />
vtkstd::string str = os.str();<br />
//<br />
// Process the string as you want<br />
<br />
=== Writing a simple CMakeLists.txt. ===<br />
<br />
If you get something that looks like:<br />
<br />
undefined reference to<br />
`__imp___ZN13vtkTIFFReader3NewEv'<br />
collect2: ld returned 1 exit status <br />
<br />
You certainly forgot to pass in a library to your executable. The easisest way is to use CMakeLists.txt file.<br />
<br />
For example the minimal project is:<br />
<br />
FIND_PACKAGE(VTK)<br />
IF (VTK_FOUND)<br />
INCLUDE (${VTK_USE_FILE})<br />
ENDIF (VTK_FOUND)<br />
ADD_EXECUTABLE(tiff tiff.cxx )<br />
TARGET_LINK_LIBRARIES (tiff<br />
vtkRendering<br />
)<br />
<br />
Since vtkRendering is link against all other vtk lib. Except if you are building VTK with Hybrid or Parallel in that case you need to explicitely specify which library you want to link against.<br />
<br />
== Platform-specific questions ==<br />
<br />
=== What platforms does vtk run on? ===<br />
<br />
VTK should compile and run on most versions of Unix, Linux and Windows.<br />
It has been tested on Suns, SGIs, HPs, Alphas, RS6000s and many Windows<br />
workstations. It was also succesfully built on MacOS X.<br />
<br />
=== What Graphics Cards work with VTK ===<br />
<br />
VTK uses OpenGL to perform almost all of its rendering and some graphics cards/drivers have better support for OpenGL than others. This is not a listing of what cards perform well. It is a listing of what cards actually produce correct results. Here is a list of cards and their status roughly in best to worst order.<br />
<br />
Any Nvidia desktop card on Windows -- 100% compatible<br /> <br />
Any ATI desktop cards on Windows -- 100% compatible<br /><br />
Mesa -- most releases pass all VTK tests<br /><br />
Microsoft Software OpenGL -- passes all VTK tests but does have a couple bugs <br /><br />
Non-linux UNIX cards (Sun HP SGI) -- These generally work<br /><br />
Any Nvidia card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Any ATI card under linux -- these usually pass all VTK tests but have some issues<br /><br />
Nvidia laptop graphics cards under Windows -- known to have some issues, newer cards pass all tests<br /><br />
ATI laptop graphcis cards under Windows -- known to have some issues, newer cards pass all tests (e.g. [http://public.kitware.com/pipermail/vtkusers/2004-August/075966.html ATI Mobility Radeon 9600])<br /><br />
MacOSX graphics cards -- fails some VTK tests<br /><br />
Intel Extreme Graphics -- fails some VTK tests<br /><br />
<br />
<br />
<br />
=== How do I build the examples on the PC running Windows? ===<br />
<br />
Since building the C++ examples on the PC isn't all that easy, here are<br />
some instructions from Jack McInerney.<br />
<br />
Steps for creating a VTK C++ project 8/14/96<br />
<br />
This is based on what I learned creating a project to run the Mace<br />
example. These steps allowed me to successfully built and run this example.<br />
<br />
# Create a console project (File, New, then select Console application).<br />
# Add the files of interest to the project. (e.g., Mace.cxx)<br />
# Under Build, select Update all Dependencies. A long list of .hh files will show up under dependencies<br /> For this to work, Visual C++ needs to know where to look to find the include files. In my case they are at C:\VTK\VTK12SRC\INCLUDE. To tell Visual C++ to look there, go to Tools, Options. Select the tab Directories. Under the list for Include files add: C:\VTK\VTK12SRC\INCLUDE<br />
# Compile the file Mace.cxx. This will lead to many warnings about data possibly lost as double variables are converted to float variables. These can be gotten rid of by going to Build, Settings, and select the C++ tab. Under the General catagory, set Warning Level to 1* (instead of 3).<br />
# Before linking, some additional settings must be modified. Go to Build, Settings, and select the Link tab. In the General catagory, add the libraries opengl32.lib and glaux.lib to the Object/Library Modules. Put a space between each file name. Then select the C++ tab and the Category: Code Generation. Under Use Run-Time Library, select Debug Multithreaded DLL. Select OK to exit the dialog box. The above libraries are available from Microsoft's Web site at: http://www.microsoft.com/softlib/mslfiles/Opengl95.exe or ftp://ftp.microsoft.com/softlib/mslfiles/Opengl95.exe <br /> This is a self extracting archive which contains these files. Simply place them in your windows system directory.<br />
# Link the code by selecting Build, Build MaceProject.exe. I still get one warning when I do this, but it appears to be harmless<br /><br />
<br />
When you go to run the program, it will bomb out unless it can find 2<br />
DLLs: Opengl32.dll and Glu32.dll. These need to be located either in the<br />
project directory or the C:\WINDOWS directory. These files are supplied<br />
on the vtk CD-ROM (in the vtk\bin directory).<br />
<br />
=== 64-bit System Issues ===<br />
<br />
vtk does run on the DEC Alpha but vtk binary files are not compatible<br />
between 32-bit and 64-bit systems. For portability, use the default file<br />
type, ascii, for vtkPolyDataWriter, etc. You may be able to write a<br />
binary file on a 64-bit system and read it back in.<br />
<br />
=== What size swap space should I use on a PC? ===<br />
<br />
Building vtk on the PC requires a significant amount of memory (at least<br />
when using Visual C++)... but the final product is nice and compact. To<br />
build vtk on the PC, we recommend setting the min/max swap space to at<br />
least 400MB/500MB (depending on how much RAM you have... the sum of RAM<br />
and swap space should be roughly 500+ MB).<br />
<br />
=== Are there any benchmarks of VTK and/or the hardware it runs on? ===<br />
<br />
Take a look at the "Simple Sphere Benchmark":<br />
<br />
http://www.barre.nom.fr/vtk/bench.html<br />
<br />
It is not a "real world" benchmark, but provide synthetic results<br />
comparing different hardware running VTK:<br />
<br />
http://purl.oclc.org/NET/rriv/vtk/sphere-bench<br />
<br />
=== Why is XtString undefined when using VTK+Python on Unix? ===<br />
<br />
This is a side effect of dynamic linking on (some?) Unix systems. It<br />
appears often on Linux with the Mesa libraries at least. The solution is<br />
to make sure your Mesa libraries are linked with the Xt library. One way<br />
to do this is to add "-lXt" to MESA_LIB in your user.make file.<br />
<br />
=== How do I get the Python bindings to work when building VTK with Borland C++? ===<br />
<br />
If you've built VTK with the freely downloadable Borland C++ 5.5 (or its<br />
commercial counterpart) and you're using the Python binaries from<br />
http://www.python.org/, you'll note that when you try to run a VTK<br />
Python example you get something similar to the following error message:<br />
<br />
from vtkCommonPython import * <br />
ImportError: dynamic module does not define init function<br />
(initvtkCommonPython)<br />
<br />
This is because BCC32 prepends an underscore ("_") to all exported<br />
functions, so (in this case) the vtkCommonPython.dll contains a symbol<br />
_initvtkCommonPython which Python does not find. All kits (e.g.<br />
Rendering, Filtering, Patented) will suffer from this problem.<br />
<br />
The solution is to create Borland module definition in the VTK binary<br />
(output) directory, in my case VTK/bin. You have to do this for all kits<br />
that you are planning to use in Python. Each .def file must have the<br />
same basename as the DLL, e.g. "vtkCommonPython.def" for<br />
vtkCommonPython.dll and it must be present at VTK link time. The def<br />
file contains an export alias, e.g.:<br />
<br />
EXPORTS<br />
initvtkCommonPython=_initvtkCommonPython<br />
<br />
The Borland compiler will create an underscore-less alias in the DLL<br />
file and Python will be able to load it as a module.<br />
<br />
=== How do I build Python bindings on AIX ? ===<br />
<br />
There is a problem with dynamic loading on AIX. Old AIX did not have<br />
dlopen/dlsym, but they used load mechanism. Python still reflects this.<br />
VTK is however not compatible with the old load mechanism.<br />
<br />
The following patch to Python 2.2.2 makes python use dlopen/dlsym on AIX<br />
5 or greater.<br />
<br />
http://www.vtk.org/files/misc/python_aix.diff<br />
<br />
=== How to build VTK for offscreen rendering? ===<br />
<br />
Struggled a few hours to get VTK to do offscreen rendering. I use it to<br />
batch process medical images. Without actually producing output on the<br />
screen, I still print resulting images in a report to easily review the<br />
results of an experiment.<br />
<br />
Here is how I solved this problem for VTK version 4.2.2.<br />
<br />
1. Download Mesa-4.0.4 source<br />
<br />
Modify Mesa-4.0.4/Make-config in the 'linux:' target the following vars:<br />
<br />
GL_LIB = libVTKMesaGL.so<br />
GLU_LIB = libVTKMesaGLU.so<br />
GLUT_LIB = libVTKMesaglut.so<br />
GLW_LIB = libVTKMesaGLw.so<br />
OSMESA_LIB = libOSVTKMesa.so<br />
CFLAGS = -O -g -ansi -pedantic -fPIC -ffast-math-DUSE_MGL_NAMESPACE \<br />
-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L-D_SVID_SOURCE \<br />
-D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include"<br />
<br />
then<br />
<br />
make -f Makefile.X11 linux <br />
cp Mesa-4.0.4/lib/* /data/usr/mesa404/lib/<br />
<br />
I use 'VTKMesa' name extension to avoid conflicts with my RH9.0 libs<br />
(especially OSMesa lib in XFree!). I'm using shared libraries, because<br />
that allows me to use dynamic libs from VTK and not the vtk program<br />
itself without explicitly having to load VTKMesaGL with my app. I copied<br />
the 'VTKMesa' libs in /data/usr/mesa404/lib/, but any odd place probably<br />
will work. Avoid /usr/lib /usr/local/lib for now.<br />
<br />
2. Follow normal instructions to get a proper working vtk, then<br />
<br />
ccmake <br />
<br />
with the following options:<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
| VTK_USE_MANGLED_MESA || ON<br />
|-<br />
| MANGLED_MESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_MESA_LIBRARY || /data/usr/mesa404/lib/libVTKMesaGL.so<br />
|-<br />
| MANGLED_OSMESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_OSMESA_LIBRARY || /data/usr/mesa404/lib/libOSVTKMesa.so<br />
|-<br />
| OPENGL_xmesa_INCLUDE_DIR || /data/usr/mesa404/include<br />
|}<br />
<br />
test using /data/prog/VTK-4.2.2/Examples/MangledMesa/Tcl scripts<br />
<br />
== Changes to the VTK API ==<br />
<br />
=== Change to vtkIdList::IsId() ===<br />
<br />
vtkIdList::IsId(int id) used to return a 0 or 1 to indicate whether the<br />
specified id is in the list. Now it returns -1 if the id is not in the<br />
list; or a non-negative number indicating the position in the list.<br />
<br />
=== Changes vtkEdgeTable ===<br />
<br />
vtkEdgeTable had two changes. The constructor now takes no arguments,<br />
and you use InitEdgeInsertion() to tell the class how many points are in<br />
the dataset. Also, IsEdge(p1,p2) now returns a -1 if the edge (defined<br />
by points p1,p2) is not defined. otherwise a non-negative integer value<br />
is returned.<br />
<br />
These changes were made to support the association of attributes with<br />
edges.<br />
<br />
=== Changes between VTK 4.2 and VTK 4.4 (and how to update) ===<br />
<br />
We have removed the CVS date, revision, and the language from the<br />
copyright on all the files. This information wasn't being used much and<br />
it created extra work for developers. For example you edit vtkObject.h<br />
rebuild all of VTK, check in you change, then you must rebuild all of<br />
VTK again because commiting the header file causes it to be changed by<br />
CVS (because the revision number changed) This change will also make it<br />
easier to compare different branches of VTK since these revision number<br />
differences will no longer show up. The CVS revision number is still in<br />
the cxx file in the RevisionMacro. You don't need to make any changes to<br />
your code for this.<br />
<br />
The DataArray classes now use a templated intermediate class to share<br />
their implementation. Again there is no need for you to make changes to<br />
your code.<br />
<br />
Legacy code has been removed. Specifically none of the old style<br />
callbacks are supported and observers should be used instead. So where<br />
you used a filter->SetStartMethod(myFunc) you should do a<br />
filter->AddObserver(vtkCommand::StartEvent,myCommand) Usually this will<br />
require you to create a small class for the observer.<br />
vtkImageOpenClose3D.cxx has an example of using an observer and there<br />
are a few other examples in VTK. If you switch to using Observers your<br />
code should also work with versions of VTK from 3.2 or later since the<br />
Observers have been in VTK since VTK 3.2.<br />
<br />
Many functions that previously took or returned float now take or return<br />
double. To change your code to work with VTK 4.4 or later you can just<br />
replace float with double for the appropriate calls and variables. If<br />
you want your code to work with both old and new versions of VTK you can<br />
use vtkFloatingPointType which is defined to be double in VTK 4.4 and<br />
later and it is float in vtk 4.2.5. In versions of VTK prior to 4.2.5<br />
you can use something like:<br />
<br />
#ifndef vtkFloatingPointType<br />
#define vtkFloatingPointType vtkFloatingPointType<br />
typedef float vtkFloatingPointType;<br />
#endif<br />
<br />
at the beginning of your code. That will set it to the correct value for<br />
all versions of VTK old and new.<br />
<br />
=== Use of New() and Delete() now enforced (vs. new & delete) ===<br />
<br />
Constructors and destructors in VTK are now protected. This means you<br />
can no longer use little "new" or "delete" to create VTK instances.<br />
You'll have to use the methods ::New() and ::Delete() (as has been<br />
standard practice for some time).<br />
<br />
The reason for this is to enforce the use of New() and Delete(). Not<br />
using New() and Delete() can lead to bad mojo, mainly reference counting<br />
problems or not taking advantage of special procedures incorporated into<br />
the New() method (e.g., selecting the appropriate hardware interface<br />
during instance creation time).<br />
<br />
If you've used New() and Delete() in your code, these changes will not<br />
affect you at all. If you're using little "new" or "delete", your code<br />
will no longer and compile and you'll have to switch to New() and Delete().<br />
<br />
=== Changes between VTK 4.4 and VTK 4.6 ===<br />
<br />
Collection Changes<br />
<br />
Collections have had some small changes (originally started by Chris<br />
Volpe) to better support reentrant iteration. Specifically all the<br />
collection have an InitTraversal(sit) and GetNextFoobar(sit) methods.<br />
(where Foobar is what the collection contains, for example<br />
GetNextActor(sit)) The argument to both of these methods is a<br />
vtkCollectionSimpleIterator. Most of the collection use in VTK has been<br />
modified to use these new methods. The advantage is that these new<br />
methods support having the same collection be iterated through in a<br />
reentrant safe manner. In the past this was not true and led to a number<br />
of problems. In the future for C++ class development please use this<br />
approach to iterating through a collection. These changes are fully<br />
backwards compatible and no old APIs were harmed in the making of these<br />
changes. So in summary, for the future, where you would have written:<br />
<br />
for (actors->InitTraversal();<br />
(actor = actors->GetNextActor());)<br />
<br />
you would now have:<br />
<br />
vtkCollectionSimpleIterator actorIt;<br />
for (actors->InitTraversal(actorIt);<br />
(actor = actors->GetNextActor(actorIt));)<br />
<br />
=== Changes in VTK between 3.2 and 4.0 ===<br />
<br />
* Changes to vtkDataSetAttributes, vtkFieldData and vtkDataArray: All attributes (scalars, vectors...) are now stored in the field data as vtkDataArray's. vtkDataSetAttributes became a sub-class of vtkFieldData. For backwards compatibility, the interface which allows setting/getting the attributes the old way (by passing in a sub-class of vtkAttributeData such as vtkScalars) is still supported but it will be removed in the future. Therefore, the developers should use the new interface which requires passing in a vtkDataArray to set an attribute. vtkAttributeData and it's sub-classes (vtkScalars, vtkVectors...) will be deprectated in the near future; developers should use vtkDataArray and it's sub-classes instead. We are in the process of removing the use of these classes from vtk filters.<br />
<br />
* Subclasses of vtkAttributeData (vtkScalars, vtkVectors, vtkNormals, vtkTCoords, vtkTensors) were removed. As of VTK 4.0, vtkDataArray and it's sub-classes should be used to represent attributes and fields. Detailed description of the changes and utilities for upgrading from 3.2 to 4.0 can be found in the package: http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
* Added special methods to data arrays to replace methods like<br />
<br />
tc SetTCoord i x y 0<br />
<br />
or<br />
<br />
vc SetVector i vx vy vz<br />
<br />
in interpreted languages (Tcl, Python, Java). Use:<br />
<br />
tc SetTuple2 i x y<br />
<br />
or<br />
<br />
vc SetTuple3 i vx vy vz<br />
<br />
* Improved support for parallel visualization: vtkMultiProcessController and it's sub-classes have been re-structured and mostly re-written. The functionality of vtkMultiProcessController have been re-distributed between vtkMultiProcessController and vtkCommunicator. vtkCommunicator is responsible of sending/receiving messages whereas vtkMultiProcessController (and it's subclasses) is responsible of program flow/control (for example processing rmi's). New classes have been added to the Parallel directory. These include vtkCommunicator, vtkMPIGroup, vtkMPICommunicator, vtkSharedMemoryCommunicator, vtkMPIEventLog... There is now a tcl interpreter which supports parallel scripts. It is called pvtk and can be build on Windows and Unix. Examples for both Tcl and C++ can be found in the examples directories.<br />
<br />
* vtkSocketCommunicator and vtkSocketController have been added. These support message passing via BSD sockets. Best used together with input-output ports.<br />
<br />
* Since it was causing very long compile times (it essentially includes every vtk header file) and it was hard to maintain (you had to add a line whenever you added a class to VTK) vtk.h was removed. You will have to identify the header files needed by your application and include them one by one.<br />
<br />
* vtkIterativeClosestPointTransform has been added. This class is an implementation of the ICP algorithm. It matches two surfaces using the iterative closest point (ICP) algorithm. The core of the algorithm is to match each vertex in one surface with the closest surface point on the other, then apply the transformation that modify one surface to best match the other (in a least square sense).<br />
<br />
* The SetFileName, SaveImageAsPPM and related methods in vtkRenderWindow have been removed. vtkWindowToImageFilter combined with any of the image writers provides greater functionality.<br />
<br />
* Support for reading and writing PGM and JPEG images has been included.<br />
<br />
* Methods with parameters of the form "type param[n]" are wrapped. Previously, these methods were only wrapped if the array was declared 'const'. The python wrappers will allow values to be returned in the array.<br />
<br />
* The directory structure was completely reorganized. There are now subdirectories for Common (core common classes) Filtering (superclasses for filtering operations) Imaging (filters and sources that produce images or structured points) Graphics (filters or sources that produce data types other than ImageData and StructuredPoints) IO (file IO classes that do not require Rendering support) Rendering (all actors mappers annotation and rendering classes) Hybrid (typically filters and sources that require support from Rendering or both Imagign and Graphics) Parallel (parallel visualization support classes) Patented (patented classes) Examples (documented examples) Wrapping (support for the language wrappers). In many directories you will see a Testing subdirectory. The Testing subdirectories contain tests used to validate VTKs operation. Some tests may be useful as examples but they are not well documented.<br />
<br />
* The Build process for VTK now uses CMake (found at www.cmake.org) This replaces pcmaker on windows and configure on UNIX. This resolves some longstanding problems and limitation we were having with pcmaker and configure, and unifies the build process into one place.<br />
<br />
=== Changes to VTK between 4.0 and 4.2 ===<br />
<br />
* Use of macros to support serialization, standardize the New method, and provide the Superclass typedef.<br />
<br />
* Subclassing of VTK classes in the python wrappers (virtual method hooks are not provided).<br />
<br />
* vtkImageWindow, vtkImager, vtkTkImageWindowWidget and their subclasses have been removed to reduce duplicated code and enable interation in ImageWindows. Now people should use vtkRenderer and vtkRenderWindow instead. vtkImageViewer still works as a turn key image viewing class although it now uses vtkRenderWindow and vtkRenderer internally instead of vtkImageWindow and vtkImager.<br />
<br />
* New class: vtkBandedPolyDataContourFilter. Creates solid colored bands (like you find on maps) of scalar value.<br />
<br />
* Event processing: Several new events to VTK were added (see vtkCommand.h). Also event processing can now be prioritized and aborted. This allows applications to manage who processes which events, and terminates the processing of a particular event if desired.<br />
<br />
* 3D Widgets: A new class vtkInteractorObserver was added to observe events on vtkRenderWindowInteractor. Using the new event processing infrastructure, multiple 3D widgets (subclasses of vtkInteractorObserver) can be used simultaneously to process interactions. Several new 3D widgets have been added including:<br />
** vtkLineWidget<br />
** vtkPlaneWidget<br />
** vtkImagePlaneWidget<br />
** vtkBoxWidget<br />
** vtkSphereWidget<br />
<br />
* Besides providing a representation, widgets also provide auxiliary functionality such as providing transforms, implicit functions, plane normals, sphere radius and center, etc.<br />
<br />
* New class: vtkInstantiator provides a means by which one can create an instance of a VTK class using only the name of the class as a string.<br />
<br />
* New class: vtkXMLParser provides a wrapper around the Expat XML parsing library. A new parser can be written by subclassing from vtkXMLParser and providing a few simple virtual method implementations.<br />
<br />
* TIFF reader is now implemented using libtiff, which makes it capable of reading almost all available TIFF formats. The libtiff is also available internally as vtktiff.<br />
<br />
* New method (all sub-classes of vtkObject): Added a virtual function called NewInstance to vtkTypeMacro. NewInstance creates and returns an object of the same type as the current one. It does not copy any properties. The returned pointer is of the same type as the pointer the method was invoked with. This method should replace all the MakeObject methods scattered through VTK.<br />
<br />
* vtkSetObject macro is depricated for use inside the VTK. It is still a valid construct in projects that use VTK. Instead use vtkCxxSetObjectMacro which does the same thing.<br />
<br />
* vtkPLOT3DReader have been improved. It now supports:<br />
** multigrid (each block is one output)<br />
** ascii<br />
** fortran-style byte counts<br />
** little/big endian<br />
** i-blanking (partial)<br />
<br />
* A new vtkTextProperty class has been created, and duplicated text API s have been obsoleted accordingly. Check the<br />
[[VTK_FAQ#Text_properties_in_VTK_4.2|Text properties in VTK 4.2]] FAQ entry for a full description of the change.<br />
<br />
=== How do I upgrade my existing C++ code from 3.2 to 4.x? ===<br />
<br />
This is (a corrected version of) an email that was posted to vtkusers.<br />
Please feel free to correct or add anything.<br />
<br />
{| cellspacing="3" <br />
|- valign="top"<br />
|width="55%" bgcolor="#f0f0ff" style="border:1px solid #ffc9c9;padding:1em;padding-top:0.5em;"|<br />
<br />
I've just ported my medium-sized (40K lines) application from vtk3.2 to<br />
vtk4.x. I thought I would share my experiences with you, in case there<br />
were people out there contemplating it but a bit scared.<br />
<br />
One source of information for upgrading code is:<br />
<br />
http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
I'm using VC++6 + MFC on Win2K and was unable/unwilling to run the<br />
script in the zip file.<br />
<br />
So,<br />
<br />
I switched all my include directories to the new VTK ones and<br />
recompiled. 337 errors, not unexpectedly. Most concerned vtkScalars and<br />
vtkTCoords which have both been removed. Where I was using single value<br />
scalars, like this:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetNumberOfScalars(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetScalar(i,2.3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *scalars = vtkFloatArray::New();<br />
scalars->SetNumberOfComponents(1);<br />
scalars->SetNumberOfTuples(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetTuple1(i,2.3);<br />
...<br />
<br />
OK so far, far fewer errors.<br />
<br />
Where I had 2D texture coordinates:<br />
<br />
vtkTCoords *tcoords = vtkTCoords::New();<br />
tcoords->SetNumberOfTCoords(N);<br />
...<br />
float p[3];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTCoord(i,p);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *tcoords = vtkFloatArray::New();<br />
tcoords->SetNumberOfComponents(2);<br />
tcoords->SetNumberOfTuples(N);<br />
...<br />
float p[2];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTuple(i,p);<br />
....<br />
<br />
All well and good, still fewer errors. Make sure you call<br />
SetNumberOfComponents *before* SetNumberOfTuples else you'll get<br />
problems (I did!).<br />
<br />
Where I was creating 0-255 image data and had been using:<br />
<br />
vtkScalars* scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
...<br />
<br />
Going well!<br />
<br />
When creating RGB images, I had been using:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfScalars(X*Y);<br />
...<br />
scalars->SetActiveComponent(0);<br />
scalars->SetScalar(i,val1);<br />
scalars->SetActiveComponent(1);<br />
scalars->SetScalar(i,val2);<br />
scalars->SetActiveComponent(2);<br />
scalars->SetScalar(i,val3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfTuples(X*Y);<br />
...<br />
scalars->SetComponent(i,0,val1);<br />
scalars->SetComponent(i,1,val2);<br />
scalars->SetComponent(i,2,val3);<br />
...<br />
<br />
My remaining errors concerned vtkWin32OffscreenRenderWindow that has<br />
been removed. Where I had been using:<br />
<br />
vtkWin32OffscreenRenderWindow *offscreen = vtkWin32OffscreenRenderWindow::New();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkWin32OpenGLRenderWindow *offscreen = vtkWin32OpenGLRenderWindow::New();<br />
offscreen->SetOffScreenRendering(1);<br />
...<br />
<br />
All done. I'd had to throw in some #include "vtkFloatArray.h" and things<br />
like that of course. Zero compile errors.<br />
<br />
Had to remember to link against the new vtk lib files, so I removed<br />
<br />
vtkdll.lib <br />
<br />
and added<br />
<br />
vtkCommon.lib<br />
vtkGraphics.lib<br />
<br />
etc.<br />
<br />
Zero link errors. My program is up and running again, no apparant<br />
problems. Plus now I can use all the new features of vtk4. (And I'm sure<br />
it's faster but maybe that's my imagination.)<br />
<br />
All this took me about three hours.<br />
<br />
Bye!<br />
<br />
Tim.<br />
|}<br />
<br />
=== What is the release schedule for VTK ===<br />
<br />
VTK has a formal release every eight to sixteen months. VTK 4.0 was cut<br />
in December of 2001 and released in March 2002. VTK 4.2 was releaseed in<br />
February of 2003. VTK 4.4 (which is an interim release) was released at the end of 2003. The next version of VTK 5.0 will probably be released in late 2004.<br />
<br />
=== Roadmap: What changes are being considered for VTK ===<br />
<br />
This is a list of changes that are being considered for inclusion into<br />
VTK. Some of these changes will happen while other changes we would like<br />
to see happen but may not due to funding or time issues. For each change<br />
we try to list what the change is, when we hope to complete it, if it is<br />
actively being developed. Detailed discussion on changes is limited to<br />
the vtk-developers mailing list.<br />
<br />
# Modify existing image filters to use the new vtkImageIterator etc. Most simple filters have been modified to use ithe iterator in VTK 4.2. It would be nice to have some sort of efficient neighborhood iterators but so far we haven't come up with any.<br />
# Update vtkCollections to support an iterator. Currently vtkCollections do not work well because they store state for the current item. So two methods cannot work on the same collection in the same stack trace using the GetNextItem() interface. An iterator of some sort should be used instead. No one is working on this yet.<br />
# Support for AMR (mulit-res grids see http://seesar.lbl.gov/AMR/Overview/ for an overview)<br />
# Improvements to the pipeline update mechanism including support for multiresolution<br />
# Possible support for multi-block and composite grids<br />
# Rework the polydata and unstructured grid structures (vtkMesh ??). Related ideas include:<br />
#* Make UnstructuredGrid more compact by removing the cell point count from the vtkCellArray. This will reduce the storage required by each cell by 4 bytes.<br />
#* Make vtkPolyData an empty subclass of vtkUnstructuredGrid. There are a number of good reasons for this but it is a tricky task and backwards compatibility needs to be maintained.<br />
# More parallel support, including parallel compositing algorithms<br />
# Algorithms like LIC (http://www-courses.cs.uiuc.edu/~cs419/lic.pdf), maybe a couple terrain-decimation algorithms<br />
# Further integration of STL and other important C++ constructs (like templates)<br />
# Unstructured grid volume rendering<br />
<br />
VTK 4.4 (intermediate release, end of 2003)<br />
<br />
* convert APIs to double (done)<br />
* remove old callbacks (done)<br />
* blanking<br />
* ref count observers (done)<br />
* switch collections to use iterators (done)<br />
* improve copyright (done)<br />
<br />
VTK 5.0 (major release, end of 2004)<br />
<br />
* new pipeline mechanism (see [[Media:Pipeline.pdf|Pipeline.pdf]])<br />
* time support<br />
* true AMR support<br />
<br />
=== Changes to Interactors ===<br />
<br />
The Interactors have been updated to use the Command/Observer events of<br />
vtk. The vtkRenderWindowInteractor now has ivars for all the event<br />
information. There is a new class called<br />
vtkGenericRenderWindowInteractor that can be used to set up the bindings<br />
from other languages like python, Java or TCl.<br />
<br />
A new class vtkInteractorObserver was also added. It has a<br />
SetInteractor() method. It observes the keypress and delete events<br />
invoked by the render window interactor. The keypress activation value<br />
for a widget is now 'i' (although this can be programmed).<br />
vtkInteractorObserver has the state ivar Enabled. All subclasses must<br />
have the SetEnabled(int) method. Convenience methods like On(), Off(),<br />
EnabledOn(), and EnabledOff() are available. The state of the interactor<br />
observer is obtained using GetEnabled(). The SetEnabled(1) method adds<br />
observers to watch the interactor (appropriate to the particular<br />
interactor observer) ; SetEnabled(0) removes the observers . There are<br />
two new events: EnableEvent and DisableEvent which are invoked by the<br />
SetEnabled() method.<br />
<br />
The events also support the idea of priority now. When you add an<br />
observer, you can specify a priority from 0 to 1. Higher values will be<br />
called back first. An observer can also tell the object not to call any<br />
more observers. This way you can handle an event, and stop further<br />
processing. In this way you can add handlers to InteractorStyles without<br />
sub-classing and from wrapped languages.<br />
<br />
For more information see: vtkGenericRenderWindowInteractor,<br />
vtkRenderWindowInteractor, vtkInteractorObserver.<br />
<br />
=== Header files and vtkSetObjectMacro ===<br />
<br />
On some platforms such as MS Visual Studio .NET, compiler is not capable<br />
of handling too big input files. Some VTK files with all includes do<br />
become big enough to overwhelm the compiler. The solution is to minimize<br />
the amount of includes. This especially goes for header files, because<br />
they propagate to other files. Every class header file should include<br />
only the parent class header file. If there is no other alternative, you<br />
should put a comment next to include file explaining why the file has to<br />
be included.<br />
<br />
The related issue is with vtkSetObjectMacro. This file calles some<br />
methods on an argument class, which implies that the argument class<br />
header file has to be included. The result is bloat on the header files.<br />
The solution is to not use vtkSetObjectMacro but vtkCxxSetObjectMacro.<br />
The difference is that vtkCxxSetObjectMacro goes in the Cxx file and not<br />
in the header file.<br />
<br />
Example: Instead of<br />
<br />
#include "vtkBar.h"<br />
class vtkFoo : public vtkObject<br />
{ ...<br />
vtkSetObjectMacro(Bar, vtkBar);<br />
...<br />
};<br />
<br />
Do:<br />
<br />
class vtkBar;<br />
class vtkFoo : public vtkObject<br />
{<br />
...<br />
virtual void SetBar(vtkBar*);<br />
...<br />
};<br />
<br />
and add the following line to vtkFoo.cxx<br />
<br />
vtkCxxSetObjectMacro(vtkFoo,Bar,vtkBar);<br />
<br />
=== Text properties in VTK 4.2 ===<br />
<br />
A new<br />
[http://public.kitware.com/VTK/doc/nightly/html/classvtkTextProperty.html vtkTextProperty]<br />
class has been added to VTK 4.2.<br />
<br />
This class factorizes text attributes that used to be spread out and<br />
duplicated in many different classes (mostly 2D actors and text<br />
mappers). Among those attributes, font family, font size,<br />
bold/italic/shadow properties, horizontal and vertical justification,<br />
line spacing and offset have been retained, whereas new attributes like<br />
color and opacity have been introduced.<br />
<br />
We tried to make sure that you can use a vtkTextProperty to modify text<br />
properties in the same way a vtkProperty can be used to modify the<br />
surface properties of a geometric object. In that regard, you should be<br />
able to share a vtkTextProperty between different actors or assign the<br />
same vtkTextProperty to an actor that offers multiple vtkTextProperty<br />
attributes ([http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlot]<br />
for example).<br />
<br />
Here is a quick example:<br />
<br />
vtkTextActor *actor0 = vtkTextActor::New();<br />
actor0->GetTextProperty()->SetItalic(1);<br />
//<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
//<br />
vtkTextActor *actor1 = vtkTextActor::New();<br />
actor1->SetTextProperty(tprop);<br />
//<br />
vtkTextActor *actor2 = vtkTextActor::New();<br />
actor2->SetTextProperty(tprop);<br />
<br />
*Backward compatibility issues*:<br />
<br />
1) Color and Opacity:<br />
<br />
The text color and text opacity settings are now controlled by the<br />
vtkTextProperty Color and Opacity attributes instead of the<br />
corresponding actor's color and opacity attributes. In the following<br />
example, those settings were controlled by the attributes of the<br />
vtkProperty2D attached to the vtkActor2D (vtkTextActor). The<br />
vtkTextProperty attributes should be used instead:<br />
<br />
vtkTextActor *actor = vtkActor::New();<br />
actor->GetProperty()->SetColor(...);<br />
actor->GetProperty()->SetOpacity(...);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetColor(...);<br />
actor->GetTextProperty()->SetOpacity(...);<br />
<br />
To make migration easier for a while, we have set the vtkTextProperty<br />
default color to ''(-1.0, -1.0, -1.0)'' and the default opacity to ''-1.0''.<br />
These "magic" values are checked by the underlying text mappers at<br />
rendering time. If they are found, the color and opacity of the 2D<br />
actor's vtkProperty2D are used, just as it was in VTK 4.1.<br />
<br />
2) API (i.e. SetBold(), SetItalic(), etc)<br />
<br />
Most of the VTK classes involving text used to provide their own text<br />
attributes like Bold, Italic, Shadow, FontFamily. Thus, each of those<br />
classes would duplicate the vtkTextMapper API through methods like<br />
SetItalic(), SetBold(), SetFontFamily(), etc.<br />
<br />
Moreover, if one class had different text elements (say, for example,<br />
the title and the labels of a scalar bar), there was no way to modify<br />
the text properties of these elements separately.<br />
<br />
The vtkTextProperty class has been created to address both issues, by<br />
obsoleting those duplicated attributes and methods and providing a<br />
unified way to access text properties, and by allowing each class to<br />
associate different vtkTextProperty to different text elements.<br />
<br />
Migrating your code basically involves using the old API on your actor's<br />
vtkTextProperty instead of the actor itself. For example:<br />
<br />
actor->SetBold(1);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetBold(1);<br />
<br />
When a class provides different vtkTextProperty for different text<br />
elements, the TextProperty attribute is usually prefixed with that<br />
element type. Example: AxisTitleTextProperty, or AxisLabelTextProperty.<br />
This allows you to set different aspect for each text elements. If you<br />
want to use the same properties, you can either set the same values on<br />
each vtkTextProperty, or make both vtkTextProperty point to the same<br />
vtkTextProperty object. Example:<br />
<br />
actor->GetAxisLabelTextProperty()->SetBold(1);<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
or:<br />
<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
actor->SetAxisLabelTextProperty(tprop);<br />
actor->SetAxisTitleTextProperty(tprop);<br />
<br />
or:<br />
<br />
actor->SetAxisLabelTextProperty(actor->GetAxisTitleTextProperty());<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
The following list specifies the name of the text properties used in the<br />
VTK classes involving text.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html vtkTextMapper]:<br />
* you can still use the vtkTextMapper + vtkActor2D combination, but we would advise you to use a single vtkTextActor instead, this will give you maximum flexibility.<br />
* has 1 text prop: TextProperty, but although you have access to it, do not twwak it unless you are using vtkTextMapper with a vtkActor2D. In all other cases, use the text prop provided by the actor (see below).<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextActor.html vtkTextActor]:<br />
* has 1 text prop: TextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLabeledDataMapper.html vtkLabeledDataMapper]:<br />
* has 1 text prop: LabelTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCaptionActor2D.html vtkCaptionActor2D]:<br />
* has 1 text prop: CaptionTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLegendBoxActor.html vtkLegendBoxActor]:<br />
* has 1 text prop: EntryTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkAxisActor2D.html vtkAxisActor2D],<br />
[http://www.vtk.org/doc/nightly/html/classvtkParallelCoordinatesActor.html vtkParallelCoordinatesActor], and<br />
[http://www.vtk.org/doc/nightly/html/classvtkScalarBarActor.html vtkScalarBarActor]:<br />
* have 2 text props: TitleTextProperty, LabelTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlotActor]:<br />
* has 3 text prop: TitleTextProperty (plot title), AxisTitleTextProperty, AxisLabelTextProperty (title and labels of all axes)<br />
* the legend box text prop (i.e. entry text prop) can be retrieved through actor->GetLegendBoxActor()->GetEntryTextProperty()<br />
* the X (or Y) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/YAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCubeAxesActor2D.html vtkCubeAxesActor2D]:<br />
* has 2 text props: AxisTitleTextProperty, AxisLabelTextProperty (title and label of all axes)<br />
* the X (Y or Z) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/Y/ZAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched.<br />
<br />
=== Forward declaration in VTK 4.x ===<br />
<br />
Since VTK 4.x all classes have been carefully inspected to only include the necessesary headers, and do what is called 'forward declaration' for all other needed classes. Thus, when you compile your projects using a filter that takes as input a dataset and you are passing an imagedata: you need to explicitely include imagedata within your implementation file. This is true for all data types.<br />
<br />
For example, if you get this error:<br />
<br />
no matching function for call to `vtkContourFilter::SetInput(vtkImageData*)'<br />
VTK/Filtering/vtkDataSetToPolyDataFilter.h:44:<br />
candidates are: virtual void vtkDataSetToPolyDataFilter::SetInput(vtkDataSet*)<br />
<br />
This means you need to add in your code : #include "vtkImageData.h"<br />
<br />
== Miscellaneous questions ==<br />
<br />
=== What are the legal issues? ===<br />
<br />
The Visualization Toolkit software is provided under the following<br />
copyright. We think it's pretty reasonable. We do restrict the<br />
distribution of modified code. This is primarily a revision control<br />
issue. We don't want a bunch of renegade vtks running around without us<br />
having some idea why the changes were made and giving us a chance to<br />
incorporate them into the general release.<br />
<br />
Copyright &copy; 1993-2004 Ken Martin, Will Schroeder, Bill Lorensen All<br />
rights reserved.<br />
<br />
Redistribution and use in source and binary forms, with or without<br />
modification, are permitted provided that the following conditions are met:<br />
<br />
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.<br />
<br />
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.<br />
<br />
* Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.<br />
<br />
* Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software.<br />
<br />
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS<br />
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br />
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br />
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR<br />
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br />
<br />
=== Can't you split up the data file? ===<br />
<br />
The data is now in one file that is about 15 Megabytes. This is smaller<br />
than the original data files VTK used and we hope that this size is not<br />
a problem for people anymore. If it is please let us know.<br />
<br />
=== Do you have any shared library tips? ===<br />
<br />
VTK version 4.0 and later supports both shared and static libraries on<br />
most all platforms. For development we typically use shared libraries<br />
since they are faster to link when making small changes. You can control<br />
how VTK builds by setting the BUILD_SHARED_LIBS option in CMake.<br />
<br />
=== What is the deal with the patents ===<br />
<br />
As the copyright mentions there are some patents used in VTK. If you use<br />
any code in the Patented/ directory for commercial application you<br />
should contact the patent holder and obtain a license.<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by General Electric Company: vtkDecimate, vtkMarchingCubes,<br />
vtkMarchingSquares, vtkDividingCubes, vtkSliceCubes and vtkSweptSurface.<br />
The GE contact is:<br />
<br />
Carl B. Horton<br />
Sr. Counsel, Intellectual Property<br />
3000 N. Grandview Blvd., W-710<br />
Waukesha, WI 53188<br />
Phone: (262) 513-4022<br />
E-Mail: mailto:Carl.Horton@med.ge.com<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by Kitware, Inc.: vtkGridSynchronizedTemplates3D,<br />
vtkKitwareContourFilter.h, vtkSynchronizedTemplates2D, and<br />
vtkSynchronizedTemplates3D. The Kitware contact is:<br />
<br />
Ken Martin<br />
Kitware<br />
28 Corporate Drive, Suite 204,<br />
Clifton Park, NY 12065<br />
Phone:1-518-371-3971<br />
E-Mail: mailto:kitware@kitware.com</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=User:Goodwin&diff=278User:Goodwin2004-10-26T20:50:27Z<p>Goodwin: </p>
<hr />
<div>You can email [mailto:goodwin.lawlor&#64;ucd.ie here]<br />
<br />
You can mail here:<br />
<br />
Bioengineering Research Centre</br><br />
205a, Engineering</br><br />
University College Dublin</br><br />
Belfield, Dublin 4</br><br />
Ireland<br />
<br />
I've started to put some code up [http://www.bioengineering-research.com here]</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Scripts&diff=296VTK Scripts2004-10-19T23:33:08Z<p>Goodwin: </p>
<hr />
<div><small>This page was based on Sebastien Barre's [http://www.barre.nom.fr/vtk/links-scripts.html VTK Links: Scripts] page</small>.<br />
<br />
Have you written nifty Tcl/Tk, Java or Python scripts ? Many of us have built scripts and programs that might benefit VTK users. Here are some of them, and I'm quite sure that you also have developped interesting stuff : be part of the VTK swiss-knife !<br />
<br />
== Tcl ==<br />
<br />
[http://brighton.ncsa.uiuc.edu/prajlich/vtkPipeline/ VTK pipeline browser]<br />
<br />
''(P. Rajlich, NCSA)''<br />
"I took the tree widget for Tk by R. Hipp and turned it into a VTK pipeline browser. Combined with the vtkShow script by C. Odet, it allows you to browse and modify the objects in your VTK pipeline".<br />
<br />
[3D VTK pipeline browser] (disappeared, author should contact me)<br />
<br />
''(D. Pont)''<br />
"This 3D pipeline browser is derived from the 2D pipeline browser developed by P. Rajlich, and uses vtkShow developed by C. Odet. Your VTK pipeline is visualised as a 3D tree using VTK. The browser creates its own window. Pre-defined icons are used to represent the different types of objects such as: data sources, filters, actors, and mappers. The icons are connected with tubes to represent the flow of data [...]. Objects with multiple inputs and outputs are handled. If the *animation* feature is selected the icons are highlighted with a translucent sphere and labeled in the order they execute in your pipeline. [...]."<br />
<br />
[http://rrvtk.free.fr/vtk/reflector/ VTK Reflector (object browser)]<br />
<!-- the old dead link was: http://www-sop.inria.fr/caiman/personnel/Robert.Riviere/vtk/reflect.html --><br />
<br />
''(R. Rivière, INRIA)''<br />
"Here is VTK Reflector, a small tool using TCL and VTK reflection properties. With reflector, you can browse among VTK objects you have created, display their contents and known methods names, and apply them. "<br />
<br />
[http://www.barre.nom.fr/vtk/bench.html VTK Sphere Benchmark]<br />
<br />
''(R. Rivière, S. Barré, INRIA, UTC)''<br />
"The VTK Sphere Benchmark is a simple platform-independent Tcl/Tk graphics performance test using VTK library. It is small with no (or little) version requirements. It is designed to get a rough idea of the capabilities and efficiency of your system by displaying a 3D object and computing an estimation of the average throughput in polygons/s. Different rendering options might be used, and automation is provided to try the same bench at varying 3D complexity. A final report may be sent to us and all results are saved to a database for further comparisons."<br />
<br />
[http://fzs05.ms.tu-berlin.de/%7Erunarko/ melati a little tool for visualization ]<br />
<br />
''(J. Runarko)''<br />
"Melati is a script written with TclTk and the Visualization Toolkit. It is written on my old Linux box at home. It's purpose is to give the user the ability to view calculated data from Tochnog a FEA program written by Dennis Roddeman.<br />
<br />
[isoViewer]<br />
<br />
''(K. Eschenberg)''<br />
Two programs have been created for using isosurfaces to view structured data fields. The program "iso" reads a file of time-varying structured data (TSD) then uses VTK to generate isosurfaces for each time. The results are written to a file which can then be read and displayed with the program "chap2".<br />
<br />
[[VTK Mouse Picking]]<br />
<br />
The default way pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button... a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor. --[[User:Goodwin|Goodwin]] 11:06, 17 Aug 2004 (EDT)<br />
<br />
== Python ==<br />
<br />
<br />
[http://mayavi.sourceforge.net/vtkPipeline/ Python vtkPipeline browser]<br />
<br />
''(P. Ramachandran)''<br />
"Python modules that provide a VTK pipeline browser using Tkinter. All the objects in the pipeline can be configured".<br />
<br />
== Perl ==<br />
<br />
<br />
[http://www.math.umd.edu/%7Erdl/PerlVTK/ PerlVTK]<br />
<br />
''(R. De Leo)''<br />
"PerlVTK is a Perl module that allows you to call VTK functions from Perl".</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK/FAQ&diff=177VTK/FAQ2004-09-10T17:02:30Z<p>Goodwin: /* Is there a mailing list or Usenet newsgroup for VTK? */</p>
<hr />
<div>== General information and availability ==<br />
<br />
=== What is the Visualization Toolkit? ===<br />
<br />
The '''Visualization ToolKit (vtk)''' is a software system for 3D Computer<br />
Graphics and Visualization.<br />
<br />
VTK includes a textbook published by Kitware Inc. ([http://www.kitware.com/products/vtktextbook.html The Visualization<br />
Toolkit, An Object-Oriented Approach to 3D Graphics]),<br />
a C++ class library, and Tcl, Python and Java implementations based on<br />
the class library.<br />
<br />
For more information, see http://www.vtk.org and http://www.kitware.com.<br />
<br />
=== What is the current release? ===<br />
<br />
The current release of vtk is 4.2. This release is available at:<br />
<br />
http://www.vtk.org/files/release/4.2/<br />
<br />
Nightly development releases are available at:<br />
<br />
http://www.vtk.org/files/nightly/<br />
<br />
See http://www.vtk.org/get-software.php for more information.<br />
<br />
=== Can I contribute code or bug fixes? ===<br />
<br />
We encourage people to contribute bug fixes as well as new contributions<br />
to the code. We will try to incorporate these into future releases so<br />
that the entire user community will benefit from them.<br />
<br />
See http://www.vtk.org/contribute.php for information on contributing to<br />
VTK.<br />
<br />
For some ideas take a look at some of the entries in the "Changes to the<br />
VTK API" FAQ section, for example: <br />
[[VTK_FAQ#Roadmap:_What_changes_are_being_considered_for_VTK|What changes are being considered for VTK]]<br />
<br />
=== Can I contribute money? ===<br />
<br />
Please don't send money. Not that we think you're going to send in<br />
unsolicited money. But if you were thinking about it, stop. It would<br />
just complicate our lives and make for all sorts of tax problems.<br />
<br />
=== Is there a mailing list or Usenet newsgroup for VTK? ===<br />
<br />
There is a mailing list: vtkusers@vtk.org<br />
<br />
To subscribe or unsubscribe to the mailing list, go to:<br />
http://www.vtk.org/mailman/listinfo/vtkusers<br />
<br />
To search the list archives go to: http://www.kitware.com/search.html<br />
<br />
There is also a newsgroup that mirrors the mailinglist. At this point it<br />
seems that mirror is down. Mail to the mailinglist used to be posted the<br />
newsgroup, but posts on the newsgroup were not sent to the mailinglist.<br />
The newsgroup was located at:<br />
news://scully.esat.kuleuven.ac.be/vtk.mailinglist<br />
<br />
http://www.gmane.org is a bidirectional mail-to-news gateway that carries the vtkusers mailing list. Its located here: news://news.gmane.org/gmane.comp.lib.vtk.user or here: http://news.gmane.org/gmane.comp.lib.vtk.user. vtkusers mails have been archived since April 2002 and they never expire. You can read and send mails to the vtkusers list without having subscribed to the list.<br />
<br />
=== Is the VTK mailing list archived anywhere? ===<br />
<br />
The mailing list is archived at:<br />
http://www.vtk.org/pipermail/vtkusers/<br />
<br />
You can search the archive at: http://www.kitware.com/search.html<br />
<br />
=== Are answers for the exercises in the VTK book available? ===<br />
<br />
Not anymore.<br />
<br />
The answers to the exercises of the textbook used to be maintained by<br />
Martin Stoufer (kudos), and will be made available by Kitware in the<br />
next future.<br />
<br />
=== Is VTK regression tested on a regular basis? Can I help? ===<br />
<br />
Yes, it is.<br />
<br />
You can view the current regression test results at:<br />
http://public.kitware.com/dashboard.php?name=vtk<br />
<br />
VTK uses Dart to perform builds, run tests, and generate dashboards. You<br />
can find more information about Dart at: http://public.kitware.com/Dart/<br />
<br />
You can help improve the quality of VTK by supplying the authors with<br />
Tcl scripts that can be used as or turned into regression tests. A good<br />
regression test will:<br />
<br />
# Cover code that is not already covered.<br />
# Illustrate a bug that is occuring now or that has occurred in the past.<br />
# Use data that is on the 2nd Edition book CDROM or use "small" data files or use no data at all.<br />
# Optionally, produce an interesting result. <br />
<br />
Currently almost all regression tests are written in Tcl.<br />
<br />
Please send your Tcl regression tests to:<br />
mailto:wlorens1@mail.nycap.rr.com<br />
<br />
Bill will evaluate them for applicability and integrate them into the<br />
nightly test process.<br />
<br />
=== What's the best way to learn VTK? ===<br />
<br />
There are five things you might want to try:<br />
<br />
# Purchase the book [http://www.kitware.com/products/vtktextbook.html The Visualization Toolkit] from Kitware Inc.<br />
# Purchase the book [http://www.kitware.com/products/vtkguide.html VTK Users Guide] from Kitware Inc. <br />
# [http://www.vtk.org/get-software.php Download the source code and/or binaries] (available on Windows) and work through the examples (there are 400-500 examples). <br />
# To learn the innards of VTK, you can attend a [http://www.kitware.com/products/proftrain.html#VTKCourse VTK course] or [http://www.kitware.com/products/proftrain.html sponsor a VTK course at your site] through Kitware. http://www.kitware.com/products/index.html<br />
# Buy Bill a beer and get him talking about VTK<br />
<br />
=== How should I ask questions on the mailing lists? ===<br />
<br />
The best online resource for this question is Eric S. Raymond's<br />
excellent guide on the topic titled "How to ask questions the smart<br />
way". Read it here:<br />
<br />
http://www.catb.org/~esr/faqs/smart-questions.html<br />
<br />
Please do read it and follow his advice. Thanks!<br />
<br />
Please also remember the following when you post your messages to the<br />
VTK mailing lists.<br />
<br />
* Mention the version of VTK you are using and the version of the compiler or scripting language you are using.<br />
<br />
* Mention your platform, OS and their versions.<br />
<br />
* Include hardware details if relevant.<br />
<br />
* Include all relevant error messages (appropriately trimmed of course).<br />
<br />
* The lists have a very large number of subscribers (in the thousands), so please keep messages to the point.<br />
<br />
* Avoid HTML emails.<br />
<br />
* Use a sensible and descriptive subject line.<br />
<br />
* Do NOT post large data files or images to the list. Instead put them in your web page and mention the URLs.<br />
<br />
* Quote the messages you reply to appropriately. Remove unnecessary details.<br />
<br />
When asking a question or reporting a problem try to include a small<br />
example program that demonstrates the problem. Make sure that this<br />
example program is as small as you can make it, simple (and uses VTK<br />
alone), complete and demonstrates the problem adequately. Doing this<br />
will go a *long way* towards getting a quick and meaningful response.<br />
<br />
Sometimes you might not get any acceptable response. This happens<br />
bacause the others think the question has either been already answered<br />
elsewhere (the archives, FAQ and google are your friends), or believe<br />
that you have not done enough homework to warrant their attention, or<br />
they don't know the answer or simply don't have the time to answer.<br />
Please do be patient and understanding. Most questions are answered by<br />
people volunteering their time to help you.<br />
<br />
Happy posting!<br />
<br />
== Language bindings ==<br />
<br />
=== Are there bindings to languages other than Tcl? ===<br />
<br />
Aside from C++ (which it's written in) and Tcl, vtk is also bound into<br />
Java as of JDK 1.1 and Python 1.5, 1.6 and 2.X. All of the<br />
Tcl/Java/Python wrapper code is generated from some LEX and YACC code<br />
that parses our classes and extracts the required information to<br />
generate the wrapper code.<br />
<br />
=== What version of Tcl/Tk should I use with VTK? ===<br />
<br />
Currently we recommend that you use Tcl/Tk 8.2.3 with VTK. This is the<br />
best-supported version combination at this time.<br />
<br />
VTK has also been tested with Tcl/Tk 8.3.2 and works well.<br />
<br />
Tcl/Tk 8.3.4 has been tested to a limited extent but seems to have more<br />
memory leaks that Tcl 8.3.2 has.<br />
<br />
Tcl/Tk 8.4.x seems to work well with VTK too, but you might have to<br />
change a couple of configuration settings depending on the version of<br />
VTK you are using. Check the [[VTK_FAQ#Does_VTK_support_Tcl.2FTk_8.4_.3F|Does VTK support Tcl/Tk 8.4?]].<br />
<br />
=== Where can I find Python 2.x binaries? ===<br />
<br />
All of the Python binaries available on the kitware site are built for<br />
Python 1.5.2. This includes the official release VTK3.2 and the nightly<br />
builds (as at 2001-07-16).<br />
<br />
For Python 2.x binaries, you will have to compile your own from source.<br />
It is worth checking the mailing list archives for comments by others<br />
who have been through this process.<br />
<br />
There are some user-contributed binaries available at other sites. Check<br />
the mailing list archives for possible leads. Some win32 binaries for<br />
Python 2.1 are available at;<br />
<br />
http://basic.netmeg.net/godzilla/<br />
<br />
YMMV...<br />
<br />
=== Why do I get the Python error -- ValueError: method requires a VTK object? ===<br />
<br />
You just built VTK with Python support and everything went smoothly.<br />
After you install everything and try running a Python-VTK script you get<br />
a traceback with this error:<br />
<br />
ValueError: method requires a VTK object.<br />
<br />
This error occurs if you have two copies of the VTK libraries on your<br />
system. These copies need not be in your linkers path. The VTK libraries<br />
are usually built with an rpath flag (under *nix). This is necessary to<br />
be able to test the build in place. When you install VTK into another<br />
directory in your linkers path and then run a Python script the Python<br />
modules remember the old path and load the libraries in the build<br />
directory as well. This triggers the above error since the object you<br />
passed the method was instantiated from the other copy.<br />
<br />
So how do you fix it? The easiest solution is to simply delete the copy<br />
of the libraries inside your build directory or move the build directory<br />
to another place. For example, if you build the libraries in VTK/bin<br />
then move VTK/bin to VTK/bin1 or remove all the VTK/bin/*.so files. The<br />
error should no longer occur.<br />
<br />
Another way to fix the error is to turn the CMAKE_SKIP_RPATH boolean to<br />
ON in your CMakeCache.txt file and then rebuild VTK. You shouldn't have<br />
to rebuild all of VTK, just delete the libraries (*.so files) and then<br />
re-run cmake and make. The only trouble with this approach is that you<br />
cannot have BUILD_TESTING to ON when you do this.<br />
<br />
Alternatively, starting with recent VTK CVS versions (post Dec. 6, 2002)<br />
and with VTK versions greater than 4.1 (i.e. 4.2 and beyond) there is a<br />
special VTK-Python interpreter built as part of VTK called 'vtkpython'<br />
that should eliminate this problem. Simply use vtkpython in place of the<br />
usual python interpreter when you use VTK-Python scripts and the problem<br />
should not occur. This is because vtkpython uses the libraries inside<br />
the build directory.<br />
<br />
2002 by Prabhu Ramachandran<br />
<br />
=== Does VTK support Tcl/Tk 8.4 ? ===<br />
<br />
Short answer: yes, but it might require some adjustments, depending on<br />
the VTK and CMake versions you are using.<br />
<br />
# The VTK 4.x CVS nightly/development distribution supports Tcl/Tk 8.4 as long as you use a release version of CMake > 1.4.5. Since VTK 4.2 will require CMake 1.6, the next release version will support Tcl/Tk 8.4.<br />
# The VTK 4.0 release distribution does not support Tcl/Tk 8.4 out-of-the-box.<br />
<br />
In either cases, the following solutions will adress the problem. This<br />
basically involves setting two definition symbols that will make Tcl/Tk<br />
8.4 backward compatible with previous versions of Tcl/Tk (i.e. discard<br />
the "const correctness" and Tk_PhotoPutBlock compositing rule features) :<br />
<br />
a) Edit your C/C++ flags:<br />
<br />
Run your favorite CMake cache editor (i.e. CMakeSetup, or ccmake),<br />
display the advanced values and add the USE_NON_CONST and<br />
USE_COMPOSITELESS_PHOTO_PUT_BLOCK definition symbols to the end of any<br />
of the following CMake variables (if they exist): CMAKE_CXX_FLAGS,<br />
CMAKE_C_FLAGS.<br />
<br />
Example: On Unix your CMAKE_CXX_FLAGS will probably look like:<br />
<br />
-g -O2 -DUSE_NON_CONST -DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
On Windows (Microsoft MSDev nmake mode):<br />
<br />
/W3 /Zm1000 /GX /GR /YX /DUSE_NON_CONST /DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
<br />
b) or a more intrusive solution:<br />
<br />
Edit the top VTK/CMakeList.txt file and the following lines add '''at the<br />
top''' of this file:<br />
<br />
ADD_DEFINITIONS(<br />
-DUSE_NON_CONST<br />
-DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK<br />
)<br />
<br />
== Using VTK ==<br />
<br />
=== What object/filter should I use to do ??? ===<br />
<br />
Frequently when starting out with a large visualization system people<br />
are not sure what object to use to achieve a desired effect.<br />
<br />
The most up-to-date information can be found in the VTK User's Guide<br />
(http://www.kitware.com/products/vtkguide.html).<br />
<br />
Alternative sources for information are the appendix of the book which<br />
has nice one line descriptions of what the different objects do and the<br />
VTK man pages (http://www.vtk.org/doc/nightly/html/classes.html).<br />
<br />
Additionally, the VTK man pages feature a "Related" section that provide<br />
links from each class to all the examples or tests using that class<br />
(http://www.vtk.org/doc/nightly/html/pages.html). This information is<br />
also provided in each class man page under the "Tests" or "Examples"<br />
sub-section.<br />
<br />
Some useful books are listed at http://www.vtk.org/buy-books.php<br />
<br />
=== What 3D file formats can VTK import and export? ===<br />
<br />
The following table identifies the file formats that VTK can read and<br />
write. Importer and Exporter classes move full scene information into or<br />
out of VTK. Reader and Writer classes move just geometry.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! File Format !! Read !! Write<br />
|-<br />
| 3D Studio || vtk3DSImporter || <br />
|-<br />
| AVS "UCD" format || vtkAVSucdReader || <br />
|-<br />
| Movie BYU || vtkBYUReader || vtkBYUWriter<br />
|-<br />
| Renderman || || vtkRIBExporter<br />
|-<br />
| Open Inventor 2.0 || || vtkIVExporter/vtkIVWriter<br />
|-<br />
| CAD STL || vtkSTLReader || vtkSTLWriter<br />
|-<br />
| Fluent GAMBIT ASCII || vtkGAMBITReader || <br />
|-<br />
| Unigraphics Facet Files || vtkUGFacetReader || <br />
|-<br />
| Marching Cubes || vtkMCubesReader || vtkMCubesWriter<br />
|-<br />
| Wavefront OBJ || || vtkOBJExporter<br />
|-<br />
| VRML 2.0 || || vtkVRMLExporter<br />
|-<br />
| VTK Structured Grid &dagger; || vtkStructuredGridReader || vtkStructuredWriter<br />
|-<br />
| VTK Poly Data &dagger; || vtkPolyDataReader || vtkPolyDataWriter<br />
|-<br />
| PLOT3D || vtkPLOT3DReader || <br />
|-<br />
| CGM || || vtkCGMWriter<br />
|-<br />
| OBJ || vtkOBJReader || <br />
|-<br />
| Particle || vtkParticleReader || <br />
|-<br />
| PDB || vtkPDBReader || <br />
|-<br />
| PLY || vtkPLYReader || vtkPLYWriter<br />
|-<br />
| Gaussian || vtkGaussianCubeReader || <br />
|-<br />
| XYZ || vtkXYZMolReader || <br />
|-<br />
| Ensight &Dagger; || vtkGenericEnSightReader || <br />
|}<br />
<br />
&dagger; See the books [http://www.kitware.com/products/vtktextbook.html The<br />
Visualization Toolkit, An Object-Oriented Approach to 3D Graphics] or<br />
[http://www.kitware.com/products/vtkguide.html the User's Guide] for details<br />
about structured grid and poly data file formats.<br />
<br />
&Dagger; The class vtkGenericEnSightReader allows the user to read an EnSight<br />
data set without a priori knowledge of what type of EnSight data set it<br />
is (among vtkEnSight6BinaryReader, vtkEnSight6Reader,<br />
vtkEnSightGoldBinaryReader, vtkEnSightGoldReader,<br />
vtkEnSightMasterServerReader, vtkEnSightReader).<br />
<br />
For any other file format you may want to search for a converter to a<br />
known VTK file format, more info on:<br />
http://www.tech-edv.co.at/lunix/UTILlinks.html<br />
<br />
=== Why can't I find vtktcl (vtktcl.c)? ===<br />
<br />
In versions of VTK prior to 4.0 VTK Tcl scripts would require a:<br />
<br />
catch {load vtktcl} <br />
<br />
so that they could be executed directly from wish. In VTK 4.0 the<br />
correct mechanism is to use:<br />
<br />
package require vtk<br />
<br />
For people using versions earlier than 4.0, vtktcl is a shared library<br />
that is built only on the PC. Most examples used the "catch" notation so<br />
that they will work on UNIX and on the PC. On UNIX you must use the vtk<br />
executable/shell which should be in vtk/tcl/vtk.<br />
<br />
=== Problems with vtkDecimate and vtkDecimatePro ===<br />
<br />
''vtkDecimate'' and ''vtkDecimatePro'' have been tested fairly heavily so<br />
all known bugs have been removed. However, there are three situations<br />
where you can encounter weird behavior:<br />
<br />
# The mesh is not all triangles. Solution: use ''vtkTriangleFilter'' to triangulate polygons.<br />
# The mesh consists of independent triangles (i.e., not joined at vertices - no decimation occurs). Solution: use ''vtkCleanPolyData'' to link triangles.<br />
# Bad triangles are present: e.g., triangles with duplicate vertices such as (1,2,1) or (100,100,112), or (57,57,57), and so on. Solution: use ''vtkCleanPolyData''.<br />
<br />
=== How can I read DICOM files ? ===<br />
<br />
VTK does not support the DICOM protocol/format directly, although VTK is<br />
able to read 2D and 3D ''raw'' files, i.e. slices or volumes (see<br />
''vtkImageReader'', ''vtkVolumeReader'', and derived classes). Hence, one<br />
solution is to convert DICOM files to a suitable raw format.<br />
<br />
DICOM is a huge protocol, thus we would suggest you to look for any<br />
existing converters before coding your own DICOM reader. Some of them<br />
are listed in the The Medical Image Format FAQ (Part 8):<br />
http://www.dclunie.com/medical-image-faq/html/part8.html<br />
<br />
Sebastien BARRE wrote a free DICOM converter, named dicom2, that can be<br />
used to convert medical images to raw format. This tool is a command<br />
line program and does not provide any GUI at the moment.<br />
http://dicom2.barre.nom.fr/<br />
<br />
There is a special section dedicated to the VTK:<br />
http://dicom2.barre.nom.fr/how-to.html, then "Convert to raw (vtk)"<br />
<br />
The following page also provide links to several other DICOM converters:<br />
http://www.barre.nom.fr/medical/samples/index.html#links<br />
<br />
Finally in VTK 4.4 you have access to a simple vtkDICOMImageReader [http://www.vtk.org/doc/nightly/html/classvtkDICOMImageReader.html]<br />
<br />
For a more elaborate DICOM library that support compressed jpeg, go to [http://www.creatis.insa-lyon.fr/Public/Gdcm/]<br />
<br />
=== How to handle large data sets in VTK ===<br />
<br />
One of the challenges in VTK is to efficiently handle large datasets. By<br />
default VTK is tuned towards smaller datasets. For large datasets there<br />
are a couple of changes you can make that should yield a much smaller<br />
memory footprint (less swapping) and also improve rendering performance.<br />
The solution is to:<br />
<br />
# Use ReleaseDataFlag,<br />
# Turn on ImmediateModeRendering<br />
# Use triangle strips via vtkStripper<br />
# Use a different filter or mapper<br />
<br />
Each of these will be discussed below.<br />
<br />
1) Using ReleaseDataFlag<br />
<br />
By default VTK keeps a copy of all intermediate results between filters<br />
in a pipeline. For a pipeline with five filters this can result in<br />
having six copies of the data in memory at once. This can be controlled<br />
using ReleaseDataFlag and GlobalReleaseDataFlag. If ReleaseDataFlag is<br />
set to one on a data object, then once a filter has finished using that<br />
data object, it will release its memory. Likewise, if<br />
GlobalReleaseDataFlag is set on ANY data object, all data objects will<br />
release their memory once their dependent filter has finished executing.<br />
For example in Tcl and C++<br />
<br />
# Tcl<br />
vtkPolyDataReader reader<br />
[reader GetOutput] ReleaseDataFlagOn<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->GetOutput()->GlobalReleaseDataFlagOn();<br />
<br />
While turning on the ReleaseDataFlag will reduce your memory footprint,<br />
the disadvantage is that none of the intermediate results are kept in<br />
memory. So if you interactively change a parameter of a filter (such as<br />
the isosurface value), all the filters will have to re-execute to<br />
produce the new result. When the intermediate results are stored in<br />
memory, only the downstream filters would have to re-execute.<br />
<br />
One hint for good interactive performance. If only one stage of the<br />
pipeline can have its parameters changed interactively (such as the<br />
target reduction in a decimation filter), only retain the data just<br />
prior to that step (which is the default) and turn ReleaseDataFlag on<br />
for all other steps.<br />
<br />
2) Use ImmediateModeRendering<br />
<br />
By default, VTK uses OpenGL display lists which results in another copy<br />
of the data being stored in memory. For most large datasets you will be<br />
better off saving memory by not using display lists. You can turn off<br />
display lists by turning on ImmediateModeRendering. This can be<br />
controlled on a mapper by mapper basis using ImmediateModeRendering, or<br />
globally for all mappers in a process by using<br />
GlobalImmediateModeRendering. For example:<br />
<br />
# Tcl<br />
vtkPolyDataMapper mapper<br />
mapper ImmediateModeRenderingOn<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
<br />
or<br />
<br />
// C++<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->GlobalImmediateModeRenderingOn();<br />
<br />
The disadvantage to using ImmediateModeRendering is that if memory is<br />
not a problem, your rendering rates will typically be slower with<br />
ImmediateModeRendering turned on.<br />
<br />
3) Use triangle strips via vtkStripper.<br />
<br />
Most filters in VTK produce independent triangles or polygons which are<br />
not the most compact or efficient to render. To create triangle strips<br />
from polydata you can first use vtkTriangleFilter to convert any<br />
polygons to triangles (not required if you only have triangles to start<br />
with) then run it through a vtkStipper to convert the triangles into<br />
triangle strips. For example in C++<br />
<br />
vtkPolyDataReader *reader = vtkPolyDataReader::New();<br />
reader->SetFileName("yourdatafile.vtk");<br />
reader->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkTriangleFilter *tris = vtkTriangleFilter::New();<br />
tris->SetInput(reader->GetOutput());<br />
tris->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkStripper *strip = vtkStripper::New();<br />
strip->SetInput(tris->GetOutput());<br />
strip->GetOutput()->ReleaseDataFlagOn();<br />
<br />
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br />
mapper->ImmediateModeRenderingOn();<br />
mapper->SetInput(tris->GetOutput());<br />
<br />
The only disadvantage to using triangle strips is that they require time<br />
to compute, so if your data is changing every time you render, it could<br />
actually be slower.<br />
<br />
4) Use a different filter or mapper<br />
<br />
This is a tough issue. In VTK there are typically a couple of ways to<br />
solve any problem. For example an image can be rendered as a polygon for<br />
each pixel, or it can be rendered as a single polygon with a texture map<br />
on it. For almost all cases the second approach will be much faster than<br />
the first event though VTK supports both. There isn't a single good<br />
answer for how to find the best approach. If you suspect that it is<br />
running more slowly than it should, try posting to the mailing list or<br />
looking for other ways to achieve the same result.<br />
<br />
=== VTK is slow, what is wrong? ===<br />
<br />
We have heard people say that VTK is really slow. In many of these<br />
cases, changing a few parameters can make a huge difference in performance.<br />
<br />
If you find that VTK is slower than other visualization systems running<br />
the same problem first take a look at the FAQ section dealing with large<br />
data: [[VTK_FAQ#How_to_handle_large_data_sets_in_VTK|How to handle large data sets in VTK]]. Many of its suggestions<br />
will improve VTK's performance significantly for many datasets.<br />
<br />
If you still find VTK slow, please let us know and send us an example<br />
(to mailto:kitware@kitware.com). In the past there<br />
have been some filters that simply were not written to be fast. When we<br />
come across one of these we frequently can make minor changes to the<br />
filter that will make it run much more quickly. In fact many changes in<br />
the past couple years have been this type of performance improvement.<br />
<br />
=== Is VTK thread-safe ? ===<br />
<br />
The short answer is no.<br />
<br />
Many VTK sources and filters cache information and will not perform as<br />
expected when used in multiple threads. When writing a multithreaded<br />
filter, the developer has to be very careful about how she accesses data.<br />
<br />
For example, GetXXX() methods which return a pointer should only be used<br />
to read. If the pointer returned by these methods are used to change<br />
data in multiple threads (without mutex locks), the result will most<br />
probably be wrong and unpredictable. In many cases, there are<br />
alternative methods which copy the data referred by the pointer. For<br />
example:<br />
<br />
float* vtkDataArray::GetTuple(const vtkIdType i);<br />
<br />
is thread-safe only for reading whereas:<br />
<br />
void vtkDataArray::GetTuple (const vtkIdType i, float * tuple);<br />
<br />
copies the requested tuple and is thread safe even if tuple is modified<br />
afterwards (as long as the same pointer is not passed as the argument<br />
tuple simultaneously by different threads).<br />
<br />
Unfortunately, only very few methods are clearly marked as<br />
thread-(un)safe and, in many situations, the developer has to dig into<br />
the source code to figure out whether an accessor is thread safe or not.<br />
<br />
''vtkDataSet'' and most of it's sub-classes are well documented and almost<br />
all methods are marked thread-safe or not thread-safe. This might be a<br />
good place to start. Most of the filters in imaging and some filters in<br />
graphics (like ''vtkStreamer'') are good examples of how a multi-threaded<br />
filter can be written in VTK.<br />
<br />
However, if you are not interested in developing multithreaded filters<br />
but want to process some data in parallel using the same (or similar)<br />
pipeline, your job is much easier. To do this, create a different copy<br />
of the pipeline on each thread and execute them in parallel on a<br />
different piece of the data. This is best accomplished by using<br />
''vtkThreadedController'' (instead of ''vtkMultiThreader''). See the<br />
documentation of ''vtkMultiProcessController'' and ''vtkThreadedController''<br />
and the examples in the parallel directory for details on how this can<br />
be done.<br />
<br />
Also, note that most of the OpenGL libraries are not thread-safe.<br />
Therefore, if you are rendering to multiple render windows from<br />
different threads, you are likely to get in trouble, even if you have<br />
mutex locks around the render calls.<br />
<br />
=== Can I use STL with VTK? ===<br />
<br />
As of VTK version 4.2, you can use STL. However, the following policy<br />
applies.<br />
<br />
# STL is for implementation, not interface. All STL references should be contained in a .cxx class or the private section of the .h header file.<br />
# Use the PIMPL idiom to forward reference/contain STL classes in heavily used superclasses. STL is big, fat, and slow to compile so we do not want to include STL headers in any .h files that are included by most of VTK, e.g. vtkObject.h vtkSource.h etc.<br />
# Use the vtkstd:: namespace to refer to STL classes and functions.<br />
<br />
Here's an example (from vtkInterpolateVelocityField):<br />
<br />
In the .h file (the PIMPL) forward declare<br />
<br />
class vtkInterpolatedVelocityFieldDataSetsType;<br />
//<br />
class VTK_COMMON_EXPORT vtkInterpolatedVelocityField : public vtkFunctionSet<br />
{<br />
private:<br />
vtkInterpolatedVelocityFieldDataSetsType* DataSets;<br />
};<br />
<br />
In the .cxx file define the class (here deriving from the STL vector<br />
container)<br />
<br />
typedef vtkstd::vector< vtkSmartPointer<vtkDataSet> > DataSetsTypeBase;<br />
class vtkInterpolatedVelocityFieldDataSetsType: public DataSetsTypeBase<br />
{};<br />
<br />
In the .cxx file construct and destruct the class:<br />
<br />
vtkInterpolatedVelocityField::vtkInterpolatedVelocityField()<br />
{<br />
this->DataSets = new vtkInterpolatedVelocityFieldDataSetsType;<br />
}<br />
//<br />
vtkInterpolatedVelocityField::~vtkInterpolatedVelocityField()<br />
{<br />
delete this->DataSets;<br />
}<br />
<br />
And in the .cxx file use the container as you would any STL container:<br />
<br />
for ( DataSetsTypeBase::iterator i = this->DataSets->begin();<br />
i != this->DataSets->end(); ++i)<br />
{<br />
ds = i->GetPointer();<br />
....<br />
}<br />
<br />
=== What image file formats can VTK read and write? ===<br />
<br />
The following table identifies the image file formats that VTK can read<br />
and write.<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! Image File !! Read !! Write<br />
|-<br />
| Bitmap || vtkBMPReader || vtkBMPWriter<br />
|-<br />
| Digital Elevation Model (DEM) || vtkDEMReader || <br />
|-<br />
| DICOM || vtkDICOMImageReader || <br />
|-<br />
| GE Signal || vtkGESignaReader || <br />
|-<br />
| JPEG || vtkJPEGReader || vtkJPEGWriter<br />
|-<br />
| Binary UNC meta image data || vtkMetaImageReader || vtkMetaImageWriter<br />
|-<br />
| PNG || vtkPNGReader || vtkPNGWriter<br />
|-<br />
| PNM || vtkPNMReader || vtkPNMWriter<br />
|-<br />
| PostScript || vtkPostScriptWriter || <br />
|-<br />
| SLC || vtkSLCReader || <br />
|-<br />
| TIFF || vtkTIFFReader || vtkTIFFWriter<br />
|-<br />
| RAW files &dagger; || vtkImageReader, vtkVolumeReader || <br />
|}<br />
<br />
&dagger; A typical example of use is:<br />
<br />
# Image pipeline<br />
reader = vtkImageReader()<br />
reader.SetDataByteOrderToBigEndian()<br />
reader.SetDataExtent(0,511,0,511,0,511)<br />
reader.SetFilePrefix("Ser397")<br />
reader.SetFilePattern("%s/I.%03d")<br />
reader.SetDataScalarTypeToUnsignedShort()<br />
reader.SetHeaderSize(5432)<br />
<br />
=== Printing an object. ===<br />
<br />
Sometimes when debugging you need to print an object to a string, either<br />
for logging purposes, or in the case of windows applications, to a window.<br />
<br />
Here is a way to do this:<br />
<br />
std::ostringstream os;<br />
//<br />
// "SomeVTKObject" could be, for example, <br />
// declared somewhere as: vtkCamera *SomeVTKObject;<br />
//<br />
SomeVTKObject->Print(os);<br />
vtkstd::string str = os.str();<br />
//<br />
// Process the string as you want<br />
<br />
== Platform-specific questions ==<br />
<br />
=== What platforms does vtk run on? ===<br />
<br />
VTK should compile and run on most versions of Unix, Linux and Windows.<br />
It has been tested on Suns, SGIs, HPs, Alphas, RS6000s and many Windows<br />
workstations. It was also succesfully built on MacOS X.<br />
<br />
=== How do I build the examples on the PC running Windows? ===<br />
<br />
Since building the C++ examples on the PC isn't all that easy, here are<br />
some instructions from Jack McInerney.<br />
<br />
Steps for creating a VTK C++ project 8/14/96<br />
<br />
This is based on what I learned creating a project to run the Mace<br />
example. These steps allowed me to successfully built and run this example.<br />
<br />
# Create a console project (File, New, then select Console application).<br />
# Add the files of interest to the project. (e.g., Mace.cxx)<br />
# Under Build, select Update all Dependencies. A long list of .hh files will show up under dependencies<br /> For this to work, Visual C++ needs to know where to look to find the include files. In my case they are at C:\VTK\VTK12SRC\INCLUDE. To tell Visual C++ to look there, go to Tools, Options. Select the tab Directories. Under the list for Include files add: C:\VTK\VTK12SRC\INCLUDE<br />
# Compile the file Mace.cxx. This will lead to many warnings about data possibly lost as double variables are converted to float variables. These can be gotten rid of by going to Build, Settings, and select the C++ tab. Under the General catagory, set Warning Level to 1* (instead of 3).<br />
# Before linking, some additional settings must be modified. Go to Build, Settings, and select the Link tab. In the General catagory, add the libraries opengl32.lib and glaux.lib to the Object/Library Modules. Put a space between each file name. Then select the C++ tab and the Category: Code Generation. Under Use Run-Time Library, select Debug Multithreaded DLL. Select OK to exit the dialog box. The above libraries are available from Microsoft's Web site at: http://www.microsoft.com/softlib/mslfiles/Opengl95.exe or ftp://ftp.microsoft.com/softlib/mslfiles/Opengl95.exe <br /> This is a self extracting archive which contains these files. Simply place them in your windows system directory.<br />
# Link the code by selecting Build, Build MaceProject.exe. I still get one warning when I do this, but it appears to be harmless<br /><br />
<br />
When you go to run the program, it will bomb out unless it can find 2<br />
DLLs: Opengl32.dll and Glu32.dll. These need to be located either in the<br />
project directory or the C:\WINDOWS directory. These files are supplied<br />
on the vtk CD-ROM (in the vtk\bin directory).<br />
<br />
=== 64-bit System Issues ===<br />
<br />
vtk does run on the DEC Alpha but vtk binary files are not compatible<br />
between 32-bit and 64-bit systems. For portability, use the default file<br />
type, ascii, for vtkPolyDataWriter, etc. You may be able to write a<br />
binary file on a 64-bit system and read it back in.<br />
<br />
=== What size swap space should I use on a PC? ===<br />
<br />
Building vtk on the PC requires a significant amount of memory (at least<br />
when using Visual C++)... but the final product is nice and compact. To<br />
build vtk on the PC, we recommend setting the min/max swap space to at<br />
least 400MB/500MB (depending on how much RAM you have... the sum of RAM<br />
and swap space should be roughly 500+ MB).<br />
<br />
=== Are there any benchmarks of VTK and/or the hardware it runs on? ===<br />
<br />
Take a look at the "Simple Sphere Benchmark":<br />
<br />
http://www.barre.nom.fr/vtk/bench.html<br />
<br />
It is not a "real world" benchmark, but provide synthetic results<br />
comparing different hardware running VTK:<br />
<br />
http://purl.oclc.org/NET/rriv/vtk/sphere-bench<br />
<br />
=== Why is XtString undefined when using VTK+Python on Unix? ===<br />
<br />
This is a side effect of dynamic linking on (some?) Unix systems. It<br />
appears often on Linux with the Mesa libraries at least. The solution is<br />
to make sure your Mesa libraries are linked with the Xt library. One way<br />
to do this is to add "-lXt" to MESA_LIB in your user.make file.<br />
<br />
=== How do I get the Python bindings to work when building VTK with Borland C++? ===<br />
<br />
If you've built VTK with the freely downloadable Borland C++ 5.5 (or its<br />
commercial counterpart) and you're using the Python binaries from<br />
http://www.python.org/, you'll note that when you try to run a VTK<br />
Python example you get something similar to the following error message:<br />
<br />
from vtkCommonPython import * <br />
ImportError: dynamic module does not define init function<br />
(initvtkCommonPython)<br />
<br />
This is because BCC32 prepends an underscore ("_") to all exported<br />
functions, so (in this case) the vtkCommonPython.dll contains a symbol<br />
_initvtkCommonPython which Python does not find. All kits (e.g.<br />
Rendering, Filtering, Patented) will suffer from this problem.<br />
<br />
The solution is to create Borland module definition in the VTK binary<br />
(output) directory, in my case VTK/bin. You have to do this for all kits<br />
that you are planning to use in Python. Each .def file must have the<br />
same basename as the DLL, e.g. "vtkCommonPython.def" for<br />
vtkCommonPython.dll and it must be present at VTK link time. The def<br />
file contains an export alias, e.g.:<br />
<br />
EXPORTS<br />
initvtkCommonPython=_initvtkCommonPython<br />
<br />
The Borland compiler will create an underscore-less alias in the DLL<br />
file and Python will be able to load it as a module.<br />
<br />
=== How do I build Python bindings on AIX ? ===<br />
<br />
There is a problem with dynamic loading on AIX. Old AIX did not have<br />
dlopen/dlsym, but they used load mechanism. Python still reflects this.<br />
VTK is however not compatible with the old load mechanism.<br />
<br />
The following patch to Python 2.2.2 makes python use dlopen/dlsym on AIX<br />
5 or greater.<br />
<br />
http://www.vtk.org/files/misc/python_aix.diff<br />
<br />
=== How to build VTK for offscreen rendering? ===<br />
<br />
Struggled a few hours to get VTK to do offscreen rendering. I use it to<br />
batch process medical images. Without actually producing output on the<br />
screen, I still print resulting images in a report to easily review the<br />
results of an experiment.<br />
<br />
Here is how I solved this problem for VTK version 4.2.2.<br />
<br />
1. Download Mesa-4.0.4 source<br />
<br />
Modify Mesa-4.0.4/Make-config in the 'linux:' target the following vars:<br />
<br />
GL_LIB = libVTKMesaGL.so<br />
GLU_LIB = libVTKMesaGLU.so<br />
GLUT_LIB = libVTKMesaglut.so<br />
GLW_LIB = libVTKMesaGLw.so<br />
OSMESA_LIB = libOSVTKMesa.so<br />
CFLAGS = -O -g -ansi -pedantic -fPIC -ffast-math-DUSE_MGL_NAMESPACE \<br />
-D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L-D_SVID_SOURCE \<br />
-D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include"<br />
<br />
then<br />
<br />
make -f Makefile.X11 linux <br />
cp Mesa-4.0.4/lib/* /data/usr/mesa404/lib/<br />
<br />
I use 'VTKMesa' name extension to avoid conflicts with my RH9.0 libs<br />
(especially OSMesa lib in XFree!). I'm using shared libraries, because<br />
that allows me to use dynamic libs from VTK and not the vtk program<br />
itself without explicitly having to load VTKMesaGL with my app. I copied<br />
the 'VTKMesa' libs in /data/usr/mesa404/lib/, but any odd place probably<br />
will work. Avoid /usr/lib /usr/local/lib for now.<br />
<br />
2. Follow normal instructions to get a proper working vtk, then<br />
<br />
ccmake <br />
<br />
with the following options:<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
| VTK_USE_MANGLED_MESA || ON<br />
|-<br />
| MANGLED_MESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_MESA_LIBRARY || /data/usr/mesa404/lib/libVTKMesaGL.so<br />
|-<br />
| MANGLED_OSMESA_INCLUDE_DIR || /data/usr/mesa404/include<br />
|-<br />
| MANGLED_OSMESA_LIBRARY || /data/usr/mesa404/lib/libOSVTKMesa.so<br />
|-<br />
| OPENGL_xmesa_INCLUDE_DIR || /data/usr/mesa404/include<br />
|}<br />
<br />
test using /data/prog/VTK-4.2.2/Examples/MangledMesa/Tcl scripts<br />
<br />
== Changes to the VTK API ==<br />
<br />
=== Change to vtkIdList::IsId() ===<br />
<br />
vtkIdList::IsId(int id) used to return a 0 or 1 to indicate whether the<br />
specified id is in the list. Now it returns -1 if the id is not in the<br />
list; or a non-negative number indicating the position in the list.<br />
<br />
=== Changes vtkEdgeTable ===<br />
<br />
vtkEdgeTable had two changes. The constructor now takes no arguments,<br />
and you use InitEdgeInsertion() to tell the class how many points are in<br />
the dataset. Also, IsEdge(p1,p2) now returns a -1 if the edge (defined<br />
by points p1,p2) is not defined. otherwise a non-negative integer value<br />
is returned.<br />
<br />
These changes were made to support the association of attributes with<br />
edges.<br />
<br />
=== Changes between VTK 4.2 and VTK 4.4 (and how to update) ===<br />
<br />
We have removed the CVS date, revision, and the language from the<br />
copyright on all the files. This information wasn't being used much and<br />
it created extra work for developers. For example you edit vtkObject.h<br />
rebuild all of VTK, check in you change, then you must rebuild all of<br />
VTK again because commiting the header file causes it to be changed by<br />
CVS (because the revision number changed) This change will also make it<br />
easier to compare different branches of VTK since these revision number<br />
differences will no longer show up. The CVS revision number is still in<br />
the cxx file in the RevisionMacro. You don't need to make any changes to<br />
your code for this.<br />
<br />
The DataArray classes now use a templated intermediate class to share<br />
their implementation. Again there is no need for you to make changes to<br />
your code.<br />
<br />
Legacy code has been removed. Specifically none of the old style<br />
callbacks are supported and observers should be used instead. So where<br />
you used a filter->SetStartMethod(myFunc) you should do a<br />
filter->AddObserver(vtkCommand::StartEvent,myCommand) Usually this will<br />
require you to create a small class for the observer.<br />
vtkImageOpenClose3D.cxx has an example of using an observer and there<br />
are a few other examples in VTK. If you switch to using Observers your<br />
code should also work with versions of VTK from 3.2 or later since the<br />
Observers have been in VTK since VTK 3.2.<br />
<br />
Many functions that previously took or returned float now take or return<br />
double. To change your code to work with VTK 4.4 or later you can just<br />
replace float with double for the appropriate calls and variables. If<br />
you want your code to work with both old and new versions of VTK you can<br />
use vtkFloatingPointType which is defined to be double in VTK 4.4 and<br />
later and it is float in vtk 4.2.5. In versions of VTK prior to 4.2.5<br />
you can use something like:<br />
<br />
#ifndef vtkFloatingPointType<br />
#define vtkFloatingPointType vtkFloatingPointType<br />
typedef float vtkFloatingPointType;<br />
#endif<br />
<br />
at the beginning of your code. That will set it to the correct value for<br />
all versions of VTK old and new.<br />
<br />
=== Use of New() and Delete() now enforced (vs. new & delete) ===<br />
<br />
Constructors and destructors in VTK are now protected. This means you<br />
can no longer use little "new" or "delete" to create VTK instances.<br />
You'll have to use the methods ::New() and ::Delete() (as has been<br />
standard practice for some time).<br />
<br />
The reason for this is to enforce the use of New() and Delete(). Not<br />
using New() and Delete() can lead to bad mojo, mainly reference counting<br />
problems or not taking advantage of special procedures incorporated into<br />
the New() method (e.g., selecting the appropriate hardware interface<br />
during instance creation time).<br />
<br />
If you've used New() and Delete() in your code, these changes will not<br />
affect you at all. If you're using little "new" or "delete", your code<br />
will no longer and compile and you'll have to switch to New() and Delete().<br />
<br />
=== Changes between VTK 4.4 and VTK 4.6 ===<br />
<br />
Collection Changes<br />
<br />
Collections have had some small changes (originally started by Chris<br />
Volpe) to better support reentrant iteration. Specifically all the<br />
collection have an InitTraversal(sit) and GetNextFoobar(sit) methods.<br />
(where Foobar is what the collection contains, for example<br />
GetNextActor(sit)) The argument to both of these methods is a<br />
vtkCollectionSimpleIterator. Most of the collection use in VTK has been<br />
modified to use these new methods. The advantage is that these new<br />
methods support having the same collection be iterated through in a<br />
reentrant safe manner. In the past this was not true and led to a number<br />
of problems. In the future for C++ class development please use this<br />
approach to iterating through a collection. These changes are fully<br />
backwards compatible and no old APIs were harmed in the making of these<br />
changes. So in summary, for the future, where you would have written:<br />
<br />
for (actors->InitTraversal();<br />
(actor = actors->GetNextActor());)<br />
<br />
you would now have:<br />
<br />
vtkCollectionSimpleIterator actorIt;<br />
for (actors->InitTraversal(actorIt);<br />
(actor = actors->GetNextActor(actorIt));)<br />
<br />
=== Changes in VTK between 3.2 and 4.0 ===<br />
<br />
* Changes to vtkDataSetAttributes, vtkFieldData and vtkDataArray: All attributes (scalars, vectors...) are now stored in the field data as vtkDataArray's. vtkDataSetAttributes became a sub-class of vtkFieldData. For backwards compatibility, the interface which allows setting/getting the attributes the old way (by passing in a sub-class of vtkAttributeData such as vtkScalars) is still supported but it will be removed in the future. Therefore, the developers should use the new interface which requires passing in a vtkDataArray to set an attribute. vtkAttributeData and it's sub-classes (vtkScalars, vtkVectors...) will be deprectated in the near future; developers should use vtkDataArray and it's sub-classes instead. We are in the process of removing the use of these classes from vtk filters.<br />
<br />
* Subclasses of vtkAttributeData (vtkScalars, vtkVectors, vtkNormals, vtkTCoords, vtkTensors) were removed. As of VTK 4.0, vtkDataArray and it's sub-classes should be used to represent attributes and fields. Detailed description of the changes and utilities for upgrading from 3.2 to 4.0 can be found in the package: http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
* Added special methods to data arrays to replace methods like<br />
<br />
tc SetTCoord i x y 0<br />
<br />
or<br />
<br />
vc SetVector i vx vy vz<br />
<br />
in interpreted languages (Tcl, Python, Java). Use:<br />
<br />
tc SetTuple2 i x y<br />
<br />
or<br />
<br />
vc SetTuple3 i vx vy vz<br />
<br />
* Improved support for parallel visualization: vtkMultiProcessController and it's sub-classes have been re-structured and mostly re-written. The functionality of vtkMultiProcessController have been re-distributed between vtkMultiProcessController and vtkCommunicator. vtkCommunicator is responsible of sending/receiving messages whereas vtkMultiProcessController (and it's subclasses) is responsible of program flow/control (for example processing rmi's). New classes have been added to the Parallel directory. These include vtkCommunicator, vtkMPIGroup, vtkMPICommunicator, vtkSharedMemoryCommunicator, vtkMPIEventLog... There is now a tcl interpreter which supports parallel scripts. It is called pvtk and can be build on Windows and Unix. Examples for both Tcl and C++ can be found in the examples directories.<br />
<br />
* vtkSocketCommunicator and vtkSocketController have been added. These support message passing via BSD sockets. Best used together with input-output ports.<br />
<br />
* Since it was causing very long compile times (it essentially includes every vtk header file) and it was hard to maintain (you had to add a line whenever you added a class to VTK) vtk.h was removed. You will have to identify the header files needed by your application and include them one by one.<br />
<br />
* vtkIterativeClosestPointTransform has been added. This class is an implementation of the ICP algorithm. It matches two surfaces using the iterative closest point (ICP) algorithm. The core of the algorithm is to match each vertex in one surface with the closest surface point on the other, then apply the transformation that modify one surface to best match the other (in a least square sense).<br />
<br />
* The SetFileName, SaveImageAsPPM and related methods in vtkRenderWindow have been removed. vtkWindowToImageFilter combined with any of the image writers provides greater functionality.<br />
<br />
* Support for reading and writing PGM and JPEG images has been included.<br />
<br />
* Methods with parameters of the form "type param[n]" are wrapped. Previously, these methods were only wrapped if the array was declared 'const'. The python wrappers will allow values to be returned in the array.<br />
<br />
* The directory structure was completely reorganized. There are now subdirectories for Common (core common classes) Filtering (superclasses for filtering operations) Imaging (filters and sources that produce images or structured points) Graphics (filters or sources that produce data types other than ImageData and StructuredPoints) IO (file IO classes that do not require Rendering support) Rendering (all actors mappers annotation and rendering classes) Hybrid (typically filters and sources that require support from Rendering or both Imagign and Graphics) Parallel (parallel visualization support classes) Patented (patented classes) Examples (documented examples) Wrapping (support for the language wrappers). In many directories you will see a Testing subdirectory. The Testing subdirectories contain tests used to validate VTKs operation. Some tests may be useful as examples but they are not well documented.<br />
<br />
* The Build process for VTK now uses CMake (found at www.cmake.org) This replaces pcmaker on windows and configure on UNIX. This resolves some longstanding problems and limitation we were having with pcmaker and configure, and unifies the build process into one place.<br />
<br />
=== Changes to VTK between 4.0 and 4.2 ===<br />
<br />
* Use of macros to support serialization, standardize the New method, and provide the Superclass typedef.<br />
<br />
* Subclassing of VTK classes in the python wrappers (virtual method hooks are not provided).<br />
<br />
* vtkImageWindow, vtkImager, vtkTkImageWindowWidget and their subclasses have been removed to reduce duplicated code and enable interation in ImageWindows. Now people should use vtkRenderer and vtkRenderWindow instead. vtkImageViewer still works as a turn key image viewing class although it now uses vtkRenderWindow and vtkRenderer internally instead of vtkImageWindow and vtkImager.<br />
<br />
* New class: vtkBandedPolyDataContourFilter. Creates solid colored bands (like you find on maps) of scalar value.<br />
<br />
* Event processing: Several new events to VTK were added (see vtkCommand.h). Also event processing can now be prioritized and aborted. This allows applications to manage who processes which events, and terminates the processing of a particular event if desired.<br />
<br />
* 3D Widgets: A new class vtkInteractorObserver was added to observe events on vtkRenderWindowInteractor. Using the new event processing infrastructure, multiple 3D widgets (subclasses of vtkInteractorObserver) can be used simultaneously to process interactions. Several new 3D widgets have been added including:<br />
** vtkLineWidget<br />
** vtkPlaneWidget<br />
** vtkImagePlaneWidget<br />
** vtkBoxWidget<br />
** vtkSphereWidget<br />
<br />
* Besides providing a representation, widgets also provide auxiliary functionality such as providing transforms, implicit functions, plane normals, sphere radius and center, etc.<br />
<br />
* New class: vtkInstantiator provides a means by which one can create an instance of a VTK class using only the name of the class as a string.<br />
<br />
* New class: vtkXMLParser provides a wrapper around the Expat XML parsing library. A new parser can be written by subclassing from vtkXMLParser and providing a few simple virtual method implementations.<br />
<br />
* TIFF reader is now implemented using libtiff, which makes it capable of reading almost all available TIFF formats. The libtiff is also available internally as vtktiff.<br />
<br />
* New method (all sub-classes of vtkObject): Added a virtual function called NewInstance to vtkTypeMacro. NewInstance creates and returns an object of the same type as the current one. It does not copy any properties. The returned pointer is of the same type as the pointer the method was invoked with. This method should replace all the MakeObject methods scattered through VTK.<br />
<br />
* vtkSetObject macro is depricated for use inside the VTK. It is still a valid construct in projects that use VTK. Instead use vtkCxxSetObjectMacro which does the same thing.<br />
<br />
* vtkPLOT3DReader have been improved. It now supports:<br />
** multigrid (each block is one output)<br />
** ascii<br />
** fortran-style byte counts<br />
** little/big endian<br />
** i-blanking (partial)<br />
<br />
* A new vtkTextProperty class has been created, and duplicated text API s have been obsoleted accordingly. Check the<br />
[[VTK_FAQ#Text_properties_in_VTK_4.2|Text properties in VTK 4.2]] FAQ entry for a full description of the change.<br />
<br />
=== How do I upgrade my existing C++ code from 3.2 to 4.x? ===<br />
<br />
This is (a corrected version of) an email that was posted to vtkusers.<br />
Please feel free to correct or add anything.<br />
<br />
{| cellspacing="3" <br />
|- valign="top"<br />
|width="55%" bgcolor="#f0f0ff" style="border:1px solid #ffc9c9;padding:1em;padding-top:0.5em;"|<br />
<br />
I've just ported my medium-sized (40K lines) application from vtk3.2 to<br />
vtk4.x. I thought I would share my experiences with you, in case there<br />
were people out there contemplating it but a bit scared.<br />
<br />
One source of information for upgrading code is:<br />
<br />
http://www.vtk.org/files/misc/Upgrading.zip<br />
<br />
I'm using VC++6 + MFC on Win2K and was unable/unwilling to run the<br />
script in the zip file.<br />
<br />
So,<br />
<br />
I switched all my include directories to the new VTK ones and<br />
recompiled. 337 errors, not unexpectedly. Most concerned vtkScalars and<br />
vtkTCoords which have both been removed. Where I was using single value<br />
scalars, like this:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetNumberOfScalars(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetScalar(i,2.3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *scalars = vtkFloatArray::New();<br />
scalars->SetNumberOfComponents(1);<br />
scalars->SetNumberOfTuples(N_POINTS);<br />
...<br />
polydata->GetPointData()->SetScalars(scalars);<br />
...<br />
scalars->SetTuple1(i,2.3);<br />
...<br />
<br />
OK so far, far fewer errors.<br />
<br />
Where I had 2D texture coordinates:<br />
<br />
vtkTCoords *tcoords = vtkTCoords::New();<br />
tcoords->SetNumberOfTCoords(N);<br />
...<br />
float p[3];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTCoord(i,p);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkFloatArray *tcoords = vtkFloatArray::New();<br />
tcoords->SetNumberOfComponents(2);<br />
tcoords->SetNumberOfTuples(N);<br />
...<br />
float p[2];<br />
p[0]=x; p[1]=y;<br />
tcoords->SetTuple(i,p);<br />
....<br />
<br />
All well and good, still fewer errors. Make sure you call<br />
SetNumberOfComponents *before* SetNumberOfTuples else you'll get<br />
problems (I did!).<br />
<br />
Where I was creating 0-255 image data and had been using:<br />
<br />
vtkScalars* scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
...<br />
<br />
Going well!<br />
<br />
When creating RGB images, I had been using:<br />
<br />
vtkScalars *scalars = vtkScalars::New();<br />
scalars->SetDataTypeToUnsignedChar();<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfScalars(X*Y);<br />
...<br />
scalars->SetActiveComponent(0);<br />
scalars->SetScalar(i,val1);<br />
scalars->SetActiveComponent(1);<br />
scalars->SetScalar(i,val2);<br />
scalars->SetActiveComponent(2);<br />
scalars->SetScalar(i,val3);<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkUnsignedCharArray *scalars = vtkUnsignedCharArray::New()<br />
scalars->SetNumberOfComponents(3);<br />
scalars->SetNumberOfTuples(X*Y);<br />
...<br />
scalars->SetComponent(i,0,val1);<br />
scalars->SetComponent(i,1,val2);<br />
scalars->SetComponent(i,2,val3);<br />
...<br />
<br />
My remaining errors concerned vtkWin32OffscreenRenderWindow that has<br />
been removed. Where I had been using:<br />
<br />
vtkWin32OffscreenRenderWindow *offscreen = vtkWin32OffscreenRenderWindow::New();<br />
...<br />
<br />
I replaced with:<br />
<br />
vtkWin32OpenGLRenderWindow *offscreen = vtkWin32OpenGLRenderWindow::New();<br />
offscreen->SetOffScreenRendering(1);<br />
...<br />
<br />
All done. I'd had to throw in some #include "vtkFloatArray.h" and things<br />
like that of course. Zero compile errors.<br />
<br />
Had to remember to link against the new vtk lib files, so I removed<br />
<br />
vtkdll.lib <br />
<br />
and added<br />
<br />
vtkCommon.lib<br />
vtkGraphics.lib<br />
<br />
etc.<br />
<br />
Zero link errors. My program is up and running again, no apparant<br />
problems. Plus now I can use all the new features of vtk4. (And I'm sure<br />
it's faster but maybe that's my imagination.)<br />
<br />
All this took me about three hours.<br />
<br />
Bye!<br />
<br />
Tim.<br />
|}<br />
<br />
=== What is the release schedule for VTK ===<br />
<br />
VTK has a formal release every eight to sixteen months. VTK 4.0 was cut<br />
in December of 2001 and released in March 2002. VTK 4.2 was releaseed in<br />
February of 2003. The next version of VTK will probably be released in<br />
late 2003 or early 2004.<br />
<br />
=== Roadmap: What changes are being considered for VTK ===<br />
<br />
This is a list of changes that are being considered for inclusion into<br />
VTK. Some of these changes will happen while other changes we would like<br />
to see happen but may not due to funding or time issues. For each change<br />
we try to list what the change is, when we hope to complete it, if it is<br />
actively being developed. Detailed discussion on changes is limited to<br />
the vtk-developers mailing list.<br />
<br />
# Modify existing image filters to use the new vtkImageIterator etc. Most simple filters have been modified to use ithe iterator in VTK 4.2. It would be nice to have some sort of efficient neighborhood iterators but so far we haven't come up with any.<br />
# Update vtkCollections to support an iterator. Currently vtkCollections do not work well because they store state for the current item. So two methods cannot work on the same collection in the same stack trace using the GetNextItem() interface. An iterator of some sort should be used instead. No one is working on this yet.<br />
# Support for AMR (mulit-res grids see http://seesar.lbl.gov/AMR/Overview/ for an overview)<br />
# Improvements to the pipeline update mechanism including support for multiresolution<br />
# Possible support for multi-block and composite grids<br />
# Rework the polydata and unstructured grid structures (vtkMesh ??). Related ideas include:<br />
#* Make UnstructuredGrid more compact by removing the cell point count from the vtkCellArray. This will reduce the storage required by each cell by 4 bytes.<br />
#* Make vtkPolyData an empty subclass of vtkUnstructuredGrid. There are a number of good reasons for this but it is a tricky task and backwards compatibility needs to be maintained.<br />
# More parallel support, including parallel compositing algorithms<br />
# Algorithms like LIC (http://www-courses.cs.uiuc.edu/~cs419/lic.pdf), maybe a couple terrain-decimation algorithms<br />
# Further integration of STL and other important C++ constructs (like templates)<br />
# Unstructured grid volume rendering<br />
<br />
VTK 4.4 (intermediate release, end of 2003)<br />
<br />
* convert APIs to double<br />
* remove old callbacks<br />
* blanking<br />
* ref count observers (done)<br />
* switch collections to use iterators<br />
* improve copyright (done)<br />
<br />
VTK 5.0 (major release, end of August 2004)<br />
<br />
* new pipeline mechanism (see [[Media:Pipeline.pdf|Pipeline.pdf]])<br />
* time support<br />
* true AMR support<br />
<br />
=== Changes to Interactors ===<br />
<br />
The Interactors have been updated to use the Command/Observer events of<br />
vtk. The vtkRenderWindowInteractor now has ivars for all the event<br />
information. There is a new class called<br />
vtkGenericRenderWindowInteractor that can be used to set up the bindings<br />
from other languages like python, Java or TCl.<br />
<br />
A new class vtkInteractorObserver was also added. It has a<br />
SetInteractor() method. It observes the keypress and delete events<br />
invoked by the render window interactor. The keypress activation value<br />
for a widget is now 'i' (although this can be programmed).<br />
vtkInteractorObserver has the state ivar Enabled. All subclasses must<br />
have the SetEnabled(int) method. Convenience methods like On(), Off(),<br />
EnabledOn(), and EnabledOff() are available. The state of the interactor<br />
observer is obtained using GetEnabled(). The SetEnabled(1) method adds<br />
observers to watch the interactor (appropriate to the particular<br />
interactor observer) ; SetEnabled(0) removes the observers . There are<br />
two new events: EnableEvent and DisableEvent which are invoked by the<br />
SetEnabled() method.<br />
<br />
The events also support the idea of priority now. When you add an<br />
observer, you can specify a priority from 0 to 1. Higher values will be<br />
called back first. An observer can also tell the object not to call any<br />
more observers. This way you can handle an event, and stop further<br />
processing. In this way you can add handlers to InteractorStyles without<br />
sub-classing and from wrapped languages.<br />
<br />
For more information see: vtkGenericRenderWindowInteractor,<br />
vtkRenderWindowInteractor, vtkInteractorObserver.<br />
<br />
=== Header files and vtkSetObjectMacro ===<br />
<br />
On some platforms such as MS Visual Studio .NET, compiler is not capable<br />
of handling too big input files. Some VTK files with all includes do<br />
become big enough to overwhelm the compiler. The solution is to minimize<br />
the amount of includes. This especially goes for header files, because<br />
they propagate to other files. Every class header file should include<br />
only the parent class header file. If there is no other alternative, you<br />
should put a comment next to include file explaining why the file has to<br />
be included.<br />
<br />
The related issue is with vtkSetObjectMacro. This file calles some<br />
methods on an argument class, which implies that the argument class<br />
header file has to be included. The result is bloat on the header files.<br />
The solution is to not use vtkSetObjectMacro but vtkCxxSetObjectMacro.<br />
The difference is that vtkCxxSetObjectMacro goes in the Cxx file and not<br />
in the header file.<br />
<br />
Example: Instead of<br />
<br />
#include "vtkBar.h"<br />
class vtkFoo : public vtkObject<br />
{ ...<br />
vtkSetObjectMacro(Bar, vtkBar);<br />
...<br />
};<br />
<br />
Do:<br />
<br />
class vtkBar;<br />
class vtkFoo : public vtkObject<br />
{<br />
...<br />
virtual void SetBar(vtkBar*);<br />
...<br />
};<br />
<br />
and add the following line to vtkFoo.cxx<br />
<br />
vtkCxxSetObjectMacro(vtkFoo,Bar,vtkBar);<br />
<br />
=== Text properties in VTK 4.2 ===<br />
<br />
A new<br />
[http://public.kitware.com/VTK/doc/nightly/html/classvtkTextProperty.html vtkTextProperty]<br />
class has been added to VTK 4.2.<br />
<br />
This class factorizes text attributes that used to be spread out and<br />
duplicated in many different classes (mostly 2D actors and text<br />
mappers). Among those attributes, font family, font size,<br />
bold/italic/shadow properties, horizontal and vertical justification,<br />
line spacing and offset have been retained, whereas new attributes like<br />
color and opacity have been introduced.<br />
<br />
We tried to make sure that you can use a vtkTextProperty to modify text<br />
properties in the same way a vtkProperty can be used to modify the<br />
surface properties of a geometric object. In that regard, you should be<br />
able to share a vtkTextProperty between different actors or assign the<br />
same vtkTextProperty to an actor that offers multiple vtkTextProperty<br />
attributes ([http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlot]<br />
for example).<br />
<br />
Here is a quick example:<br />
<br />
vtkTextActor *actor0 = vtkTextActor::New();<br />
actor0->GetTextProperty()->SetItalic(1);<br />
//<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
//<br />
vtkTextActor *actor1 = vtkTextActor::New();<br />
actor1->SetTextProperty(tprop);<br />
//<br />
vtkTextActor *actor2 = vtkTextActor::New();<br />
actor2->SetTextProperty(tprop);<br />
<br />
*Backward compatibility issues*:<br />
<br />
1) Color and Opacity:<br />
<br />
The text color and text opacity settings are now controlled by the<br />
vtkTextProperty Color and Opacity attributes instead of the<br />
corresponding actor's color and opacity attributes. In the following<br />
example, those settings were controlled by the attributes of the<br />
vtkProperty2D attached to the vtkActor2D (vtkTextActor). The<br />
vtkTextProperty attributes should be used instead:<br />
<br />
vtkTextActor *actor = vtkActor::New();<br />
actor->GetProperty()->SetColor(...);<br />
actor->GetProperty()->SetOpacity(...);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetColor(...);<br />
actor->GetTextProperty()->SetOpacity(...);<br />
<br />
To make migration easier for a while, we have set the vtkTextProperty<br />
default color to ''(-1.0, -1.0, -1.0)'' and the default opacity to ''-1.0''.<br />
These "magic" values are checked by the underlying text mappers at<br />
rendering time. If they are found, the color and opacity of the 2D<br />
actor's vtkProperty2D are used, just as it was in VTK 4.1.<br />
<br />
2) API (i.e. SetBold(), SetItalic(), etc)<br />
<br />
Most of the VTK classes involving text used to provide their own text<br />
attributes like Bold, Italic, Shadow, FontFamily. Thus, each of those<br />
classes would duplicate the vtkTextMapper API through methods like<br />
SetItalic(), SetBold(), SetFontFamily(), etc.<br />
<br />
Moreover, if one class had different text elements (say, for example,<br />
the title and the labels of a scalar bar), there was no way to modify<br />
the text properties of these elements separately.<br />
<br />
The vtkTextProperty class has been created to address both issues, by<br />
obsoleting those duplicated attributes and methods and providing a<br />
unified way to access text properties, and by allowing each class to<br />
associate different vtkTextProperty to different text elements.<br />
<br />
Migrating your code basically involves using the old API on your actor's<br />
vtkTextProperty instead of the actor itself. For example:<br />
<br />
actor->SetBold(1);<br />
<br />
becomes:<br />
<br />
actor->GetTextProperty()->SetBold(1);<br />
<br />
When a class provides different vtkTextProperty for different text<br />
elements, the TextProperty attribute is usually prefixed with that<br />
element type. Example: AxisTitleTextProperty, or AxisLabelTextProperty.<br />
This allows you to set different aspect for each text elements. If you<br />
want to use the same properties, you can either set the same values on<br />
each vtkTextProperty, or make both vtkTextProperty point to the same<br />
vtkTextProperty object. Example:<br />
<br />
actor->GetAxisLabelTextProperty()->SetBold(1);<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
or:<br />
<br />
vtkTextProperty *tprop = vtkTextProperty::New();<br />
tprop->SetBold(1);<br />
actor->SetAxisLabelTextProperty(tprop);<br />
actor->SetAxisTitleTextProperty(tprop);<br />
<br />
or:<br />
<br />
actor->SetAxisLabelTextProperty(actor->GetAxisTitleTextProperty());<br />
actor->GetAxisTitleTextProperty()->SetBold(1);<br />
<br />
The following list specifies the name of the text properties used in the<br />
VTK classes involving text.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html vtkTextMapper]:<br />
* you can still use the vtkTextMapper + vtkActor2D combination, but we would advise you to use a single vtkTextActor instead, this will give you maximum flexibility.<br />
* has 1 text prop: TextProperty, but although you have access to it, do not twwak it unless you are using vtkTextMapper with a vtkActor2D. In all other cases, use the text prop provided by the actor (see below).<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkTextActor.html vtkTextActor]:<br />
* has 1 text prop: TextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLabeledDataMapper.html vtkLabeledDataMapper]:<br />
* has 1 text prop: LabelTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCaptionActor2D.html vtkCaptionActor2D]:<br />
* has 1 text prop: CaptionTextProperty. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkLegendBoxActor.html vtkLegendBoxActor]:<br />
* has 1 text prop: EntryTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkAxisActor2D.html vtkAxisActor2D],<br />
[http://www.vtk.org/doc/nightly/html/classvtkParallelCoordinatesActor.html vtkParallelCoordinatesActor], and<br />
[http://www.vtk.org/doc/nightly/html/classvtkScalarBarActor.html vtkScalarBarActor]:<br />
* have 2 text props: TitleTextProperty, LabelTextProperty.<br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkXYPlotActor.html vtkXYPlotActor]:<br />
* has 3 text prop: TitleTextProperty (plot title), AxisTitleTextProperty, AxisLabelTextProperty (title and labels of all axes)<br />
* the legend box text prop (i.e. entry text prop) can be retrieved through actor->GetLegendBoxActor()->GetEntryTextProperty()<br />
* the X (or Y) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/YAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched. <br />
<br />
[http://www.vtk.org/doc/nightly/html/classvtkCubeAxesActor2D.html vtkCubeAxesActor2D]:<br />
* has 2 text props: AxisTitleTextProperty, AxisLabelTextProperty (title and label of all axes)<br />
* the X (Y or Z) axis text props (i.e. title and label text props) can be retrieved through actor->GetX/Y/ZAxisActor2D->GetTitle/LabelTextProperty(), and will override the corresponding AxisTitleTextProperty or AxisLabelTextProperty props as long as they remain untouched.<br />
<br />
=== Forward declaration in VTK 4.x ===<br />
<br />
Since VTK 4.x all classes have been carefully inspected to only include the necessesary headers, and do what is called 'forward declaration' for all other needed classes. Thus, when you compile your projects using a filter that takes as input a dataset and you are passing an imagedata: you need to explicitely include imagedata within your implementation file. This is true for all data types.<br />
<br />
For example, if you get this error:<br />
<br />
no matching function for call to `vtkContourFilter::SetInput(vtkImageData*)'<br />
VTK/Filtering/vtkDataSetToPolyDataFilter.h:44:<br />
candidates are: virtual void vtkDataSetToPolyDataFilter::SetInput(vtkDataSet*)<br />
<br />
This means you need to add in your code : #include "vtkImageData.h"<br />
<br />
== Miscellaneous questions ==<br />
<br />
=== What are the legal issues? ===<br />
<br />
The Visualization Toolkit software is provided under the following<br />
copyright. We think it's pretty reasonable. We do restrict the<br />
distribution of modified code. This is primarily a revision control<br />
issue. We don't want a bunch of renegade vtks running around without us<br />
having some idea why the changes were made and giving us a chance to<br />
incorporate them into the general release.<br />
<br />
Copyright &copy; 1993-2004 Ken Martin, Will Schroeder, Bill Lorensen All<br />
rights reserved.<br />
<br />
Redistribution and use in source and binary forms, with or without<br />
modification, are permitted provided that the following conditions are met:<br />
<br />
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.<br />
<br />
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.<br />
<br />
* Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.<br />
<br />
* Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software.<br />
<br />
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS<br />
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED<br />
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br />
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR<br />
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br />
<br />
=== Can't you split up the data file? ===<br />
<br />
The data is now in one file that is about 15 Megabytes. This is smaller<br />
than the original data files VTK used and we hope that this size is not<br />
a problem for people anymore. If it is please let us know.<br />
<br />
=== Do you have any shared library tips? ===<br />
<br />
VTK version 4.0 and later supports both shared and static libraries on<br />
most all platforms. For development we typically use shared libraries<br />
since they are faster to link when making small changes. You can control<br />
how VTK builds by setting the BUILD_SHARED_LIBS option in CMake.<br />
<br />
=== What is the deal with the patents ===<br />
<br />
As the copyright mentions there are some patents used in VTK. If you use<br />
any code in the Patented/ directory for commercial application you<br />
should contact the patent holder and obtain a license.<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by General Electric Company: vtkDecimate, vtkMarchingCubes,<br />
vtkMarchingSquares, vtkDividingCubes, vtkSliceCubes and vtkSweptSurface.<br />
The GE contact is:<br />
<br />
Carl B. Horton<br />
Sr. Counsel, Intellectual Property<br />
3000 N. Grandview Blvd., W-710<br />
Waukesha, WI 53188<br />
Phone: (262) 513-4022<br />
E-Mail: mailto:Carl.Horton@med.ge.com<br />
<br />
As of VTK4.0 the following classes are known to use algorithms patented<br />
by Kitware, Inc.: vtkGridSynchronizedTemplates3D,<br />
vtkKitwareContourFilter.h, vtkSynchronizedTemplates2D, and<br />
vtkSynchronizedTemplates3D. The Kitware contact is:<br />
<br />
Ken Martin<br />
Kitware<br />
469 Clifton Corporate Parkway,<br />
Clifton Park, NY 12065<br />
Phone:1-518-371-3971<br />
E-Mail: mailto:kitware@kitware.com</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=1004VTK Mouse Picking2004-08-24T17:21:40Z<p>Goodwin: </p>
<hr />
<div>The default way to pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to turn mouse picking on/off and to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... here's the link [http://www.vtk.org/Bug/bug.php?op=show&bugid=1054&pos=3 Bug submission]. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
'''To perform a pick in the example below: move the cursor to the position in the render window you want to pick, then press and release the left mouse button without moving the mouse in between'''. This may seem tricky at first but you'll get used to it!<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Scripts&diff=243VTK Scripts2004-08-17T15:06:06Z<p>Goodwin: /* Tcl */</p>
<hr />
<div>Have you written nifty Tcl/Tk, Java or Python scripts ? Many of us have built scripts and programs that might benefit VTK users. Here are some of them, and I'm quite sure that you also have developped interesting stuff : be part of the VTK swiss-knife !<br />
<br />
== Tcl ==<br />
<br />
[http://brighton.ncsa.uiuc.edu/prajlich/vtkPipeline/ VTK pipeline browser]<br />
<br />
''(P. Rajlich, NCSA)''<br />
"I took the tree widget for Tk by R. Hipp and turned it into a VTK pipeline browser. Combined with the vtkShow script by C. Odet, it allows you to browse and modify the objects in your VTK pipeline".<br />
<br />
[3D VTK pipeline browser] (disappeared, author should contact me)<br />
<br />
''(D. Pont)''<br />
"This 3D pipeline browser is derived from the 2D pipeline browser developed by P. Rajlich, and uses vtkShow developed by C. Odet. Your VTK pipeline is visualised as a 3D tree using VTK. The browser creates its own window. Pre-defined icons are used to represent the different types of objects such as: data sources, filters, actors, and mappers. The icons are connected with tubes to represent the flow of data [...]. Objects with multiple inputs and outputs are handled. If the *animation* feature is selected the icons are highlighted with a translucent sphere and labeled in the order they execute in your pipeline. [...]."<br />
<br />
[http://www-sop.inria.fr/caiman/personnel/Robert.Riviere/vtk/reflect.html VTK Reflector (object browser)]<br />
<br />
''(R. Rivière, INRIA)''<br />
"Here is VTK Reflector, a small tool using TCL and VTK reflection properties. With reflector, you can browse among VTK objects you have created, display their contents and known methods names, and apply them. "<br />
<br />
[http://www.barre.nom.fr/vtk/bench.html VTK Sphere Benchmark]<br />
<br />
''(R. Rivière, S. Barré, INRIA, UTC)''<br />
"The VTK Sphere Benchmark is a simple platform-independent Tcl/Tk graphics performance test using VTK library. It is small with no (or little) version requirements. It is designed to get a rough idea of the capabilities and efficiency of your system by displaying a 3D object and computing an estimation of the average throughput in polygons/s. Different rendering options might be used, and automation is provided to try the same bench at varying 3D complexity. A final report may be sent to us and all results are saved to a database for further comparisons."<br />
<br />
[http://fzs05.ms.tu-berlin.de/%7Erunarko/ melati a little tool for visualization ]<br />
<br />
''(J. Runarko)''<br />
"Melati is a script written with TclTk and the Visualization Toolkit. It is written on my old Linux box at home. It's purpose is to give the user the ability to view calculated data from Tochnog a FEA program written by Dennis Roddeman.<br />
<br />
[isoViewer]<br />
<br />
''(K. Eschenberg)''<br />
Two programs have been created for using isosurfaces to view structured data fields. The program "iso" reads a file of time-varying structured data (TSD) then uses VTK to generate isosurfaces for each time. The results are written to a file which can then be read and displayed with the program "chap2".<br />
<br />
[[VTK Mouse Picking]]<br />
<br />
The default way pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button... a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor. --[[User:Goodwin|Goodwin]] 11:06, 17 Aug 2004 (EDT)<br />
<br />
== Python ==<br />
<br />
<br />
[http://mayavi.sourceforge.net/vtkPipeline/ Python vtkPipeline browser]<br />
<br />
''(P. Ramachandran)''<br />
"Python modules that provide a VTK pipeline browser using Tkinter. All the objects in the pipeline can be configured".<br />
<br />
== Perl ==<br />
<br />
<br />
[http://www.math.umd.edu/%7Erdl/PerlVTK/ PerlVTK]<br />
<br />
''(R. De Leo)''<br />
"PerlVTK is a Perl module that allows you to call VTK functions from Perl".</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=ITK/FAQ&diff=159ITK/FAQ2004-08-17T02:01:37Z<p>Goodwin: Resolved recommended FLTK version</p>
<hr />
<div>== General information and availability ==<br />
=== Do I need FLTK to build ITK ? ===<br />
No,<br />
<br />
ITK does not require FLTK. FLTK is only used in particular demo applications in the InsightApplications directory.<br />
<br />
ITK does not provide any GUI functionality. When building full applications, the GUI is provided by other libraries such as Qt (http://www.trolltech.com/products/qt/index.html), FLTK (http://www.fltk.org/) Gtk+ (http://www.gtk.org/) or wxWidgets (http://www.wxwidgets.org/, which used to be called wxWindows).<br />
<br />
If you want to build the demo applications that require FLTK, you must install FLTK in your system. The recommended version is 1.1.4 that can be obtained from ftp.fltk.org and from the "RelatedSoftware" page in www.itk.org.<br />
<br />
Once FLTK is installed in your system, you will have to enable the USE_FLTK option when you run CMake to configure ITK.<br />
<br />
=== Do I need VTK to build ITK ? ===<br />
No,<br />
<br />
ITK does not require VTK.<br />
<br />
VTK is only used by specific demo applications in the Insight/Applications directory. These applications will simply not be build if VTK is not available in your system.<br />
<br />
ITK does not provide any visualization functionalities. Applications requiring visualization should implement those functionalities from internal code or libraries like OpenGL, GLUT or VTK.<br />
<br />
In order to use ITK with VTK you must build VTK from sources and make sure that it is configured with the flag USE_ANSI_STDLIB enabled.<br />
<br />
Then you have to reconfigure ITK making sure that the option USE_VTK is enabled.<br />
<br />
=== Do I need GLUT/OpenGL to build ITK ===<br />
No,<br />
<br />
ITK does not depend on GLUT not OpenGL.<br />
<br />
GLUT and OpenGL are only used by specific demo applications in the Insight/Applications directory.<br />
<br />
ITK does not provide any visualization functionalities. Applications requiring visualization should obtain these services from external libraries like OpenGL, GLUT or VTK.<br />
<br />
=== Do I need Tcl to build ITK ===<br />
No,<br />
<br />
ITK does not depend on Tcl.<br />
<br />
However, there are three ways in which ITK is related to Tcl:<br />
<br />
# The testing system used by ITK dashboard is managed by Dart which is writen mostly in Tcl. If you want to configure experimental, continuous or nightly builds in your system using Dart. You will need Tcl installed.<br />
# ITK can be wrapped in order to be used from Tcl.<br />This is done using "Cable". That gives ITK the versatility needed for developing rapid prototyping, and facilitating interactive teaching and experimentaion with ITK classes.<br />
# Some demo applications in the Insight/Applications directory have configured their visualization by using VTK. These demo-applications have packaged ITK filters inside VTK filters and then wrapped those into Tcl using the traditional Tcl wrapping mechanism of VTK.<br />
<br />
=== What version of FLTK is required by ITK demo applications ===<br />
The recommended version of fltk is 1.1.4.<br />
<br />
The sources can be obtained from ftp.fltk.org <br />
<br />
ftp://ftp.fltk.org/pub/fltk/1.1.4/<br />
<br />
or from the "Related Software" page in www.itk.org.<br />
<br />
FLTK is not needed for building ITK itself. FLTK is only used by<br />
some of the demo applications distributed in InsightApplications<br />
<br />
FLTK is in continuous development and it has been quite difficult to keep track of its configuration changes.<br />
<br />
Also note that InsightApplications is not any more part of the core Insight Toolkit but is a standalone package.<br />
<br />
=== What additional packages are required by each demo-application ===<br />
The following list rapidly summarizes the additional pacakges required by demo applications in the Insight/Applications directory.<br />
<br />
The following applications require VTK wrapped for Tcl. These applications insert ITK filters into VTK objects and then wrapp them to be used from Tcl.<br />
<br />
* MRIRegistration<br />
* SegmentationEditor<br />
* vtkITK<br />
<br />
This wrapping is done with the traditional VTK wrapping mechanism which is totally independdent of ITK mechanism based on Cable.<br />
<br />
FLTK is used in the following demo applications to implement their GUI. The recommended version can be downloaded from http://www.itk.org/HTML/DownloadRelatedSoftware.htm<br />
<br />
* DistanceMapFilter<br />
* DicomImageViewer<br />
* GaussianFilter<br />
* GradientRecursiveGaussianFilter<br />
* Curves2DExtractor<br />
* Morphogenesis<br />
* MutualInformationEuler2DRegistration<br />
* ImageRegistration<br />
* ImageRegistration2D<br />
* RawImageReaderViewer<br />
* RegionGrowingSegmentation<br />
* ThresholdSegmentationLevelSet<br />
* FastMarchingLevelSet<br />
* ShapeDetectionLevelSet<br />
* MetaImageViewer<br />
* MetaImageColorViewer<br />
* SurfaceGenerator<br />
<br />
Among the applications using FLTK for GUI, the following applications also require VTK for visualizing segmented images in 3D:<br />
<br />
* RegionGrowingSegmentation<br />
* ThresholdSegmentationLevelSet<br />
* FastMarchingLevelSet<br />
* ShapeDetectionLevelSet<br />
<br />
There is also an example of how to use Qt for GUI along with ITK:<br />
<br />
* QtITK<br />
<br />
=== What 3D file formats can ITK import and export? ===<br />
<br />
The following table identifies the file formats that ITK can read/write via a factory mechanism based on the file extension (itk::ImageIOFactory). Some proprietary files format are only imported. More information on [[ITK File Formats]] is available, including data types supported.<br />
<br />
A very nice tool for viewing all of these images is ImageViewer which can be found in the InsightApplication package (fltk is required).<br />
<br />
{| border="1" cellpadding="2" cellspacing="0"<br />
|- bgcolor="#abcdef"<br />
! File Format<br />
! Read/Write<br />
! Import<br />
|-<br />
| Analyze 7.5 || AnalyzeImageIO ||<br />
|-<br />
| BMP &dagger; || BMPImageIO ||<br />
|-<br />
| Dicom || || DicomImageIO<br />
|-<br />
| GE 4x || || GE4ImageIO<br />
|-<br />
| GE 5x || || GE5ImageIO<br />
|-<br />
| GE Advantage Windows || || GEAdwImageIO<br />
|-<br />
| Gipl (.gipl) || GiplImageIO ||<br />
|-<br />
| IPLCommon || || IPLCommonImageIO<br />
|-<br />
| JPEG &dagger; || JPEGImageIO ||<br />
|-<br />
| MetaImage (.mha/.mhd) || MetaImageIO ||<br />
|-<br />
| PNG &dagger; || PNGImageIO ||<br />
|-<br />
| Raw &Dagger; || RawImageIO ||<br />
|-<br />
| Siemens Vision || || SiemensVisionImageIO<br />
|-<br />
| Stimulate (spr/sdt) || StimulateImageIO ||<br />
|-<br />
| TIFF || TIFFImageIO ||<br />
|-<br />
| VTK Structured Points || VTKImageIO ||<br />
|}<br />
<br />
&dagger; BMP, PNG and JPEG are not very good formats for 3D medical images. They only support 2D images and a limited set of pixel types such as unsigned char, and unsigned short. The great advantage of BMP, PNG and JPEG is that you can view them with almost any image viewer. It is possible to read/write 3D datasets as collections of 2D slices each one in an independent BMP, PNG or JPEG file by using the ImageSerierReader and ImageSeriesWriter.<br />
<br />
&Dagger; It is higly recommended not using this format. RAW is not a format, it is insufficient, inconsistent and simply dangerous. A RAW file without a header is useless, and once you add a header, it is not RAW anymore.<br />
<br />
=== What if my file format is not supported by ITK ? ===<br />
If ITK doesn't have a specific file format reader at this point.<br />
<br />
You may try converting this specific file format image to a format like PNG, for which ITK has readers.<br />
<br />
A good set of tools for performing such conversions is available in ImageMagick. It can be downloaded it for free from: http://www.imagemagick.org/<br />
<br />
You can also take advantage of the VTK readers/importers. All you need is then use the VTKImageToImage adaptor in order to convert the vtkImageData into an itk::Image.<br />
<br />
Supported VTK file formats can be found here: [[VTK_FAQ#What_image_file_formats_can_VTK_read_and_write.3F|What image file formats can VTK read and write?]] and [[VTK_FAQ#What_3D_file_formats_can_VTK_import_and_export.3F|What 3D file formats can VTK import and export]]<br />
<br />
=== How to read a volume from a DICOM series ===<br />
# Write a MetaImageHeader<br>This is a small text file holding information about the image: spacing, dimensions, pixelt type... This header can hold the list of dicom files you want to read. The only restriction is that the files must be uncompressed.<br>The easy way to create a MetaImage header is to use the application: MetaImageImporter that is available in: InsightApplications/MetaImageImporter. you can also take an existing metaimage reader and modify it in order to fit your needs. Please find attached one file that you can edit it with your favorite text editor.<br />
# Use MRIConvert<br>Jolinda Smith from the Lewis Center for Neuroimaging at the University of Oregon has developed a nice application that allows you to load DICOM series and export them in MetaImage and Analyze format (among others).<br>She graciously has made this application publicly available at: http://lcni.uoregon.edu/~jolinda/MRIConvert There is a fresh version updated in april 14th.<br />
# Jeff Brubaker and Stephen R. Aylward, at the UNC<br>CADDLab developed a DICOM query/move application called "MIND" (whit the motto: "MIND is not DICOM"). This application loads DICOM files over the network and export them in MetaImage format. This application is open source and it is available at: http://www.jeffro.net/mind/ and http://caddlab.rad.unc.edu/software/MIND/<br />
<br />
=== Interpreted languages supported by ITK ===<br />
Currently ITK supports the following language bindings:<br />
<br />
* Tcl<br />
* Python <br />
* Java<br />
<br />
Java was added in February 2004, it will not be found in the ITK release 1.6. You will need a CVS checkout with a data posterior to February 25 2004.<br />
<br />
=== How do I cite the use of ITK in a publication? ===<br />
The Insight software may be cited by referencing the paper, the books, and/or the web site.<br />
<br />
A) The paper:<br />
<br />
T.S. Yoo, M. J. Ackerman, W. E. Lorensen, W. Schroeder, V. Chalana, S. Aylward, D. Metaxes, R. Whitaker. Engineering and Algorithm Design for an Image Processing API: A Technical Report on ITK - The Insight Toolkit. In Proc. of Medicine Meets Virtual Reality, J. Westwood, ed., IOS Press Amsterdam pp 586-592 (2002).<br />
<br />
B) The books:<br />
<br />
"Insight into Images"<br />
edited by Terry Yoo<br />
published by A.K. Peters 2004<br />
ISBN: 1-56881-217-5<br />
<br />
"The ITK Software Guide"<br />
Ibanez, Schroeder, Ng, Cates.<br />
published by Kitware Inc.<br />
ISBN: 1-930934-10-6<br />
<br />
"Mastering CMake,<br />
A Cross-Platform Build System"<br />
K. Martin and B. Hoffman<br />
published by Kitware Inc.<br />
ISBN: 1-930934-09-2<br />
<br />
C) The Web sites:<br />
<br />
"The Insight Segmentation and Registration Toolkit"<br />
www.itk.org<br />
<br />
"CMake: Cross Platform Make"<br />
www.cmake.org<br />
<br />
If you want to include ITK in an acknowledment section, a phrase similar to the following may be used:<br />
<br />
"This work benefited from the use of the Insight Segmentation<br />
and Registration Toolkit (ITK), an open source software<br />
developed as an initiative of the U.S. National Library<br />
of Medicine and available at www.itk.org."<br />
<br />
and<br />
<br />
"The multi-platform configuration tool CMake was used for<br />
configuring ITK and facilitating its use from our project.<br />
CMake was partially funded by the U.S. National Library of<br />
Medicine as part of the Insight Toolkit project. CMake is an <br />
open source system and it is freely available at www.cmake.org."<br />
<br />
=== I got the message: "Could not create IO object for file" ===<br />
Question:<br />
<br />
When trying to read or write a file using the ImageFileReader or the ImageFileWriter I got an exception with the following message:<br />
<br />
itk::ImageFileReaderException (00F7F494)<br />
Location: "Unknown"<br />
File: C:\ITK\InsightToolkit-1.6.0\Code\IO\itkImageFileReader.txx<br />
Line: 101<br />
Description: Could not create IO object for file c:\t1.mnc<br />
<br />
What is going wrong ?<br />
<br />
Answer:<br />
<br />
This exception is thrown when ITK does not recognize the fileformat that you are trying to read or write. When reading, ITK recognize file formats by asking a set of internal readers to attempt to read your file. If none of the registered readers accept your file, then the exception above is thrown. When writing, ITK uses the extension of the filename in order to chose the fileformat to be used. You must make sure that you use one of the filename extensions recognized by ITK. Please look at FAQ entry 1.7 for a full list of those extensions and associated fileformats.<br />
<br />
Additional details on the ITK Input/Output architecture are available in the ITK Software Guide: http://www.itk.org/ItkSoftwareGuide.pdf.<br />
<br />
== Language bindings ==<br />
=== Error opening hint file NOTFOUND ===<br />
When you enable "USE_VTK" in the CMake configuration of ITK, and VTK was built with wrapping, CMake looks for a "hints" file.<br />
<br />
The "hints" file is on the VTK source tree under: VTK/Wrapping/hints<br />
<br />
Please switch CMake to "advanced", look for the VTK_WRAP_HINTS variable and set it to the full path to the "hints" file including the "hints" filename itself.<br />
<br />
here is how it looks in the CMakeCache.txt of a typical ITK installation:<br />
<br />
//Where can the hints file be found<br />
VTK_WRAP_HINTS:FILEPATH=/home/johndoe/src/VTK/Wrapping/hints<br />
<br />
== Using Insight ==<br />
<br />
=== How to combine ITK and VTK in my application ===<br />
<br />
A full tutorial on how to combine ITK and VTK is available at<br />
<br />
"Getting Started with ITK and VTK"<br />
http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf<br />
<br />
You will need the auxiliary classes available at<br />
<br />
InsightApplications/Auxiliary/vtk<br />
<br />
For example, for converting ITK images into VTK images and back, you will find useful the files<br />
<br />
itkImageToVTKImageFilter.h<br />
itkImageToVTKImageFilter.txx<br />
itkVTKImageToImageFilter.h<br />
itkVTKImageToImageFilter.txx<br />
<br />
Simply copy those files into the source code directory of your project.<br />
<br />
For the full list of tutorials please look at<br />
<br />
http://www.itk.org/HTML/Tutorials.htm<br />
<br />
<br />
=== Compile/Link errors involving C++ streams library ===<br />
<br />
Compile and link errors involving the C++ streams library (ostream, istream, ifstream, ofstream, etc.) are usually the result of collisions between the old and new streams library. The C++ streams library in the Standard Library is different and usually imcompatible with the original C++ streams library. The new streams library is share the same class names as the old streams library but has a very different implementation (templates, thread safety, etc.). ITK can only be built using the Standard Library streams library.<br />
<br />
If the compile/link error is in an ITK file, the solution is usually to include the proper stream header file, i.e. <fstream> before any other include file. The forces the streams library used by all subsequent headers to be the Standard Library version.<br />
<br />
If the compile/link error is in an application that is trying to use ITK, the solution is usually to include an ITK header file before any other include file. This forces whatever include files that the application may use to use the Standard Library streams library.<br />
<br />
=== What is the difference between the CMake options ITK_WRAP_TCL and VTKITK_WRAP_TCL ? ===<br />
<br />
ITK_WRAP_TCL enables the official method of wrapping ITK into Tcl. This wrapping requires the installation of two external packages: Cable and GCC_XML. Information about these packages can be found at http://public.kitware.com/Cable/HTML/Index.html and http://www.gccxml.org/HTML/Index.html<br />
<br />
VTKITK_WRAP_TCL is not really part of ITK. It is only required to enable the build of some demo-applications in the Insight/Applications directory. These applications use VTK for visualization. ITK filter are packaged here inside VTK classes that are subsequently wrapped for Tcl using the traditional VTK wrapping mechanism (not Cable).<br />
<br />
=== EMACS configuration file : ITK coding style ===<br />
You can add the following codes into your .emacs file<br />
<br />
;;;;;;;;;;;;;;<br />
(c-add-style "itk"<br />
'("stroustrup" <br />
(c-basic-offset . 2)<br />
(c-offsets-alist<br />
(c . c-lineup-dont-change)<br />
(innamespace . 0)<br />
(inline-open . 0) <br />
(substatement-open . +)<br />
(statement-block-intro . 0) ) ) )<br />
(add-hook 'c++-mode-hook (function (lambda ()<br />
(c-set-style "itk")(turn-on-auto-fill))))<br />
(add-to-list 'auto-mode-alist '("\\.txx\\'" . c++-mode)) (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))<br />
;;;;;;;;;;;<br />
<br />
== VIM configuration file : ITK coding style ==<br />
for all of you who use VIM, here are just couple of things:<br />
<br />
set tabstop=2 " Tabs are two characters<br />
set shiftwidth=2 " Indents are two charactes too<br />
set expandtab " Do not use tabs<br />
set matchpairs+=<:> " To mach arguments of templates<br />
set cinoptions={1s,:0,l1,g0,c0,(0,(s,m1 " ITK/VTK style indenting<br />
<br />
Then you can also use CMake indentation and syntax file which are available on www.vim.org.<br />
<br />
This was contributed by Andy Cedilnik @kitware.com<br />
<br />
=== FLTK_WRAP_UI called with FLTK_WARP_UI undefined ===<br />
I use CMake to build the InsightApplications and the following error appears:<br />
<br />
CMake Error: Error in cmake code at<br />
../../CMakeLists.txt:20:<br />
FLTK_WRAP_UI called with FLTK_WARP_UI undefined<br />
<br />
I wonder where and how to define it.<br />
<br />
This error message<br />
<br />
"...FLTK_WARP_UI undefined"<br />
<br />
appears when you have missed to specify some of the FTLK components.<br />
<br />
Please run Cmake again, pass to "Advanced" mode and double check that you provided the right paths for the following components<br />
<br />
* FLTK_BASE_LIBRARY<br />
* FLTK_FLUID_EXECUTABLE<br />
* FLTK_FORMS_LIBRARY<br />
* FLTK_GL_LIBRARY<br />
* FLTK_INCLUDE_DIR<br />
<br />
Here is for example how they look in a typical Windows installation:<br />
<br />
FLTK_BASE_LIBRARY C:/cygwin/home/ibanez/src/fltk-1.1.4/lib/fltkd.lib<br />
FLTK_FLUID_EXECUTABLE C:/cygwin/home/ibanez/src/fltk-1.1.4/fluid/fluidd.exe<br />
FLTK_FORMS_LIBRARY C:/cygwin/home/ibanez/src/fltk-1.1.4/lib/fltkformsd.lib<br />
FLTK_GL_LIBRARY C:/cygwin/home/ibanez/src/fltk-1.1.4/lib/fltkgld.lib<br />
FLTK_IMAGES_LIBRARY C:/cygwin/home/ibanez/src/fltk-1.1.4/lib/fltkimagesd.lib<br />
FLTK_INCLUDE_DIR C:/cygwin/home/ibanez/src/fltk-1.1.4<br />
<br />
<br />
Here is an example for a Linux installation<br />
<br />
FLTK_BASE_LIBRARY /home/ibanez/local/lib/fltk.a<br />
FLTK_FLUID_EXECUTABLE /home/ibanez/local/bin/fluid<br />
FLTK_FORMS_LIBRARY /home/ibanez/local/lib/fltk_forms.a<br />
FLTK_GL_LIBRARY /home/ibanez/local/lib/fltk_gl.a<br />
FLTK_IMAGES_LIBRARY /home/ibanez/local/lib/fltk_images.a<br />
FLTK_INCLUDE_DIR /home/ibanez/local/include<br />
<br />
Note that FLTK on Unix/Linux *MUST* be installed. The reason is that FLTK<br />
has an inconsitent convention for the use of upper/lower case in file names <br />
and resolved this inconsistency by duplicating *ALL* the headers' filenames <br />
with symbolic links. These links are created during the installation process. <br />
If you don't install FLTK, you will not be able to find the headers because <br />
the case will not match the #includes in ITK.<br />
<br />
== Platform-specific questions ==<br />
=== Build->Rebuild All in MS VC++ reloads all projects ===<br />
When performing a "Rebuild All" from Microsoft Visual C++, every project prompts the user for a reload (and their are hundreds of projects).<br />
<br />
DO NOT USE "Rebuild All" or "Batch Build". Use the following recommended procedure.<br />
<br />
There is an ALL_BUILD target available in the MSVC++ workspace. The best way to build ITK is to set ALL_BUILD as the active project, then select the active configuration you want (DEBUG, etc).<br />
<br />
This can also be done from the command line like this: msdev ITK.dsw /MAKE "ALL_BUILD - Debug" /REBUILD<br />
<br />
=== Borland 5.5 Compiler Issues ===<br />
To build Insight using the (free) Borland 5.5 compiler:<br />
<br />
# Get the Borland compiler from http://www.borland.com and install it<br />
# Run cmakesetup and select the Borland Makefiles in the "Build For:" drop down.<br />
# Set the CMAKE_BUIlD_TYPE to MinSizeRel. This is required so that the Borland linker will stay below its size limit which is arounbd 35 meg for a tds file.<br />
<br />
=== Windows + FLTK: unresolved external symbol TrackMouseEvent ===<br />
This error is due to changes in FLTK and it is totally unrelated to ITK. The error only appears in ITK demo applications that are using FLTK for GUI.<br />
<br />
The library "comctl32" must be added to the link command line.<br />
<br />
You can solve this by editing the CMake file: CMake/Modules/FindFLTK.cmake and around line 39 add the comctl32 library.<br />
<br />
After the change the lines should look like:<br />
<br />
IF(WIN32)<br />
SET( FLTK_PLATFORM_DEPENDENT_LIBS wsock32 comctl32 )<br />
ENDIF(WIN32)<br />
<br />
This is already fixed in the CVS version of CMake FindFLTK.cmake.<br />
<br />
The CMake version 1.6 will have this issue solved.<br />
<br />
===Under Mac OS X, when I try to run a program that builds successfully, the window is displayed but I can't interact with it.===<br />
<br />
This is caused by the fact that the application needs to be registered with the window manager for correct operation. There is an additional step that needs to be performed ''after'' the link step, in order to add the required resources to the binary. This can be done with a simple:<br />
<br />
% /Developer/Tools/Rez Carbon.r -o myapp<br />
<br />
For apps built with FLTK, you can use:<br />
<br />
% /Developer/Tools/Rez /usr/local/include/FL/mac.r -o myapp<br />
<br />
Here is an example of adding a custom command to do this automagically in your `CMakeList.txt` file:<br />
<br />
IF(APPLE)<br />
FIND_PROGRAM(APPLE_REZ Rez /Developer/Tools)<br />
ADD_CUSTOM_COMMAND(TARGET MyApplication<br />
POST_BUILD<br />
COMMAND ${APPLE_REZ}<br />
ARGS ${FLTK_INCLUDE_DIR}/mac.r -o MyApplication)<br />
ENDIF(APPLE)<br />
<br />
'''Note:''' This is ''not'' required for applcations build against X libraries; only for Carbon-based applications. If you have built FLTK for X rather than Carbon, the above does not apply.<br />
<br />
(Gavin Baker, 7-May-2004)<br />
<br />
<br />
== Testing ==<br />
=== Is ITK tested regularly? ===<br />
ITK is tested throughout the day on machines distributed around the world. You can view the results at: http://public.kitware.com/Insight/Testing/HTML/TestingResults/Dashboard/MostRecentResults-Nightly/Dashboard.html<br />
<br />
ITK uses Dart to perform builds, run tests and generate dashboards. You can find more information about Dart at http://www.itk.org/Dart/<br />
<br />
=== What is the testing schedule? ===<br />
Dart opens a daily dashboard at 1:00AM Eastern Daylight Time and keeps that dashbooard open for 24 hours. Build/Test results submitted as "nightlies" will appear on the currently opened dashboard. Each test site can select a convenient time to run tests.<br />
<br />
Fresh dashboards are generated every hour, on the hour. They can also be generated on demand using the Rollup button on the dashboard. This button should be used sparingly since dashboard rollups can be time consuming.<br />
<br />
In addition to nightly testing, several sites run Continuous build/tests. These sites monitor cvs repository activity and begin a build/test sequence if there are updates to the repository. If a compile error is detected, the Dashboard server sends email to the "offending" party.<br />
<br />
=== What kind of testing is performed? ===<br />
ITK has three types of tests:<br />
<br />
# Unit Tests. Also called white box tests. These tests reside in the Testing/Code/XXX directories. There are meant to exercise a class's methods and verify that the code compiles, links and produces expected results. These tests do not need to produce results that are useful to a user. If a test returns a 0 status, it passes. A test fails if it returns a non-zero status.<br />
# Blackbox Tests. These tests are automatically (or semi-automatically) generated. For example, each Code directory has a test called itkXXXHeaderTest. This test is automatically created and has a "#include" for each file in the directory.<br />
# Regression Tests. These tests generate results and compare them with a known result. The purpose of regression testing is to detect changes in the output of the system. <br />
<br />
=== How Do I Add a Test? ===<br />
<br />
=== What is a continuous build and how can I contribute one? ===<br />
Continuous builds run throughout the day and report their output in the Continuous Builds portion of the dashboard. The most recent build is at the top of the list. The builds run periodically and check the status of the repository. If a file is added or changed since the last build, the working repository of the continuous build is updated, the code compiled and tests executed. Optional e-mail norifications can be sent if there are errors, warmings or test failures.<br />
<br />
You can set up a continuous build. This entails writing some small shell scripts and setting up a scheduler (Scheduler for Windows, cron for Linux/Unix). You will also need to install tcl, checkout Dart and configure your build for testing.<br />
<br />
For Windows 2000, here are three batch files that can be modified for your own environment.<br />
<br />
AllowInsightContinuous.bat<br />
BuildInsightContinuous.bat<br />
PreventInsightContinuous.bat<br />
<br />
The batch files use a lock to prevent/allow the continuous<br />
<br />
rem ************* AllowInsightContinuous.bat<br />
rem Allow the Continuous to run<br />
rem<br />
c:<br />
cd c:\lorensen\InsightContinuous\Insight-VC6<br />
if EXIST continuous.lock (<br />
del continuous.lock<br />
)<br />
cd ..<br />
rem ************* BuildInsightContinuous.bat<br />
rem DO a C++ Build Continuously<br />
rem<br />
c:<br />
rem Setup proxy it behind a firewall<br />
set HTTP_PROXY=webcache<br />
set HTTP_PROXY_PORT=8080<br />
rem<br />
rem Setup the path<br />
rem<br />
set PATH=c:/lorensen/InsightContinuous/Insight-VC6/bin/Release;%PATH%<br />
rem<br />
rem Tell cvs where .cvspass resides<br />
set HOME=c:/lorensen<br />
cd c:\lorensen\InsightContinuous\Insight-VC6<br />
if EXIST continuous.lock (<br />
exit /B<br />
) else (<br />
date /T > continuous.lock<br />
time /T >> continuous.lock<br />
cd c:\lorensen\InsightContinuous\Insight-VC6<br />
tclsh83 c:/lorensen/Dart/Source/Client/DashboardManager.tcl DartConfiguration.tcl Continuous Start Update Configure Build Test Submit<br />
cd c:\lorensen\InsightContinuous\Insight-VC6<br />
del continuous.lock<br />
cd ..<br />
)<br />
rem ***************** PreventInsightContinuous.bat<br />
rem Prevent the Continuous<br />
rem<br />
c:<br />
cd c:\lorensen\InsightContinuous\Insight-VC6<br />
if EXIST continuous.lock (<br />
exit /B<br />
) else (<br />
echo "Prevent continuous for nightly" > continuous.lock<br />
)<br />
cd ..<br />
<br />
Now you need to establish a schedule for the three batch jobs. Use the "Scheduled Tasks" on the "Control Panel" to access the Schedule Task Wizard. The following schedule runs the continuous every 10 minutes from 6:05AM until 12:00AM. The Allow and Prevent scripts turn the build ON/OFF at the appropriate time. Schedule each batch file as follows:<br />
<br />
AllowInsightContinuous.bat - Daily, Start 6:00AM<br />
BuildInsightContinuous.bat - Daily, Start 6:05AM, Advanced: Repeat Task every 10 minutes, duration 17 hours and 55 minutes<br />
PreventContinuous.bat - Daily, Start 12:00AM<br />
<br />
<br />
== Working with Image Data ==<br />
<br />
===How do I iterate through all the pixels in an image?===<br />
<br />
This requires the use of image iterators, which is explained in detail in the SoftwareGuide in Chapter 11, pdf-page 481.<br />
<br />
Examples are available in `Insight/Examples/Iterators`. You probably want to use the [http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageSliceIteratorWithIndex.html ImageSliceIterator].<br />
<br />
(Luis Ibanez, 7-Jun-2004)<br />
<br />
== Data Display ==<br />
<br />
===What imaging software is available for displaying medical image files?===<br />
<br />
Here are some viewing options for the image fileformats supported in ITK: <br />
<br />
1. Scalar images:<br />
<br />
* InsightApplications/ImageViewer<br />
* [http://www.paraview.org ParaView]<br />
* For 3D images: [http://www.kitware.com/products/volview.html VolView]<br />
<br />
2. Color Images:<br />
<br />
* InsightApplications/ColorImageViewer<br />
* [http://www.paraview.org ParaView]<br />
* For 3D images: [http://www.kitware.com/products/volview.html VolView]<br />
<br />
3. Vector Images:<br />
<br />
* [http://www.paraview.org ParaView] (glyphs, streamlines, composites).<br />
<br />
(Luis Ibanez, 9-Jun-2004)<br />
<br />
===When I view the output of my program, all I see is a black image. What went wrong?===<br />
<br />
ITK is capable of reading and writing data in a variety of formats and bit depths. However many 'consumer' image programs only work with 8-bit data, so when you try to display a 16-bit data file the image will appear black. The solution is to use an image display program that correctly handles these types of files. A small selection is listed above.<br />
<br />
[http://www.imagemagick.org/ ImageMagick] is a particularly useful set of tools for image display, manipulation and conversion.<br />
<br />
The `ImageViewer` program, part of InsightApplications, is capable of correctly loading and displaying all file types supported by ITK (including anisotropic images).<br />
<br />
(Gavin Baker, 24-Jun-2004)<br />
<br />
== Registration ==<br />
<br />
===Can ITK be used for multi-modal registration? For example, CT-MRI, or MRI-fMRI?===<br />
<br />
ITK provides several method for performing Multi-Modality registration. These methods are described in detail in the SoftwareGuide Chapter 8, pdf-page 241 to 340. In particular you will find interesting Section 8.4 in pdf-page 255 where the Mutual Information metrics are described.<br />
<br />
Examples on multimodality registration are available in `Insight/Examples/Registration`. A demo application using Mutual Information is available under `InsightApplications/LandmarkInitializedMutualInformationRegistration`.<br />
<br />
It is strongly recommended that you read the chapter on image resampling before you get involved with image<br />
registration methods. That will save you a lot of misunderstandings that are common in new users.<br />
<br />
You will also find useful the tutorial sessions, in particular [http://www.itk.org/CourseWare/Training/RegistrationMethodsOverview.pdf the overview].<br />
<br />
(Luis Ibanez, 7-June-2004)</div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=158VTK Mouse Picking2004-08-12T21:37:17Z<p>Goodwin: Link to the submitted bug (idea)</p>
<hr />
<div>The default way pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to turn mouse picking on/off and to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... here's the link [http://www.vtk.org/Bug/bug.php?op=show&bugid=1054&pos=3 Bug submission]. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
'''To perform a pick in the example below: move the cursor to the position in the render window you want to pick, then press and release the left mouse button without moving the mouse in between'''. This may seem tricky at first but you'll get used to it!<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=143VTK Mouse Picking2004-08-12T20:36:40Z<p>Goodwin: Some instructions for the example</p>
<hr />
<div>The default way pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... link to come. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
'''To perform a pick in the example below: move the cursor to the position in the render window you want to pick, then press and release the left mouse button without moving the mouse in between'''. This may seem tricky at first but you'll get used to it!<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre></div>Goodwinhttps://public.kitware.com/Wiki/index.php?title=VTK_Mouse_Picking&diff=142VTK Mouse Picking2004-08-12T19:11:58Z<p>Goodwin: A tcl method to pick using the left mouse button with vtkInteractorStyleTrackballCamera</p>
<hr />
<div>The default way pick a cell/point/actor under the cursor in a render window is to press the "p" key. You may prefer to pick by pressing a mouse button. The problem is most interactor styles have already assigned functions to the mouse buttons such as rotating the camera or actor. This method of picking with a mouse button uses the fact that in vtkInteractorStyleTrackballCamera you must move the mouse in addition to pressing a mouse button to interact with the scene. Below is a tcl example of how to change vtkInteractorStyleTrackballCamera so that when you press the left mouse button and release it without moving the mouse you will perform a pick under the cursor.<br />
<br />
The annotatePick.tcl example is modifed below to illustrate a working example but here is the pertinent code:<br />
<br />
<pre><br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
</pre><br />
<br />
A "MouseMotion" flag is set to "0" when the left button is pressed. This flag is changed to "1" when you move the mouse. When you release the left button, the callback "cbLBR" checks "MouseMotion" to see if you have moved the mouse and performs a pick if you haven't.<br />
<br />
I have a c++ implimentation of this that also allows you to get which mouse button was pressed. I'll post it as an idea to the bug tracker with a patch to vtkInteractorStyleTrackballCamera... link to come. (You could use this with vtkInteractorStyleTrackballActor too)<br />
<br />
--[[User:Goodwin|Goodwin]] 15:11, 12 Aug 2004 (EDT)<br />
<br />
Here's the full example (modified annotatePick.tcl):<br />
<br />
<pre><br />
# This example demonstrates cell picking using vtkCellPicker. It displays<br />
# the results of picking using a vtkTextMapper.<br />
<br />
#<br />
# First we include the VTK Tcl packages which will make available<br />
# all of the vtk commands to Tcl<br />
#<br />
package require vtk<br />
package require vtkinteraction<br />
<br />
# create a sphere source, mapper, and actor<br />
#<br />
vtkSphereSource sphere<br />
<br />
vtkPolyDataMapper sphereMapper<br />
sphereMapper SetInput [sphere GetOutput]<br />
sphereMapper GlobalImmediateModeRenderingOn<br />
vtkLODActor sphereActor<br />
sphereActor SetMapper sphereMapper<br />
<br />
# create the spikes by glyphing the sphere with a cone. Create the mapper<br />
# and actor for the glyphs.<br />
vtkConeSource cone<br />
vtkGlyph3D glyph<br />
glyph SetInput [sphere GetOutput]<br />
glyph SetSource [cone GetOutput]<br />
glyph SetVectorModeToUseNormal<br />
glyph SetScaleModeToScaleByVector<br />
glyph SetScaleFactor 0.25<br />
vtkPolyDataMapper spikeMapper<br />
spikeMapper SetInput [glyph GetOutput]<br />
vtkLODActor spikeActor<br />
spikeActor SetMapper spikeMapper<br />
<br />
# Create a cell picker.<br />
vtkCellPicker picker<br />
picker AddObserver EndPickEvent annotatePick<br />
<br />
# Create a text mapper and actor to display the results of picking.<br />
vtkTextMapper textMapper<br />
set tprop [textMapper GetTextProperty]<br />
$tprop SetFontFamilyToArial<br />
$tprop SetFontSize 10<br />
$tprop BoldOn<br />
$tprop ShadowOn<br />
$tprop SetColor 1 0 0<br />
vtkActor2D textActor<br />
textActor VisibilityOff<br />
textActor SetMapper textMapper<br />
<br />
# Create the Renderer, RenderWindow, and RenderWindowInteractor<br />
#<br />
<br />
vtkInteractorStyleTrackballCamera style<br />
style AddObserver LeftButtonPressEvent {set MouseMotion 0; style OnLeftButtonDown}<br />
style AddObserver MouseMoveEvent {set MouseMotion 1; style OnMouseMove}<br />
style AddObserver LeftButtonReleaseEvent cbLBR<br />
vtkRenderer ren1<br />
vtkRenderWindow renWin<br />
renWin AddRenderer ren1<br />
vtkRenderWindowInteractor iren<br />
iren SetRenderWindow renWin<br />
iren SetInteractorStyle style<br />
iren SetPicker picker<br />
<br />
# Add the actors to the renderer, set the background and size<br />
#<br />
ren1 AddActor2D textActor<br />
ren1 AddActor sphereActor<br />
ren1 AddActor spikeActor<br />
ren1 SetBackground 1 1 1<br />
renWin SetSize 300 300<br />
<br />
# Get the camera and zoom in closer to the image.<br />
set cam1 [ren1 GetActiveCamera]<br />
$cam1 Zoom 1.4<br />
<br />
# Set the user method (bound to key 'u')<br />
iren AddObserver UserEvent {wm deiconify .vtkInteract}<br />
iren Initialize<br />
<br />
# Withdraw the default tk window<br />
wm withdraw .<br />
<br />
# Create a Tcl procedure to create the text for the text mapper used to<br />
# display the results of picking.<br />
proc annotatePick {} {<br />
if { [picker GetCellId] < 0 } {<br />
textActor VisibilityOff<br />
<br />
} else {<br />
set selPt [picker GetSelectionPoint]<br />
set x [lindex $selPt 0] <br />
set y [lindex $selPt 1]<br />
set pickPos [picker GetPickPosition]<br />
set xp [lindex $pickPos 0] <br />
set yp [lindex $pickPos 1]<br />
set zp [lindex $pickPos 2]<br />
<br />
textMapper SetInput "($xp, $yp, $zp)"<br />
textActor SetPosition $x $y<br />
textActor VisibilityOn<br />
}<br />
<br />
renWin Render<br />
}<br />
<br />
proc cbLBR {} {<br />
global MouseMotion<br />
<br />
if {$MouseMotion == 0} {<br />
eval picker Pick [iren GetEventPosition] 0 ren1<br />
}<br />
# Do the default things for the trackball style<br />
style OnLeftButtonUp <br />
}<br />
<br />
# Pick the cell at this location.<br />
picker Pick 85 126 0 ren1<br />
</pre></div>Goodwin