Skip to content

Commit

Permalink
update readwrite.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaak Lim committed Jun 11, 2018
1 parent 40f8a82 commit 5d35881
Showing 1 changed file with 6 additions and 60 deletions.
66 changes: 6 additions & 60 deletions docs/readwrite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,16 @@
I/O Functions
*************

OpenMesh provides two functions that read and write meshes from and to files:
:func:`~openmesh.read_mesh` and :func:`~openmesh.write_mesh`
OpenMesh provides functions that read and write meshes from and to files:
:func:`~openmesh.read_trimesh`, :func:`~openmesh.read_polymesh` and :func:`~openmesh.write_mesh`

.. code:: python
import openmesh as om
mesh = om.TriMesh()
om.read_mesh(mesh, "bunny.ply")
trimesh = om.read_trimesh("bunny.ply")
polymesh = om.read_polymesh("bunny.ply")
# modify mesh ...
om.write_mesh(mesh, "bunny.ply")
The file type is automatically deduced from the file extension. OpenMesh
currently supports five file types: .obj, .off, .ply, .stl and .om

The behaviour of the I/O functions can be fine-tuned by passing an instance of
the :class:`~openmesh.Options` class to either :func:`~openmesh.read_mesh` or
:func:`~openmesh.write_mesh`. When reading a file the options are used as hints,
i.e. depending on the format we can help the reader to interpret the data
correctly. When writing a file the options determine whether or not to use the
binary variant of the respective file format and the desired byte-ordering.

.. code:: python
import openmesh as om
mesh = om.TriMesh()
# hint: read vertex normals
options = om.Options()
options += om.Options.VertexNormal
om.read_mesh(mesh, "bunny.ply", options)
# write binary file
options = om.Options()
options += om.Options.Binary
om.write_mesh(mesh, "bunny_binary.ply", options)
The :class:`~openmesh.Options` class controls the behaviour of the I/O functions
by means of enabled/disabled bits in a bitset. The following list contains all
available option bits:

- mode bits - control binary reading/writing

- Options.Binary
- Options.MSB
- Options.LSB
- Options.Swap (MSB|LSB)

- property bits - controls which standard properties to read/write

- Options.VertexNormal
- Options.VertexTexCoord
- Options.VertexColor
- Options.FaceNormal
- Options.FaceColor
- Options.ColorAlpha
- Options.ColorFloat

Multiple options can be combined using simple arithmetic:

.. code:: python
om.write_mesh(trimesh, "bunny.ply")
options = om.Options()
options += om.Options.VertexNormal
options += om.Options.VertexColor
OpenMesh currently supports five file types: .obj, .off, .ply, .stl and .om

0 comments on commit 5d35881

Please sign in to comment.