Froggie and the Joy of Open Source Community

July 20, 2023

Thirty years ago when the authors of the VTK Textbook began creating what would become the Visualization Toolkit software, a driving motivation for the work was to collaborate with external researchers and the visualization community. To be honest, at that time we didn’t really understand how important adopting an open-source license would be. And we certainly had no inkling as to the power and potential of community.

Over the decades we’ve had contributions ranging from simple typo bug fixes, to entire software subsystems (e.g., thanks for the Transformation Matrices David Gobbi!) We’ve received guidance from stellar researchers, suggested programming tricks from astoundingly talented engineers, code from Fortune 100 companies, and our share of pointed critique from those that know better. This feedback has come from users and developers all over the planet, all in the interest of making VTK better.

For many of us, working together in community to create impactful technology is a meaningful and joyful process. Recently, yet another contribution was made by Andrew Maclean, a retired technologist living in Australia, and long-time contributor to VTK, who reminded me of the fun to be had in an OS community. Andrew has not only contributed code to VTK, but more recently he has shepherded and made significant contributions to the VTK Examples. These examples are a valuable resource for those wishing to learn more about the system, and the various programming approaches to creating VTK-based applications. Because of the fun nature of the contribution, and as an excuse to thank the community for their contributions, we asked Andrew to write a blog post describing how to run the Froggie examples.

One last note: if you have interest in creating your own open-source culture of collaboration, including establishing and improving software processes, please contact Kitware, we’d enjoy helping out.
–Will S.

FroggieView and FroggieSurface

FroggieSurface and FroggieView are examples derived from the original VTK textbook.

FroggieSurface constructs tissue models by isocontouring a segmented volumetric dataset. A total of 17 tissues (the fifteen tissue files, brainbin and the skin) are available, with each segmentation defined by a tissue mask.

FroggieView enables further exploration of the data by performing operations such as turning on and off various tissue models.

In order to run these examples, you will need to have built/installed the VTK master or the most recent release version of VTK. Your compiler should also support C++17. For Python you will need a virtual environment supporting VTK and a recent version of Python. For reference, please consult the Getting Started – VTK documentation.

The Data

Download these data files and a folder by clicking on the download button when the link opens.

  • Frog_mhd.json
  • Frog_vtk.json
  • Frog – here you must select “Download this directory and the zip file option”. Downloading as a tar file will unzip the *.mhd and *.zraw files – which is not what you want!

As an aside, this is a good way of getting just the needed data files if you want to try other examples.

Note that Frog_mhd.json and Frog_vtk.json reference files in the folder Frog and these JSON files assume that Frog is a sub-folder relative to these two files.

Now create a folder called Froggie and move Frog_mhd.json, Frog_vtk.json and the folder Frog into it. Then unzip the downloaded file: vtk-examples-master-src-Testing-Data-Frog.zip, open the zip file and copy the Frog folder into Froggie. 

Once this is done, download the code.

C++

Download the tar files at the end of these pages:

Untar these files, if you are using Windows, use 7-Zip.

You should now have two folders FroggieSurface and FroggieView;

Move the folders FroggieSurface and FroggieView into the folder Froggie.

Python

In the folder Froggie create two files, FroggieSurface.py and FroggieView.py.

Copy the Python code in FroggieSurface into your just created FroggieSurface.py. Do the same for FroggieView, copying the code from FroggieView.

At this point your folder layout will look like this:

C++

We may need to set the C++ standard to 17 so go to the CMakeLists.txt files in the FroggieSurface and FroggieView folders adding these lines (this may not be needed with most compilers):

#-----------------------------------------------------------------------------
# Set the C++ Standard.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Just before:

if (NOT VTK_FOUND)

Run these commands in each build folder:

cmake .. -G Ninja
ninja

And the executables should build.

Go to Froggie/FroggieSurface/build and run:

(Windows)
FroggieSurface.exe ../../Frog_mhd.json
(Linux)
./FroggieSurface ../../Frog_mhd.json

Go to Froggie/FroggieView/build and run:

(Windows)
FroggieView.exe ../../Frog_vtk.json
(Linux)
./ FroggieView../../Frog_vtk.json

Python

In your virtual environment, run:

FroggieSurface.py Frog_mhd.json
FroggieView Frog_vtk.json

Output

You should see the following results. FroggieSurface will produce the following figure:

FroggieSurface will produce the following figure:

Now in FroggieView you can experiment with the sliders changing the opacity of each tissue.

Next Steps

  • Run the code with –help to see all the options.
  • Try running the code with different options, for example -l or -t skin skeleton brainbin.
  • Look at the frog from different viewpoints.
  • The sliders are really useful!

Having More Fun with VTK Examples

Now that you know how to obtain data and program files, there are many fun VTK examples to try. For example, users often enjoy exploring VTK’s rendering capabilities. Physically Based Rendering (PBR) can beautifully render surfaces in read-world settings, mimicking the optics of lighting and surfaces to produce near photorealistic images. This following example uses a non-orientable surface (Boy’s Surface). It is fun to rotate the object and work out where the reflections come from.

The sliders let you play with various parameters.
(Note that these parametric surfaces are also available in a recent version of ParaView which also supports Physically Based Rendering. See this blog post for more information). Here are some images produced by the these PBR examples.

Leave a Reply