How to assign a quality value to each vertex in a mesh? #63
-
|
Hello, I have numpy arrays of vertices, faces, and vertex normals that I can use to define a mesh with Here is an example of what I am trying to do with a small cube in an interactive Python session: >>> import pymeshlab as pyml
>>> import numpy as np
>>> verts = np.array([
[-0.5, -0.5, -0.5],
[ 0.5, -0.5, -0.5],
[-0.5, 0.5, -0.5],
[ 0.5, 0.5, -0.5],
[-0.5, -0.5, 0.5],
[ 0.5, -0.5, 0.5],
[-0.5, 0.5, 0.5],
[ 0.5, 0.5, 0.5]])
>>> faces = np.array([
[-0.5, -0.5, -0.5],
[ 0.5, -0.5, -0.5],
[-0.5, 0.5, -0.5],
[ 0.5, 0.5, -0.5],
[-0.5, -0.5, 0.5],
[ 0.5, -0.5, 0.5],
[-0.5, 0.5, 0.5],
[ 0.5, 0.5, 0.5]])
>>> vnorms = np.array([
[-0.57735027, -0.57735027, -0.57735027],
[ 0.33333333, -0.66666667, -0.66666667],
[-0.66666667, 0.33333333, -0.66666667],
[ 0.66666667, 0.66666667, -0.33333333],
[-0.66666667, -0.66666667, 0.33333333],
[ 0.66666667, -0.33333333, 0.66666667],
[-0.33333333, 0.66666667, 0.66666667],
[ 0.57735027, 0.57735027, 0.57735027]])
# arbitrary values to go with vertices
>>> vals = np.array([0.84328472, 0.69231293, 0.13644346, 0.33825513, 0.30680527,
0.72530452, 0.15571249, 0.92643005])With those arrays, I can create a >>> box = pyml.Mesh(vertex_matrix=verts, face_matrix=faces, v_normals_matrix=vnorms)From that I can read back out the vertices, faces, and vertex normals I set. The vertex quality matrix is also initialized: >>> box.vertex_quality_matix()
array([0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)However if I try to set them to my desired value, I get an >>> box.vertex_quality_matrix = vals
...
----> 1 box.vertex_quality_matrix = vals
AttributeError: 'pymeshlab.pmeshlab.Mesh' object attribute 'vertex_quality_matrix' is read-onlyIf I try to instantiate a new mesh with >>> box2 = pyml.Mesh(vertex_matrix=verts, face_matrix=faces, v_normals_matrix=vnorms, vertex_quality_matrix=vals)
...
----> 1 box2 = pyml.Mesh(vertex_matrix=verts, face_matrix=faces, v_normals_matrix=vnorms, vertex_quality_matrix=vals)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. pymeshlab.pmeshlab.Mesh(vertex_matrix: numpy.ndarray[numpy.float32[m, 3]] = array([], shape=(0, 3), dtype=float32), face_matrix: numpy.ndarray[numpy.int32[m, 3]] = array([], shape=(0, 3), dtype=int32), v_normals_matrix: numpy.ndarray[numpy.float32[m, 3]] = array([], shape=(0, 3), dtype=float32), f_normals_matrix: numpy.ndarray[numpy.float32[m, 3]] = array([], shape=(0, 3), dtype=float32))
...So it seems like So if we can't assign a quality value to vertices and we can't create a mesh with them, how can I associate and arbitrary quality value with each vertex? My eventual goal is to color the mesh according to these values and then export in the u3d format. I am using pymeshlab 0.1.9. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Setting per vertex and per face quality in a mesh cannot be done right now. As you can see in the documentation a mesh can be created from scratch passing vertex coords, vertex normals, faces and face normals; quality is missing right now. Generally speaking, all the attributes of the Mesh are read only, and they can be modified only using the method provided by the Mesh class. |
Beta Was this translation helpful? Give feedback.
Setting per vertex and per face quality in a mesh cannot be done right now. As you can see in the documentation a mesh can be created from scratch passing vertex coords, vertex normals, faces and face normals; quality is missing right now. Generally speaking, all the attributes of the Mesh are read only, and they can be modified only using the method provided by the Mesh class.
I'll add the possibility to set per vertex and per face quality in the mesh construction, in the next pymeshlab version.