Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenMesh
openmesh-python
Commits
3f5e35d7
Commit
3f5e35d7
authored
Apr 02, 2019
by
Alexander Dielen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added documentation for cpp properties
parent
48558ff1
Pipeline
#9482
passed with stages
in 5 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
docs/properties.rst
docs/properties.rst
+61
-0
No files found.
docs/properties.rst
View file @
3f5e35d7
...
...
@@ -4,3 +4,64 @@ Properties
**********
TODO
A Note to OpenFlipper Users
###########################
When using the OpenMesh Python Bindings within OpenFlipper, it is often
necessary to pass data to one of the OpenFlipper plugins. Properties provide a
straightforward way to do this. For example, we may wish to calculate a scalar
vertex property using the python scripting interface and then visualize the
result using OpenFlipper's PropertyVisualizer plugin.
However, since all properties created using the mechanisms described above are
stored as python objects, most existing OpenFlipper plugins will not know how to
interpret them. To circumvent this problem, OpenFlipper users can create native
C++ properties by calling :func:`~openmesh.TriMesh.add_vertex_cpp_property`,
:func:`~openmesh.TriMesh.add_halfedge_cpp_property`,
:func:`~openmesh.TriMesh.add_edge_cpp_property` and
:func:`~openmesh.TriMesh.add_face_cpp_property` respectively.
For example,
.. code:: python
mesh.add_vertex_cpp_property("my_double_property", "double")
will create a vertex property with the name "my_double_property" and type
``double``. In addition to ``double``, the following C++ types are currently
supported: ``bool``, ``int``, ``float``, ``double``, ``vec2f``, ``vec3f``,
``vec4f``, ``vec2d``, ``vec3d``, ``vec4d``
Native C++ properties can be set like any other property, i.e.
.. code:: python
mesh.set_vertex_property("my_double_property", om.VertexHandle(0), 42.0)
will attempt to set the property for vertex 0 by converting the given value
(here 42.0) to a native ``double``. In case the conversion fails, a
``ValueError`` exception is thrown. Similarly,
.. code:: python
mesh.vertex_property("my_double_property", om.VertexHandle(0))
will retrieve the property for vertex 0.
As before, :func:`~openmesh.TriMesh.has_vertex_property`,
:func:`~openmesh.TriMesh.has_halfedge_property`,
:func:`~openmesh.TriMesh.has_edge_property` and
:func:`~openmesh.TriMesh.has_face_property` can be used to check if a property
with the given name already exists, while
:func:`~openmesh.TriMesh.remove_vertex_property`,
:func:`~openmesh.TriMesh.remove_halfedge_property`,
:func:`~openmesh.TriMesh.remove_edge_property` and
:func:`~openmesh.TriMesh.remove_face_property`
can be used to remove a property.
.. caution:: When using the OpenMesh Python Bindings within OpenFlipper,
internal properties such as ``v:points`` and ``v:normals``, which store the
vertex coordinates and normals respectively, are exposed to python. Do not
remove these properties!
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment