«

»

Aug 18

3D PDFs

Last week I was asked to figure out how to embed 3D objects into PDF.  This seemed like it would be simple once I figured out which tools to use.  This is partially true, however Adobe decided to use U3D format for its internal 3D viewer, which seems less than universal in my opinion.  The only path I could find to get .vtp files into the u3d format was to convert the .vtp to x3d files in Paraview, save it, then use meshlab to convert it to U3D.  The export in meshlab even provides a .tex file so you can generate a PDF with it from any laTeX program.  There were a couple of pieces that weren’t entirely clear that I was able to work through.  It was obscure enough to warrant this post for sure.  Here are the steps for Ubuntu 15.04:

1.  Get VTP file you want to convert (should be able to get these from turbulence cutout service soon!)

2.  Load into Paraview, then export scene as x3d.

3. Install mesh lab using sudo apt-get install meshlab

4. Mesh lab does not have the “universal” converter built in, so you have to get it and install it separate.

5.  Download the latest converter from http://www2.iaas.msu.ru/tmp/u3d/u3d-1.4.5_current.zip.  This is the only version I found that compiled and worked without anything special in Ubuntu.

6.  Unzip the converter, and then use ccmake-gui (sudo apt-get install ccmake-qt-gui if you don’t have it) to configure it and setup the build directory.

7. Generate the build files.

8. Go to that directory of build files and do a make;sudo make install.  This should put them in /usr/local/bin, which normally is ok, but meshlab has a hardcoded link to the IDTFConverter in /usr/bin, so I just symlinked it with: ln -s /usr/local/bin/IDTFConverter /usr/bin

9.  Once this is done, you are set and you can load the x3d file, and export to u3d.  It will create two files, the x3d file and the tex file.  Load the tex up in your favorite LaTeX editor and make any changes and export to PDF, and you are done!

Meshlab-Screenshot

View in Meshlab

pdf-vorticity

Final view in PDF