index.html 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/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>
  40. <li><a href="./tgf.html">.tgf</a> ASCII files for representing control handle graphs</li>
  41. <li><a href="./xml.html">.xml</a> XMLSerializer's file format containing the serialization of object data structures.</li>
  42. </ul>
  43. <h3>Triangle mesh file format performance</h3>
  44. <p>
  45. <a
  46. href="http://en.wikipedia.org/wiki/Wavefront_.obj_file#File_format">.obj</a>
  47. and <a href="http://tetgen.berlios.de/fformats.off.html">.off</a> file
  48. formats support meshes with arbitrary polygon degrees. However, often we are
  49. only working with triangle meshes. Further, .obj files do not have useful
  50. headers revealing the number of elements. For triangle meshes, .off and .obj
  51. are inferior file formats to the <a
  52. href="http://www.ann.jussieu.fr/frey/publications/RT-0253.pdf#page=33">.mesh</a>
  53. 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:
  54. </p>
  55. <pre><code>
  56. writeOBJ: 1.33742 secs
  57. writeOFF: 0.510111 secs
  58. writeMESH: 0.218139 secs
  59. readOBJ: 1.3782 secs
  60. readOFF: 0.691496 secs
  61. readMESH: 0.242315 secs
  62. </code></pre>
  63. <p>
  64. This reveals that .mesh is 6.5x faster than .obj and about 2.5x faster than .off.
  65. </p>
  66. <p>
  67. While .obj files support normals, it is typically much faster to (re)compute
  68. normals from the geometry using <code>per_face_normals</code>,
  69. <code>per_vertex_normals</code>, <code>per_corner_normals</code> than to read
  70. and write them to files.</p>
  71. <p>It gets even better if you're willing to use a nonstandard format. If your
  72. triangle mesh is in (<code>V</code>,<code>F</code>) then you can read and
  73. write those variables as dense matrices of doubles to
  74. <a href="./dmat.html">.dmat</a> uncompressed <strong>binary</strong> files.
  75. This not only ensures perfect precision but also big speed ups. On that same
  76. 300,000 triangle mesh, .dmat achieves:</p>
  77. <pre><code>
  78. writeDMAT: 0.0384338 secs
  79. readDMAT: 0.0117921 secs
  80. </code></pre>
  81. <p>This reveals that binary .dmat files are 34x/116x faster at writing and
  82. reading than .obj and a hefty 5x/20x over .mesh. In this case it may pay to
  83. compute normals once into <code>N</code> and also read and write it to a
  84. .dmat file.</p>
  85. </div>
  86. </body>
  87. </html>