4

I have 3D binary array which represents a volume, where a[x,y,z] = 0 indicates no object and a[x,y,z] = 1 indicates the object region.

I want to save this as a VTK file and view it in ParaView. What is the simplest way to achieve this? Suggestions for other approaches are welcome.

I looked through the VTK file format, but I have not found direct way to achieve what I need, just via other structures.

Chris
  • 44,602
  • 16
  • 137
  • 156
sergtk
  • 10,714
  • 15
  • 75
  • 130

1 Answers1

3

It seems Paraview accepts raw data http://paraview.org/Wiki/Data_formats#Raw_files.
So why not just write out your data in a triple for-loop to raw binary data?

How to open raw data file in Paraview (edit):

Example: Fuel from Uni Tuebingen

  1. open .raw file

  2. properties: Data Scalar Type: unsigned char
    properties: Data Extend: 1<tab>64<tab>1<tab>64<tab>1<tab>64
    properties: Apply

  3. click on Contour (next to the calculator symbol) properties: Apply

Now you should see something. From here you can play around a bit.

In VTK itself (i.e. calling from C++) I remember there were some nice volume render algorithms available (ray casting, 2D textures, etc) but I could not find them in paraview right now. Edit: But Robert could (see comment).

Kyss Tao
  • 521
  • 4
  • 13
  • Good idea! Thanks. I tried to load first example into ParaView from http://www.gris.uni-tuebingen.de/edu/areas/scivis/volren/datasets/datasets.html (Aneurism), but I was not able to obtain the same picture as on icon http://www.gris.uni-tuebingen.de/edu/areas/scivis/volren/datasets/images/aneurism.jpg. How to achieve such picture? I am new in ParaView. – sergtk Mar 11 '12 at 00:51
  • 1
    I extended my answer to explain how to load the volume data from the webpage and create a contour. The nice pictures on the webpage might have been made with vtk directly, so no guarantee they are possible to obtain with Paraview – Kyss Tao Mar 11 '12 at 02:07
  • 1
    http://public.kitware.com/pipermail/paraview/2003-January/000078.html: a bit outdated (from 2003) but not a good sign – Kyss Tao Mar 11 '12 at 02:12
  • Tao, thanks a lot for so clear answer and comments! I can view my object! it works both for .raw and for .vtk as well. it seems I should learn ParaView, because it is not obvious how to use it from the beginning – sergtk Mar 11 '12 at 06:41
  • 1
    ParaView does support volume rendering. Under the display tab change the representation to Volume. You can than adjust the Volume rendering algorithm under display->Volume mapper. – RobertJMaynard Mar 26 '12 at 21:01
  • Unfortunately the Uni Tuebingen website is no longer available. – Nathaniel Jones Apr 12 '21 at 19:51