index.html 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <link rel='stylesheet' type='text/css' href='../style.css' >
  5. <title>libigl file formats</title>
  6. </head>
  7. <body class=article_outer>
  8. <div class=article_inner>
  9. <a href=..><img src=../libigl-logo.jpg alt="igl logo" class=center></a>
  10. <h1>libigl file formats</h1>
  11. <ul>
  12. <li><a href="./bf.html">.bf</a> ASCII files for representing skeletal bone "forests"</li>
  13. <li><a href="./dmat.html">.dmat</a> uncompressed ASCII/binary files for dense matrices</li>
  14. <li><i>.ele</i> Element (triangle or tet) list. This format comes in similar flavors: <a
  15. href=http://tetgen.berlios.de/fformats.ele.html>tetgen's</a>, <a
  16. href=http://www.cs.berkeley.edu/~jrs/stellar/#fileformats>stellar's</a>,
  17. and <a href=https://www.cs.cmu.edu/~quake/triangle.ele.html>triangle's</a>.
  18. The formats of TetGen and stellar are identical upto conventions on index
  19. ordering and number of allowed attributes (unverified).</li>
  20. <li><a href=http://tetgen.berlios.de/fformats.face.html
  21. class=missing>.face</a> TetGen's file format for simplicial facets.</li>
  22. <li><a href="http://www.ann.jussieu.fr/frey/publications/RT-0253.pdf#page=33">.mesh</a> Medit's triangle surface mesh + tetrahedral volume mesh file format, see page 33, section 7.2.1</li>
  23. <li><i>.node</i> List of points (vertices). Described indentically (upto
  24. accepted dimensions, use of attributes and boundary markers) by <a
  25. href="https://www.cs.cmu.edu/~quake/triangle.node.html">Triangle</a>, <a
  26. href=http://tetgen.berlios.de/fformats.node.html>TetGen</a>, and <a
  27. href=http://www.cs.berkeley.edu/~jrs/stellar/#fileformats>Stellar</a>.
  28. </li>
  29. <li><a href="http://tetgen.berlios.de/fformats.off.html">.off</a> Geomview's polyhedral file format</li>
  30. <li><a href="http://en.wikipedia.org/wiki/Wavefront_.obj_file#File_format">.obj</a> Wavefront object file format. Usually unsafe to assume anything more than vertex positions and triangle indices are supported</li>
  31. <li><a
  32. href=https://en.wikipedia.org/wiki/Portable_Network_Graphics>.png</a>
  33. Portable Network Graphics image file. IGLLIB (in the libiglpng extra)
  34. supports png image files via the <a href=https://github.com/yig/yimg>yimg</a>
  35. library. Alpha channels and compression are suppported.</li>
  36. <li><i>.poly</i> Piecewise-linear complex. This format comes in many similar but importantly different flavors:
  37. <a href="https://www.cs.cmu.edu/~quake/triangle.poly.html">triangle's</a>, <a href="http://tetgen.berlios.de/fformats.poly.html">tetgen's</a>, <a href="http://sparse-meshing.com/svr/0.2.1/format-poly.html">pyramid/SVR's</a></li>
  38. <li><a href=./rbr.html>.rbr</a> ASCII files for saving state of ReAntTweakBar</li>
  39. <li><a href=http://en.wikipedia.org/wiki/STL_(file_format)>.stl</a> 3D Systems' CAD and 3D printing mesh file format. ASCII and binary versions.</li>
  40. <li><a href=http://en.wikipedia.org/wiki/Truevision_TGA>.tga</a> Truevision TGA or TARGA image file format. IGLLIB supports only very basic reading and writing RGB/RGBA files without colormaps and (unverified) run-length compression.</li>
  41. <li><a href="./tgf.html">.tgf</a> ASCII files for representing control handle graphs</li>
  42. <li><a href="http://en.wikipedia.org/wiki/VRML#WRL_File_Format">.wrl</a>
  43. VRML (Virtual Reality Modeling Language) file format for 3D scenes.</li>
  44. <li><a href="./xml.html">.xml</a> XMLSerializer's file format containing the serialization of object data structures.</li>
  45. </ul>
  46. <h3>Triangle mesh file format performance</h3>
  47. <p>
  48. <a
  49. href="http://en.wikipedia.org/wiki/Wavefront_.obj_file#File_format">.obj</a>
  50. and <a href="http://tetgen.berlios.de/fformats.off.html">.off</a> file
  51. formats support meshes with arbitrary polygon degrees. However, often we are
  52. only working with triangle meshes. Further, .obj files do not have useful
  53. headers revealing the number of elements. For triangle meshes, .off and .obj
  54. are inferior file formats to the <a
  55. href="http://www.ann.jussieu.fr/frey/publications/RT-0253.pdf#page=33">.mesh</a>
  56. file format. The current (version 0.1.6) IO functions for these file formats perform as follows for reading and writing a 300,000 triangle mesh:
  57. </p>
  58. <pre><code>
  59. writeOBJ: 1.33742 secs
  60. writeOFF: 0.510111 secs
  61. writeMESH: 0.218139 secs
  62. readOBJ: 1.3782 secs
  63. readOFF: 0.691496 secs
  64. readMESH: 0.242315 secs
  65. </code></pre>
  66. <p>
  67. This reveals that .mesh is 6.5x faster than .obj and about 2.5x faster than .off.
  68. </p>
  69. <p>
  70. While .obj files support normals, it is typically much faster to (re)compute
  71. normals from the geometry using <code>per_face_normals</code>,
  72. <code>per_vertex_normals</code>, <code>per_corner_normals</code> than to read
  73. and write them to files.</p>
  74. <p>It gets even better if you're willing to use a nonstandard format. If your
  75. triangle mesh is in (<code>V</code>,<code>F</code>) then you can read and
  76. write those variables as dense matrices of doubles to
  77. <a href="./dmat.html">.dmat</a> uncompressed <strong>binary</strong> files.
  78. This not only ensures perfect precision but also big speed ups. On that same
  79. 300,000 triangle mesh, .dmat achieves:</p>
  80. <pre><code>
  81. writeDMAT: 0.0384338 secs
  82. readDMAT: 0.0117921 secs
  83. </code></pre>
  84. <p>This reveals that binary .dmat files are 34x/116x faster at writing and
  85. reading than .obj and a hefty 5x/20x over .mesh. In this case it may pay to
  86. compute normals once into <code>N</code> and also read and write it to a
  87. .dmat file.</p>
  88. </div>
  89. </body>
  90. </html>