vtk page


The purpose of this page is to keep track of tips and suggestions for getting vtk running and keeping it happy.

Latest additions are now up top



Julian Chen

I noticed that it's time of the year for people building VTK for Andy's class. Compared to the old days, it's amazingly simple to do that nowadays. Especially on Macs, VTK is part of MacPorts now.

So, if you already have MacPorts, you can literately do:

$port install vtk-devel +cocoa

Wait for a while, then you'll have VTK 5.4.2 built in /opt/local/lib and /opt/local/include ready for your projects.



Paul Grenning - 1/19/11

http://vuvie.blogspot.com/2010/02/compiling-vtk-for-visual-studio-2008.html

I found this link which may be useful for anyone who is still trying
to setup VTK in windows.


past classes:

Vivek Revanna Shivaprabhu

How to install and set up VTK 5.0 on Visual Studio 2005 (dot net 2.0)?

You don’t have to compile/build/cmake any source code for this!

You can use this information for writing dot net programs on any of the languages supported (C++, VB, C#, etc). I shall describe it for C#.

1. Go to http://sourceforge.net/project/showfiles.php?group_id=167907&package_id=190894&release_id=431983 and download the files:
     VTK-5.0.1-wrap-1.1-bin.zip (DLLs to use the VTK library)
     VTK-5.0.1-control-1.1.zip (this puts a control on the toolbox)
     VTK-5.0.1-help-1.1.chm (help file)
     VTK-5.0.1-wrap-1.1-src.zip (this is the source. Download this if you want. Not required)
2. Unzip VTK-5.0.1-wrap-1.1-bin.zip and VTK-5.0.1-control-1.1.zip into :\Program Files\VTK 5.0.
3. Add C:\Program Files\VTK 5.0\bin to the user PATH (System properties -> Advanced -> Environment Variables -> User variables -> Path
4. Start Visual Studio -> Start a new C# project
5. Right click on the solution name in Solution Explorer and select Add References. Browse to C:\Program Files\VTK 5.0\bin and add the eleven (11) vtk*dotnet.dll files.
6. Right click on the toolbox and select Choose Items -> Browse to C:\Program Files\VTK 5.0 and select vtkFormsWindow.dll
7. Drag and drop the new control to your Form. Build and Run your new application. You should get a window with a control with some noise in it. You are now good to go!
8, Add your custom code to the Program.cs file.


Xun

When using shepards method to compute inverse distance weight we'll need to compute distances between two points on the earth, given their longitudes and latitudes. I have found the computation formula, for our project, it can be:

Dist = A * arccos(theta) * R (1) where A is a constant and R is the diameter of Earth. We can omit them in Shepard Formula.

theta = sin(latitude_1) * sin(latitude_2) + cos(latitude_1) * cos(latitude_2) * cos (longitude_1 - longitude_2)


Ratko

This kinda goes together with Cristian's idea of interpolation using Shepard's method. Well, it turns out that there is a class for that in VTK. It's called vtkShepardMethod. It might be patented but im not sure. So what it does, it takes some unstructured points and the "bounding box" for those points and interpolates the data in that box. It seems like that's exactly what we need for this project. I still haven't figured out how to feed it the points for the interpolation though.

Also, there's a section about it in the VTK book on page 340.


Arun

In case anyone is planning on creating images on the fly in VTK, there is a class called vtkImageCanvasSource2D where drawing of an image object can be controlled pixel by pixel, and it has some primitive capabilites (e.g. drawing a circle onto the image space, or lines, etc.)


Christian

Information about the interpolation and extrapolation method I mentioned in class can be found at http://www.ems-i.com/gmshelp/interpolation/interpolation_schemes/inverse_distance_weighted/shepards_method.htm

It seems to be the most appropriate for our project mainly because of its simplicity. In fact it's one of the methods used by GMS (http://www.emrl.byu.edu/gms.htm), which is the most sophisticated and comprehensive commercially-available software to develop computer simulations of groundwater problems.

Also, there is a lot of good maps of Illinois at http://www.illinoisatlas.com/index.htm


Arun

I fixed an error that I made in the location_abbrev.txt file that involved accidentally not putting in the Fairfield station. I've also updated the .txt and .csv files to include the longitude, latitude and elevation data from the WARM website. i added elevation just for completeness sake. Longitude is assumed to be West and Latitude is assumed to be North. I did not add the station number that was at the WARM website.

It's up at the same address:
ftp://ftp.evl.uic.edu/pub/INcoming/arun/bigdata.zip


Arun

Just wanted to let the class know that the really big data set that is at sws.uiuc.edu, which contains daily data for all the weather stations from 1989 to 2003, is saved off as .txt files. If we save off the file as a .csv then excel does a good job of loading in the files with the data in the proper cell locations. It makes it much easier to read.

I've compiled all the data, and copied over the files into .csv format. I also have a text file with the abbreviations and the corresponding weather station aswell as a .csv file of that data.

I'm posting it up on ftp://ftp.evl.uic.edu/pub/INcoming/arun/bigdata.zip


Christian

Many of the students asked me about the interface VTK-FLTK I used after class. It can be downloaded at http://cpbotha.net/vtkFlRenderWindowInteractor.html

It is simple, effective, robust and bug-free.


Mark

I just found a little gotcha in creating the isosurface. I know we don't have to change the color, but if we chose to you must do the following:

vtkPolyDataMapper mapper
mapper ScalarVisibilityOff
Or else, you can't change the color of the actor later.


Cristian

I uploaded the VTK with patented classes compiled for VC++ 6.0 to ftp://ftp.evl.uic.edu/pub/INcoming/cristian/
It includes binaries DLLs and LIBs, as well as headers, so the other students don't have to recompile VTK.


Arpit

The reason behind Setcolormodetomapscalars()

I have found out the reason behind using this routine when mapping the data read as unsigned characters. The reason is that by defaul VTK assumes any data in the unsigned character format as "color" data. So by using this routine, we can force the vtk not to assume the input data as color data and "force" it to go through lookuptable.


Raj

A very important point for doing colormaps ...

If one is reading up the elevation data file as an unsigned char array, then you HAVE to call a mapperVariable->SetColorModeToMapScalars () before you give the mapper any colormap (vtkLookupTable). Apparently you do not need to do it for any other data type ... just for unsigned chars .. according to the manual.


Allan Spale

I was able to VTK-Python working on Kiya. I had to put an older version of Python on there (2.1.1) in order for VTK to behave. And actually, based on the work I did to get this working, I think I need to modify my rules for getting Python to use VTK.

Specifically...

- Download Python 2.1. I tried using a more recent version of python, but then got an error that said python21.dll could not be found. My conclusion is that currently only Python 2.1 is supported (unless of course you mess with the source).

- In the directory that Python is installed, make a file called VTK.pth that only contain the text VTK

- Make a directory in the Python root directory called vtk. Copy all the stuff from vtk42\Wrapping\Python to the vtk directory in the Python root directory

- Follow the instructions in the README.txt file for installation option 3... which basically ends up calling python setup.py.in install ...wherever the setup.py.in files is located.

- From vtk42\bin, I would just copy everything (yes, one could be more careful, but I did not feel like picking and choosing the not-so-obvious dlls and exes that did not have Python in the name) to the vtk directory of the Python root directory.

I made a system variable VTK_DATA_ROOT to correspond to the directory with the data for all the example files.


John Bell: I recently discovered a trick that might help some others: If you can get a visualization that you like in ParaView, you can save it as a "Batch Script" from the File menu. That is an ASCII format file, and if you then look through it, you can get some clues as to what classes were used in what order to make your visualization, and what parameters were set to what values using what calls. In my case I just used it to figure out how to color my Contours according to the Actor properties, and not according to the ( grayscale ) elevation data used to create them.


Mark A. Thompson

I finally got TCL to work with vtk on windows. For some reason, the binary distribution on the CD does not set up all the paths for you and there is a little caviot. Here is what I did

1. Install TCL/TK from the CD (it's the scriptics distribution...)
I tried with the activeState distribution and it didn't go so well
2. Then install VTK.
3. From tclsh or wish type:
puts $auto_path
Make sure the path comes up in curly braces...
4. Then from a windows command prompt you have to:
set TCLLIBPATH={c:/Program Files/vtk42/lib/vtk/tcl}
The Curly braces are super duper important (TCL looks for the path
variable like it's a list). That should do it. I have to admit, this was a
little problematic.


Allan

I have managed to get Python and VTK to work together but it seemed more by luck than by any skill of my own. The best part was that this involved simply moving files around and no CMake (which I still cannot get to compile for WinXP). Here's what I did (and this is based on Windows XP or some equivalent):

1. Go to http://www.imaging.robarts.ca/~dgobbi/vtk/vtkpython.html and follow the instructions.

2. Copy the Python DLL files from the bin directory of the CD (must be the Windows binary directory...can't remember offhand) to the vtk directory in the Python2.x directory on your PC.


Arun

I have sucessfully compiled VTK with only TCL/TK wrapping on Visual Studio .NET (2002). I've had problems compiling the Java and Python wrappings. I have had problems compiling individual examples because of a error from CMake saying that VTK was compiled with one thing even though the CMake file that I used to compile VTK said I was using another file. I will see if I can setup VStudio to know all the important directories and then make a simple VTK program with VStudio only.

I've gotten vtk to work with visual studio .net (2002), and I've made a simple shell program for Windows that people can use to start with.

I think this can work with visual studio 6 if the settings were made right. If anyone wants help with this shell then they can get a hold of me. The shell is basically the same as the one that comes in the VTK user's guide. I started it out as an empty program and was able to setup the project settings so that its a windows program.

Here is the file arun.txt


Andy

For using vtk and Tcl on Linux/OS-X these are the settings I used in ccmake:

shared libs on
hybrid on
parallel maybe
patented on
rendering on
VTK_DATA_ROOT
VTK_WRAP_TCL

then to run I needed to setenv
TCLIBPATH
VTK_ROOT_DATA



last revision 1/19/11