Matlab program for making 3D pdf figures

This is a page about making u3d files using matlab for importing 3D figures into PDF files.

Introduction to Creating 3D PDF Figures from Matlab.

I learned about 3D PDF figures in Acrobat Reader around 2009 (in a Nature paper that included a 3D pdf and a youtube video demo of the 3D PDF). They seemed interesting, but I had no particular need to create 3D pdf figures myself until this year. My objective was to take a mesh object in Matlab and export a multilayer mesh object (with transparency) for export into a pdf file. The process is not very straightforward, and this document aims to clarify the process for others.

General Process for Creating a 3D Figure

.STL File (triangular mesh) → .IDTF File (intermediate file) → .U3D File (Universal 3D) → .PDF (final figure)

As shown in the diagram above, in order to create a 3D figure, a triangular mesh is required. In Matlab triangular meshes are commonly plotted with the patch() command. Many programs can import/export triangular meshes as .STL files (a stereolithography file format). Several programs can also convert .STL files directly to .U3D files (like the open-source Meshlab), or even directly to .PDF files (with Adobe Acrobat 9 Pro Extended, or with the Tetra4D addon and Adobe Acrobat X Pro). Unfortunately the Tetra4D software is quite expensive, and the Acrobat 9 Pro Extended is not available at my university. Meshlab is able to convert a single-layer to the U3D format, but not to specify the layer color or transparency.

Once a U3D file has been created, there are two basic options to convert the U3D files into PDF format. One requires the commercial Adobe Acrobat Pro software (versions 7, 8, 9, or X all include the required functionality), while the other option uses the free open-source LaTeX software package (MiKTeK and the movie15 package) to compile the final PDF. Both these options use a .U3D file of the model in order to generate the 3D figure. However, U3D files are not very easy to create directly.

Instead, an IDTF file must be created, and that is in turn converted into a Universal 3D (.U3D) file. Fortunately, the IDTF to U3D converter is freely available on sourceforge. Unfortunately, the free software comes as a fairly large download (U3D_A_061228_5.zip, 2007-01-16, 36.3 MB). More information about the U3D format is available from (ecma-international.org), and a history of the U3D format is available at (okino.com). The source for a repackaged version of the U3D converter is also available through (sourceforge.net mathgl). This version can be compiled with the GNU build system, and Alexandre Gramfort created a Matlab project that uses LaTeX and allows the PDF to be created from windows, mac or linux (mathworks.com matlab-mesh-to-pdf-with-3d-interactive-object). However, for those who just want a win32 binary, I have collected the binaries required for windows (from the U3D sourceforge project) and posted them on my web site as a 2 MB download (esmonde-white.com matlab-program-for-making-3d-pdf-figures).

Matlab Process for Creating a 3D Figure

Alexandre Gramfort’s Matlab project works well for creating a single-layer colored 3D PDF figure. However, the existing code did not make multilayer meshes with transparency, so I modified his code and repackaged it into a new project.

To create a 3D figure, start by loading your mesh. You might want to use stlread.m to load a binary .stl file from a CAD program or a drawing program.

Next, convert the mesh to the required format using mesh2idtf.m (MESH to IDTF). There are detailed instructions in the .m file. This is the point where multiple mesh layers can be assembled, and also where transparency is specified.

Next, save the mesh structure into a .idtf file using save_idtf.m. There are detailed instructions in the .m file.

Finally, convert the .idtf file into a .u3d file using the program idtf2u3d.m (IDTF to U3D).

This U3D file can now be loaded into a figure using Adobe Acrobat Pro using the ‘Multimedia’ -> ‘3D Tool’ option.

Here are all the required files:

3D Models in Biomedical Spectroscopy

A great application for 3D models is in optical tomography. The open source software NIRFAST, an open source software for multi-modal optical molecular imaging, is the package I have used. The Slicer program associated with NIRFAST can also be used to create 3D models from various types of data, including CT and MR tomography data.