[vtkusers] how to convert vtk polydata to dif file format

Sebastian Hilbert sebastian.hilbert at gmx.net
Sun Oct 4 20:13:09 EDT 2015


Hi,

I am trying to convert a model of the heart which is available as either stl 
or vtk polydata to a new file format called diffusion image format (dif)

All files are provided below. The main question is. How do I construct the dif 
file when I have only vtk and stl file available ?

dif is a format used by the medical software Ensite from St. Jude and looking 
at the spec for the dif format it seems related to what vtk can provide.

It seems to work with vertices , normals and polygons. 

I wonder if anyone has some advice on how to map data obtained from an stl 
file or vtk polydata file to data used in the dif format. How do I extract 
vertices, normals and polygons from either stl and/or vtk ?

The target format is like this:

 <DIFBody>
    <Volumes number="1">
      <Volume name="Left Atrium" color="eae0b2">
        <Vertices number="3984">
           32.4603  6.0825  -40.3249 
           13.9858  7.9016  -41.0501 
           16.6287  7.6514  -40.4356 
           30.7806  7.9503  -41.1414  
        </Vertices>
        <Normals number="3984">
           0.220882  -0.586701  -0.779098 
           -0.082953  -0.169572  -0.982021 
           0.393210  -0.647443  -0.652842 
           -0.106461  -0.248735  -0.962703  
        </Normals>
        <Polygons number="7968">
          3 40 8
          17 10 13
          41 13 42
          4 36 43
          </Polygons>
      </Volume>
    </Volumes>
    <Labels number="0">
    </Labels>
   </DIFBody>
</DIF>

Looking at the vtk file the polygons are different from the ones in the xml 
(dif) file. Looking at the stl file (ascii) I can see some vertex lines that 
match a line in the vertices section of the xml (dif) file but there are a lot 
more vertex lines in the stl file then there are in the xml (dif file).

I would prefer to use python if that is an option.

If anyone wants to have a look here are the correspondig files

vtk: https://146.0.105.21/owncloud/index.php/s/NZqGwdQQSramk1w
stl: https://146.0.105.21/owncloud/index.php/s/tWv7yKttA15hdoL
dif: https://146.0.105.21/owncloud/index.php/s/3R8oKRxXK2oR5DD

Any help is appreciated.

Sebastian


More information about the vtkusers mailing list