johnyf / fig2u3d

Export MATLAB figure as U3D file or directly to 3D interactive PDF
http://www.mathworks.com/matlabcentral/fileexchange/37640-export-figure-to-3d-interactive-pdf
BSD 2-Clause "Simplified" License
63 stars 25 forks source link

Complications with NaNs #4

Open a-ma72 opened 8 years ago

a-ma72 commented 8 years ago

Hi, thanks for this, works very fine!

I just have problems with lines containing NaNs: plot( 1:5, [1 2 NaN 4 5] ) fig2u3d( gca, 'test' );

Throws: Profile = 0 Scaling factor = 1.000000 Debug level = 0 Position Quality = 1000 Texture Coordinate Quality = 1000 Normal Quality = 1000 Diffuse Color Quality = 1000 Specular Color Quality = 1000 Geometry Default Quality = 1000 Texture Quality = 100 Animation Quality = 1000 Zero Area Faces Removal = ENABLED Zero Area Face Tolerance = 0.000012 Exclude Normals = FALSE Export Option Flags = ffff Texture size limit = 0 Exit code = 81110005

Grabbing through some code, least exit code means "IFX_E_FLOAT_NOT_FOUND" (ConverterResult.h) in component 0x0111 which is "IFXRESULT_CONVERTERS" (IFXResultComponentEngine.). That error is ommitted in FileScanner.cpp only (IFXRESULT FileScanner::ScanFloat( F32* pNumber ) ).

I rebuilt IDTFConver (Version u3d-1.4.3) from scratch, but the same failure occures, so I guess the idtf input file, created from MATLAB scripts, is malformed.

Do you have any ideas?

Kindly regards, Andreas

johnyf commented 8 years ago

One way to avoid issues caused by NaN values in lines would be to omit points with NaN values when plotting a line. NaNs are supported for surfaces, in particular they are removed here. I have a note about NaN values in lines, but they do not seem to be removed in that case.

I presume that the reasoning must have been that sometimes NaNs cannot be avoided in a surface, whereas one can always split a line into multiple ones, at a higher level (i.e., outside the exporting package), which is more reliable, and easier to develop.

Having said this, I may consider adding support in the future for handling NaN values in lines. Please consider opening a pull request.