Hello everybody,
First, thanks a lot for your neat work on openmesh! I am creating meshes
for 3D modelling as a part of my masters thesis and I am glad to use a well
written library.
I am able to build many things and play with it thanks to openmesh,
however I encounter some troubles from time to time. I asked some
communities (stackoverflow for instance) but the subject does not seem to
be hot right now, and experts are hard to find, so I am asking you.
I use openmesh with Python 3.6. Openmesh was installed with a 'pip install
openmesh' :
*1/ First*, I wanted to add custom propetries to vertices of the mesh, it
does work but does not write in the file, or it is not read when the file
is re-opened, here is my code :
import openmesh as OM import numpy as np
mesh = OM.TriMesh()
#Add some vertices
vh0 = mesh.add_vertex(np.array([0,0,0]));
vh1 = mesh.add_vertex(np.array([1,0,0]));
vh2 = mesh.add_vertex(np.array([1,1,0]));
vh3 = mesh.add_vertex(np.array([0,1,0]));
#Create some data
data = np.arange(mesh.n_vertices)
#Add custom property for vh in mesh.vertices():
mesh.set_vertex_property('prop1', vh, data[vh.idx()])
#Check properties have been added correctly
print(mesh.vertex_property('prop1'))
#prints data matrix
OM.write_mesh('mesh.om',mesh)
#Re-load mesh in another instance :
mesh1 = OM.TriMesh()
mesh1 = OM.read_trimesh('mesh.om')
#Check property is still there print(mesh1.vertex_property('prop1'))
#Prints a matrix of 'None'...
So, I cannot save then read a custom property. (So far, I save custom
properties into a csv file, which is okay but not convienient.)
*2/ Another issue* I encounter is when I want to save a mesh into a vtk
file. The writter writes nothing . Here is my code :
import openmesh as OM
mesh = OM.TriMesh()
#Add some vertices
vh0 = mesh.add_vertex([0,0,0])
vh1 = mesh.add_vertex([0,1,1])
vh2 = mesh.add_vertex([1,0,1])
vh3 = mesh.add_vertex([1,1,0])
#Add some faces (we are building a tetrahedron here)
mesh.add_face(vh0,vh1,vh2)
mesh.add_face(vh0,vh2,vh3)
mesh.add_face(vh0,vh3,vh1)
mesh.add_face(vh1,vh3,vh2)
OM.write_mesh('TEST_MESH.vtk',mesh)
Nothing is written. (When I put .ply or .om ... instead of .vtk, it
works just fine)
According to the documentation, it should work, so I don't know what I am
doing wrong. If you have any tips or advices, it would be very appreciated,
Thank you for your time, thank you for your help,
Charles Duvert.