Code covered by the BSD License  

Highlights from
Export figure to 3D interactive PDF

4.25

4.2 | 5 ratings Rate this file 84 Downloads (last 30 days) File Size: 1.64 MB File ID: #37640
image thumbnail

Export figure to 3D interactive PDF

by Ioannis Filippidis

 

27 Jul 2012

Export figure as a U3D file or directly to 3D interactive graphics within a PDF.

| Watch this File

File Information
Description

FIG2U3D saves the figure as a U3D file for inclusion as an interactive 3-dimensional figure within a PDF. Either LaTeX or Adobe Acrobat can be used to embed the U3D file in the PDF.

The IDTF2U3D executables are needed from:
   http://sourceforge.net/projects/u3d/
To obtain them download:
   http://www.mathworks.com/matlabcentral/fileexchange/25383-matlab-mesh-to-pdf-with-3d-interactive-object
and place the "bin" directory in the "idtf2u3d" directory of the fig2u3d distribution.

A VWS file is also created, which contains the current camera view of the axes saved. This file can be used to set the figure's default view in the PDF to be the same with the open figure window in MATLAB.

The media9 LaTeX package can import U3D files with their associated VWS files in a PDF document. It can be found here:
   http://www.ctan.org/tex-archive/macros/latex/contrib/media9

For PDF readers which do not render 3D figures, it is possible to include an alternative 2D image as a substitute to the 3D object. For conveniency, the script saves a 2D image together with U3D file. File type and other options for exporting this 2D image can be specified as additional arguments.

FIG2PDF3D Converts the figure directly to a PDF containing only an interactive 3D graphics object.

Graphics object supported for export include:

   line, surface, patch, quivergroup, contourgroup.

Line colors and marker styles, surfaces and quivers with NaNs and surface shading are supported. Multiple instances of various objects can be plotted in the same axes and exported. Note that some limitations apply, for example filled contours are not yet supported.

Dependency detailed info:

for fig2u3d: idtf2u3d converter executable, download:
   http://www.mathworks.com/matlabcentral/fileexchange/25383-matlab-mesh-to-pdf-with-3d-interactive-object
and place the "bin" directory in the "idtf2u3d" directory of the fig2u3d distribution.

for fig2pdf3d: latex distribution (e.g. MikTeX, TeXLive, MacTeX etc.)
http://miktex.org/
http://www.tug.org/texlive/
http://tug.org/mactex/

and media9 (preferred) or movie15 LaTeX package
http://www.ctan.org/pkg/media9

Acknowledgements

Remnan, Verbatim: Get The Text Of A Block Comment., Export Fig, Create 3 D Interactive Html File From Matlab Surface, Matlab 3 D Figure To 3 D (X)Html, Arclength, Vector Norm, Matlab Mesh To Pdf With 3 D Interactive Object, Generate Vertices, Faces And Color For U3d Format, Generate U3 D Files From Stl Models For Making Multilayer 3 D Pdf Figures, Plot 2/3 D Point(S), Vectorized Meshgrid, Plot 2/3 D Vector(S), Cell Extrema, Normalize N D Vectors In Single Matrix Or N Component Matrices, and Take & Restore Hold inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Other requirements for fig2u3d: idtf2u3d converter executable for fig2pdf3d: latex distribution (e.g. MikTeX, TeXLive, MacTeX etc.) and media9 (preferred) or movie15 LaTeX package
Tags for This File  
Everyone's Tags
3d, contour, contourgroup, data export, export, graphics, idtf, latex, mathematics, media9, mesh, movie15, pdf, pdflatex, plot, quiver, quivergroup, save, surface, u3d, vector, vision, xelatex
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
23 Jan 2013 Ioannis Filippidis

Hi dan,

The issue is probably that the missing function is not in your path. You can add all the directories of the package to your path by using the :pathtool" command. Please try to see if its working with other plots (which have surfaces).

Apart from this, this software does not yet support scattergroups. I tried the scatter3 help example and although I got no errors, the geometry exported to the u3d file was essentially empty.

The reason is that some checks are performed. If you successfully run the script for a scatter3 plot, it will report that it did not find any surfaces, lines, patches, quivergroups or contourgroups.
It turns out that scatter3 produces hggroups and the quivergroup and contourgroup export functions look for hggroups. However, they then filter them to see if they are quivers or contours. Otherwise nothing is exported.

In the future there are plans to extend the supported plot types. For the moment all these tests aim to avoid cryptic errors caused by unsupported (or untested) plots. Probably the existing functionality does support scatter3 (i.e., they are only points, so the interface to the output functions will be relatively simple, compared to e.g. quiver output, which has to care about many details). But the wrapper for scatter3 is not yet part of the code.

18 Jan 2013 dan

Hi Ioannis,
the pdf output of your manual looks really nice.
Unfortunately, it the script always gives me the following error message:
"Undefined function 'u3d_pre_surface' for
input arguments of type 'double'."
I am using scatter3 to generate the matlab figure. Does the script support this?

Thank you for your nice work!
dan

20 Dec 2012 Ioannis Filippidis

Please note that if one is willing to employ another 4 to 5 programs, one of which is a proprietary plug-in costing $99, all of which should be manually handled using the mouse and keyboard, with the obvious issue of having to deal with all the possible incompatibilities and other bugs that may arise as these update and change, then the purpose of writing a compact and clean code for doing the same in code or with one short command at the MATLAB command prompt, with fully open source code (MATLAB excluded) which is free and transparent, is totally defeated.

11 Dec 2012 Martin Trauth

I have just (11 Dec 2012) posted an alternative way to create interactive PDFs without LaTeX:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/321562

04 Dec 2012 Ioannis Filippidis

Hi Mario Garcia and Sheng Yue,

If you are using OSX 10.8+ there may be issues with the environment variables.
Please try this fix in idtf2u3d.m, hope this helps:

%% prepare command
mfiledir = fileparts(mfilename('fullpath') );
curpath = pwd;

% Intel Mac
if ismac
idtf_executable_path = [mfiledir, '/bin/maci/'];
cd(idtf_executable_path)

IDTFcmd = './IDTFConverter';

%temp = [getenv('DYLD_LIBRARY_PATH'), ':"', mfiledir, '/bin/maci/"'];
%setenv('DYLD_LIBRARY_PATH', temp)
%IDTFcmd = ['"', mfiledir, '/bin/maci/', IDTFcmd, '"'];
end

% Linux
if isunix && ~ismac
idtf_executable_path = [mfiledir, '/bin/glx/'];
cd(idtf_executable_path)

IDTFcmd = './IDTFConverter.sh';

%temp = [getenv('LD_LIBRARY_PATH'), ':"', mfiledir, '/bin/glx/"'];
%setenv('LD_LIBRARY_PATH', temp)
%IDTFcmd = ['"', mfiledir, '/bin/glx/', IDTFcmd, '.sh"'];
end

% windows
if ispc
win_mfiledir = strrep(mfiledir, '\', '\\');
IDTFcmd = ['"', win_mfiledir, '\\bin\\w32\\IDTFConverter.exe"'];
end

%% idtf -> u3d conversion
s = [IDTFcmd, ' -input "%s" -output "%s"'];
idtf2u3dcmd = sprintf(s, idtffile, u3dfile);
disp(idtf2u3dcmd)
[status, result] = system(idtf2u3dcmd);
cd(curpath) % go back

disp(result)
if status ~= 0
error('idtf2u3d:conversion',...
'IDTFConverter executable returned with error.')
end

04 Dec 2012 Mario GarcĂ­a

Hi Sheng Yue,

idtf2u3d does not work correctly on my computer, can you help me?

Error using idtf2u3d (line 97)
IDTFConverter.exe returned with error.

09 Nov 2012 Ioannis Filippidis

Hi Delit,

3D PDF files can have text in 3D.
But this depends on which intermediate file is used to import the 3D information to the PDF. In principle it is possible to insert text in the U3D file, but it is much more difficult than in a PRC file. For the moment this code uses U3D files, because it is based on previous work by others, which developed the required intermediate tools. It is possible to create an exporter to PRC, but one would have to look at the code already used for this purpose in Asymptote for example, and convert it to MATLAB, which I would like to try, but is not planned for the near future.

09 Nov 2012 Delit

Is it possible to insert scatter and text in the 3D pdf interactive?

05 Oct 2012 Sheng Yue

need to change idtf2u3d.m to make it work on my computer.
Still a nice work!

30 Jul 2012 Joachim  
29 Jul 2012 Joachim  
27 Jul 2012 Sven Koerner  

Contact us