index.html 5.3 KB

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