Open bsaunois opened 3 years ago
Hi. It looks to me like your mesh is not fully connected - i.e. it consists of multiple disconnected shapes that only appear to be a closed surface. sk.pre.fix_mesh
then removes some of these disconnected pieces because of the remove_disconnected
parameter.
You can check this like so:
>>> import networkx as nx
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected components')
Mesh consists of 70 connected components
Without having seen what your Matrixvertices
and triangle
look like, I can't tell whether it's the input data that's wrong or whether trimesh does something funny. Normally, trimesh will merge vertices that occupy the same position in space but your process=False
deactivates that behaviour.
Also another heads-up: I know it's somewhat counterintuitive but skeletonization of small primitives such as your cylinder often produce suboptimal results. You might be able to get better results by increasing the number of vertices (e.g. by subdividing).
Thanks for the quick reply!
I tried what you told me and it outputs me :
Mesh consists of 1 connected components
I am not sure I understand exactly what you said, but does this mean that almost nothing is connected in my mesh ?
Otherwise, here are the inputs I gave :
Matrixvertices = [[-9.100000e-01 -9.616506e-09 -6.000000e-01]
[-9.089955e-01 1.492265e-02 -6.000000e-01]
[-9.089955e-01 1.492265e-02 -7.000000e-01]
[-9.100000e-01 -9.616506e-09 -7.000000e-01]
[-9.089955e-01 -1.492267e-02 -6.000000e-01]
[-9.100000e-01 -9.616506e-09 -6.000000e-01]
[-9.100000e-01 -9.616506e-09 -7.000000e-01]
[-9.089955e-01 -1.492267e-02 -7.000000e-01]
[-9.060695e-01 -2.923627e-02 -6.000000e-01]
[-9.089955e-01 -1.492267e-02 -6.000000e-01]
[-9.089955e-01 -1.492267e-02 -7.000000e-01]
[-9.060695e-01 -2.923627e-02 -7.000000e-01]
[-9.013531e-01 -4.280957e-02 -6.000000e-01]
[-9.060695e-01 -2.923627e-02 -6.000000e-01]
[-9.060695e-01 -2.923627e-02 -7.000000e-01]
[-9.013531e-01 -4.280957e-02 -7.000000e-01]
[-8.949779e-01 -5.551131e-02 -6.000000e-01]
[-9.013531e-01 -4.280957e-02 -6.000000e-01]
[-9.013531e-01 -4.280957e-02 -7.000000e-01]
[-8.949779e-01 -5.551131e-02 -7.000000e-01]
[-8.870748e-01 -6.721026e-02 -6.000000e-01]
[-8.949779e-01 -5.551131e-02 -6.000000e-01]
[-8.949779e-01 -5.551131e-02 -7.000000e-01]
[-8.870748e-01 -6.721026e-02 -7.000000e-01]
[-8.777752e-01 -7.777517e-02 -6.000000e-01]
[-8.870748e-01 -6.721026e-02 -6.000000e-01]
[-8.870748e-01 -6.721026e-02 -7.000000e-01]
[-8.777752e-01 -7.777517e-02 -7.000000e-01]
[-8.672102e-01 -8.707477e-02 -6.000000e-01]
[-8.777752e-01 -7.777517e-02 -6.000000e-01]
[-8.777752e-01 -7.777517e-02 -7.000000e-01]
[-8.672102e-01 -8.707477e-02 -7.000000e-01]
[-8.555113e-01 -9.497786e-02 -6.000000e-01]
[-8.672102e-01 -8.707477e-02 -6.000000e-01]
[-8.672102e-01 -8.707477e-02 -7.000000e-01]
[-8.555113e-01 -9.497786e-02 -7.000000e-01]
[-8.428095e-01 -1.013532e-01 -6.000000e-01]
[-8.555113e-01 -9.497786e-02 -6.000000e-01]
[-8.555113e-01 -9.497786e-02 -7.000000e-01]
[-8.428095e-01 -1.013532e-01 -7.000000e-01]
[-8.292362e-01 -1.060695e-01 -6.000000e-01]
[-8.428095e-01 -1.013532e-01 -6.000000e-01]
[-8.428095e-01 -1.013532e-01 -7.000000e-01]
[-8.292362e-01 -1.060695e-01 -7.000000e-01]
[-8.149226e-01 -1.089955e-01 -6.000000e-01]
[-8.292362e-01 -1.060695e-01 -6.000000e-01]
[-8.292362e-01 -1.060695e-01 -7.000000e-01]
[-8.149226e-01 -1.089955e-01 -7.000000e-01]
[-8.000000e-01 -1.100000e-01 -6.000000e-01]
[-8.149226e-01 -1.089955e-01 -6.000000e-01]
[-8.149226e-01 -1.089955e-01 -7.000000e-01]
[-8.000000e-01 -1.100000e-01 -7.000000e-01]
[-7.850773e-01 -1.089955e-01 -6.000000e-01]
[-8.000000e-01 -1.100000e-01 -6.000000e-01]
[-8.000000e-01 -1.100000e-01 -7.000000e-01]
[-7.850773e-01 -1.089955e-01 -7.000000e-01]
[-7.707637e-01 -1.060695e-01 -6.000000e-01]
[-7.850773e-01 -1.089955e-01 -6.000000e-01]
[-7.850773e-01 -1.089955e-01 -7.000000e-01]
[-7.707637e-01 -1.060695e-01 -7.000000e-01]
[-7.571904e-01 -1.013532e-01 -6.000000e-01]
[-7.707637e-01 -1.060695e-01 -6.000000e-01]
[-7.707637e-01 -1.060695e-01 -7.000000e-01]
[-7.571904e-01 -1.013532e-01 -7.000000e-01]
[-7.444887e-01 -9.497787e-02 -6.000000e-01]
[-7.571904e-01 -1.013532e-01 -6.000000e-01]
[-7.571904e-01 -1.013532e-01 -7.000000e-01]
[-7.444887e-01 -9.497787e-02 -7.000000e-01]
[-7.327898e-01 -8.707479e-02 -6.000000e-01]
[-7.444887e-01 -9.497787e-02 -6.000000e-01]
[-7.444887e-01 -9.497787e-02 -7.000000e-01]
[-7.327898e-01 -8.707479e-02 -7.000000e-01]
[-7.222248e-01 -7.777516e-02 -6.000000e-01]
[-7.327898e-01 -8.707479e-02 -6.000000e-01]
[-7.327898e-01 -8.707479e-02 -7.000000e-01]
[-7.222248e-01 -7.777516e-02 -7.000000e-01]
[-7.129253e-01 -6.721025e-02 -6.000000e-01]
[-7.222248e-01 -7.777516e-02 -6.000000e-01]
[-7.222248e-01 -7.777516e-02 -7.000000e-01]
[-7.129253e-01 -6.721025e-02 -7.000000e-01]
[-7.050221e-01 -5.551130e-02 -6.000000e-01]
[-7.129253e-01 -6.721025e-02 -6.000000e-01]
[-7.129253e-01 -6.721025e-02 -7.000000e-01]
[-7.050221e-01 -5.551130e-02 -7.000000e-01]
[-6.986468e-01 -4.280955e-02 -6.000000e-01]
[-7.050221e-01 -5.551130e-02 -6.000000e-01]
[-7.050221e-01 -5.551130e-02 -7.000000e-01]
[-6.986468e-01 -4.280955e-02 -7.000000e-01]
[-6.939305e-01 -2.923626e-02 -6.000000e-01]
[-6.986468e-01 -4.280955e-02 -6.000000e-01]
[-6.986468e-01 -4.280955e-02 -7.000000e-01]
[-6.939305e-01 -2.923626e-02 -7.000000e-01]
[-6.910045e-01 -1.492265e-02 -6.000000e-01]
[-6.939305e-01 -2.923626e-02 -6.000000e-01]
[-6.939305e-01 -2.923626e-02 -7.000000e-01]
[-6.910045e-01 -1.492265e-02 -7.000000e-01]
[-6.900000e-01 9.616506e-09 -6.000000e-01]
[-6.910045e-01 -1.492265e-02 -6.000000e-01]
[-6.910045e-01 -1.492265e-02 -7.000000e-01]
[-6.900000e-01 9.616506e-09 -7.000000e-01]
[-6.910045e-01 1.492267e-02 -6.000000e-01]
[-6.900000e-01 9.616506e-09 -6.000000e-01]
[-6.900000e-01 9.616506e-09 -7.000000e-01]
[-6.910045e-01 1.492267e-02 -7.000000e-01]
[-6.939305e-01 2.923627e-02 -6.000000e-01]
[-6.910045e-01 1.492267e-02 -6.000000e-01]
[-6.910045e-01 1.492267e-02 -7.000000e-01]
[-6.939305e-01 2.923627e-02 -7.000000e-01]
[-6.986468e-01 4.280957e-02 -6.000000e-01]
[-6.939305e-01 2.923627e-02 -6.000000e-01]
[-6.939305e-01 2.923627e-02 -7.000000e-01]
[-6.986468e-01 4.280957e-02 -7.000000e-01]
[-7.050221e-01 5.551131e-02 -6.000000e-01]
[-6.986468e-01 4.280957e-02 -6.000000e-01]
[-6.986468e-01 4.280957e-02 -7.000000e-01]
[-7.050221e-01 5.551131e-02 -7.000000e-01]
[-7.129252e-01 6.721026e-02 -6.000000e-01]
[-7.050221e-01 5.551131e-02 -6.000000e-01]
[-7.050221e-01 5.551131e-02 -7.000000e-01]
[-7.129252e-01 6.721026e-02 -7.000000e-01]
[-7.222248e-01 7.777517e-02 -6.000000e-01]
[-7.129252e-01 6.721026e-02 -6.000000e-01]
[-7.129252e-01 6.721026e-02 -7.000000e-01]
[-7.222248e-01 7.777517e-02 -7.000000e-01]
[-7.327898e-01 8.707477e-02 -6.000000e-01]
[-7.222248e-01 7.777517e-02 -6.000000e-01]
[-7.222248e-01 7.777517e-02 -7.000000e-01]
[-7.327898e-01 8.707477e-02 -7.000000e-01]
[-7.444887e-01 9.497786e-02 -6.000000e-01]
[-7.327898e-01 8.707477e-02 -6.000000e-01]
[-7.327898e-01 8.707477e-02 -7.000000e-01]
[-7.444887e-01 9.497786e-02 -7.000000e-01]
[-7.571905e-01 1.013532e-01 -6.000000e-01]
[-7.444887e-01 9.497786e-02 -6.000000e-01]
[-7.444887e-01 9.497786e-02 -7.000000e-01]
[-7.571905e-01 1.013532e-01 -7.000000e-01]
[-7.707638e-01 1.060695e-01 -6.000000e-01]
[-7.571905e-01 1.013532e-01 -6.000000e-01]
[-7.571905e-01 1.013532e-01 -7.000000e-01]
[-7.707638e-01 1.060695e-01 -7.000000e-01]
[-7.850773e-01 1.089955e-01 -6.000000e-01]
[-7.707638e-01 1.060695e-01 -6.000000e-01]
[-7.707638e-01 1.060695e-01 -7.000000e-01]
[-7.850773e-01 1.089955e-01 -7.000000e-01]
[-8.000000e-01 1.100000e-01 -6.000000e-01]
[-7.850773e-01 1.089955e-01 -6.000000e-01]
[-7.850773e-01 1.089955e-01 -7.000000e-01]
[-8.000000e-01 1.100000e-01 -7.000000e-01]
[-8.149226e-01 1.089955e-01 -6.000000e-01]
[-8.000000e-01 1.100000e-01 -6.000000e-01]
[-8.000000e-01 1.100000e-01 -7.000000e-01]
[-8.149226e-01 1.089955e-01 -7.000000e-01]
[-8.292363e-01 1.060695e-01 -6.000000e-01]
[-8.149226e-01 1.089955e-01 -6.000000e-01]
[-8.149226e-01 1.089955e-01 -7.000000e-01]
[-8.292363e-01 1.060695e-01 -7.000000e-01]
[-8.428096e-01 1.013532e-01 -6.000000e-01]
[-8.292363e-01 1.060695e-01 -6.000000e-01]
[-8.292363e-01 1.060695e-01 -7.000000e-01]
[-8.428096e-01 1.013532e-01 -7.000000e-01]
[-8.555113e-01 9.497787e-02 -6.000000e-01]
[-8.428096e-01 1.013532e-01 -6.000000e-01]
[-8.428096e-01 1.013532e-01 -7.000000e-01]
[-8.555113e-01 9.497787e-02 -7.000000e-01]
[-8.672102e-01 8.707479e-02 -6.000000e-01]
[-8.555113e-01 9.497787e-02 -6.000000e-01]
[-8.555113e-01 9.497787e-02 -7.000000e-01]
[-8.672102e-01 8.707479e-02 -7.000000e-01]
[-8.777752e-01 7.777516e-02 -6.000000e-01]
[-8.672102e-01 8.707479e-02 -6.000000e-01]
[-8.672102e-01 8.707479e-02 -7.000000e-01]
[-8.777752e-01 7.777516e-02 -7.000000e-01]
[-8.870747e-01 6.721025e-02 -6.000000e-01]
[-8.777752e-01 7.777516e-02 -6.000000e-01]
[-8.777752e-01 7.777516e-02 -7.000000e-01]
[-8.870747e-01 6.721025e-02 -7.000000e-01]
[-8.949779e-01 5.551130e-02 -6.000000e-01]
[-8.870747e-01 6.721025e-02 -6.000000e-01]
[-8.870747e-01 6.721025e-02 -7.000000e-01]
[-8.949779e-01 5.551130e-02 -7.000000e-01]
[-9.013531e-01 4.280955e-02 -6.000000e-01]
[-8.949779e-01 5.551130e-02 -6.000000e-01]
[-8.949779e-01 5.551130e-02 -7.000000e-01]
[-9.013531e-01 4.280955e-02 -7.000000e-01]
[-9.060695e-01 2.923626e-02 -6.000000e-01]
[-9.013531e-01 4.280955e-02 -6.000000e-01]
[-9.013531e-01 4.280955e-02 -7.000000e-01]
[-9.060695e-01 2.923626e-02 -7.000000e-01]
[-9.089955e-01 1.492265e-02 -6.000000e-01]
[-9.060695e-01 2.923626e-02 -6.000000e-01]
[-9.060695e-01 2.923626e-02 -7.000000e-01]
[-9.089955e-01 1.492265e-02 -7.000000e-01]
[-9.089955e-01 1.492265e-02 -6.000000e-01]
[-9.100000e-01 -9.616506e-09 -6.000000e-01]
[-9.089955e-01 -1.492267e-02 -6.000000e-01]
[-9.060695e-01 2.923626e-02 -6.000000e-01]
[-9.060695e-01 -2.923627e-02 -6.000000e-01]
[-9.013531e-01 4.280955e-02 -6.000000e-01]
[-9.013531e-01 -4.280957e-02 -6.000000e-01]
[-8.949779e-01 5.551130e-02 -6.000000e-01]
[-8.949779e-01 -5.551131e-02 -6.000000e-01]
[-8.870747e-01 6.721025e-02 -6.000000e-01]
[-8.870748e-01 -6.721026e-02 -6.000000e-01]
[-8.777752e-01 -7.777517e-02 -6.000000e-01]
[-8.777752e-01 7.777516e-02 -6.000000e-01]
[-8.672102e-01 8.707479e-02 -6.000000e-01]
[-8.672102e-01 -8.707477e-02 -6.000000e-01]
[-8.555113e-01 9.497787e-02 -6.000000e-01]
[-8.555113e-01 -9.497786e-02 -6.000000e-01]
[-8.428096e-01 1.013532e-01 -6.000000e-01]
[-8.428095e-01 -1.013532e-01 -6.000000e-01]
[-8.292363e-01 1.060695e-01 -6.000000e-01]
[-8.292362e-01 -1.060695e-01 -6.000000e-01]
[-8.149226e-01 1.089955e-01 -6.000000e-01]
[-8.149226e-01 -1.089955e-01 -6.000000e-01]
[-8.000000e-01 1.100000e-01 -6.000000e-01]
[-8.000000e-01 -1.100000e-01 -6.000000e-01]
[-7.850773e-01 1.089955e-01 -6.000000e-01]
[-7.850773e-01 -1.089955e-01 -6.000000e-01]
[-7.707638e-01 1.060695e-01 -6.000000e-01]
[-7.707637e-01 -1.060695e-01 -6.000000e-01]
[-7.571905e-01 1.013532e-01 -6.000000e-01]
[-7.571904e-01 -1.013532e-01 -6.000000e-01]
[-7.444887e-01 9.497786e-02 -6.000000e-01]
[-7.444887e-01 -9.497787e-02 -6.000000e-01]
[-7.327898e-01 8.707477e-02 -6.000000e-01]
[-7.327898e-01 -8.707479e-02 -6.000000e-01]
[-7.222248e-01 7.777517e-02 -6.000000e-01]
[-7.222248e-01 -7.777516e-02 -6.000000e-01]
[-7.129252e-01 6.721026e-02 -6.000000e-01]
[-7.129253e-01 -6.721025e-02 -6.000000e-01]
[-7.050221e-01 -5.551130e-02 -6.000000e-01]
[-7.050221e-01 5.551131e-02 -6.000000e-01]
[-6.986468e-01 4.280957e-02 -6.000000e-01]
[-6.986468e-01 -4.280955e-02 -6.000000e-01]
[-6.939305e-01 2.923627e-02 -6.000000e-01]
[-6.939305e-01 -2.923626e-02 -6.000000e-01]
[-6.910045e-01 1.492267e-02 -6.000000e-01]
[-6.910045e-01 -1.492265e-02 -6.000000e-01]
[-6.900000e-01 9.616506e-09 -6.000000e-01]
[-9.089955e-01 -1.492267e-02 -7.000000e-01]
[-9.100000e-01 -9.616506e-09 -7.000000e-01]
[-9.089955e-01 1.492265e-02 -7.000000e-01]
[-9.060695e-01 -2.923627e-02 -7.000000e-01]
[-9.060695e-01 2.923626e-02 -7.000000e-01]
[-9.013531e-01 -4.280957e-02 -7.000000e-01]
[-9.013531e-01 4.280955e-02 -7.000000e-01]
[-8.949779e-01 -5.551131e-02 -7.000000e-01]
[-8.949779e-01 5.551130e-02 -7.000000e-01]
[-8.870748e-01 -6.721026e-02 -7.000000e-01]
[-8.870747e-01 6.721025e-02 -7.000000e-01]
[-8.777752e-01 -7.777517e-02 -7.000000e-01]
[-8.777752e-01 7.777516e-02 -7.000000e-01]
[-8.672102e-01 -8.707477e-02 -7.000000e-01]
[-8.672102e-01 8.707479e-02 -7.000000e-01]
[-8.555113e-01 -9.497786e-02 -7.000000e-01]
[-8.555113e-01 9.497787e-02 -7.000000e-01]
[-8.428095e-01 -1.013532e-01 -7.000000e-01]
[-8.428096e-01 1.013532e-01 -7.000000e-01]
[-8.292363e-01 1.060695e-01 -7.000000e-01]
[-8.292362e-01 -1.060695e-01 -7.000000e-01]
[-8.149226e-01 1.089955e-01 -7.000000e-01]
[-8.149226e-01 -1.089955e-01 -7.000000e-01]
[-8.000000e-01 -1.100000e-01 -7.000000e-01]
[-8.000000e-01 1.100000e-01 -7.000000e-01]
[-7.850773e-01 -1.089955e-01 -7.000000e-01]
[-7.850773e-01 1.089955e-01 -7.000000e-01]
[-7.707637e-01 -1.060695e-01 -7.000000e-01]
[-7.707638e-01 1.060695e-01 -7.000000e-01]
[-7.571905e-01 1.013532e-01 -7.000000e-01]
[-7.571904e-01 -1.013532e-01 -7.000000e-01]
[-7.444887e-01 9.497786e-02 -7.000000e-01]
[-7.444887e-01 -9.497787e-02 -7.000000e-01]
[-7.327898e-01 -8.707479e-02 -7.000000e-01]
[-7.327898e-01 8.707477e-02 -7.000000e-01]
[-7.222248e-01 -7.777516e-02 -7.000000e-01]
[-7.222248e-01 7.777517e-02 -7.000000e-01]
[-7.129253e-01 -6.721025e-02 -7.000000e-01]
[-7.129252e-01 6.721026e-02 -7.000000e-01]
[-7.050221e-01 -5.551130e-02 -7.000000e-01]
[-7.050221e-01 5.551131e-02 -7.000000e-01]
[-6.986468e-01 -4.280955e-02 -7.000000e-01]
[-6.986468e-01 4.280957e-02 -7.000000e-01]
[-6.939305e-01 -2.923626e-02 -7.000000e-01]
[-6.939305e-01 2.923627e-02 -7.000000e-01]
[-6.910045e-01 -1.492265e-02 -7.000000e-01]
[-6.910045e-01 1.492267e-02 -7.000000e-01]
[-6.900000e-01 9.616506e-09 -7.000000e-01]]
triangle = [[0, 1, 2], [0, 2, 3], [4, 5, 6], [4, 6, 7], [8, 9, 10], [8, 10, 11], [12, 13, 14], [12, 14, 15], [16, 17, 18], [16, 18, 19], [20, 21, 22],
[20, 22, 23], [24, 25, 26], [24, 26, 27], [28, 29, 30], [28, 30, 31], [32, 33, 34], [32, 34, 35], [36, 37, 38], [36, 38, 39], [40, 41, 42],
[40, 42, 43], [44, 45, 46], [44, 46, 47], [48, 49, 50], [48, 50, 51], [52, 53, 54], [52, 54, 55], [56, 57, 58], [56, 58, 59], [60, 61, 62],
[60, 62, 63], [64, 65, 66], [64, 66, 67], [68, 69, 70], [68, 70, 71], [72, 73, 74], [72, 74, 75], [76, 77, 78], [76, 78, 79], [80, 81, 82],
[80, 82, 83], [84, 85, 86], [84, 86, 87], [88, 89, 90], [88, 90, 91], [92, 93, 94], [92, 94, 95], [96, 97, 98], [96, 98, 99], [100, 101, 102], [100, 102, 103], [104, 105, 106], [104, 106, 107], [108, 109, 110], [108, 110, 111], [112, 113, 114], [112, 114, 115], [116, 117, 118], [116, 118, 119], [120, 121, 122], [120, 122, 123], [124, 125, 126], [124, 126, 127], [128, 129, 130], [128, 130, 131], [132, 133, 134], [132, 134, 135], [136, 137, 138], [136, 138, 139], [140, 141, 142], [140, 142, 143], [144, 145, 146], [144, 146, 147], [148, 149, 150], [148, 150, 151], [152, 153, 154], [152, 154, 155], [156, 157, 158], [156, 158, 159], [160, 161, 162], [160, 162, 163], [164, 165, 166], [164, 166, 167], [168, 169, 170], [168, 170, 171], [172, 173, 174], [172, 174, 175], [176, 177, 178], [176, 178, 179], [180, 181, 182], [180, 182, 183],
[184, 185, 186], [184, 186, 187], [188, 189, 190], [188, 190, 191], [192, 193, 194], [194, 195, 192], [194, 196, 195], [196, 197, 195], [196, 198, 197], [198, 199, 197], [198, 200, 199], [200, 201, 199], [200, 202, 201], [202, 203, 201], [203, 204, 201], [203, 205, 204], [203, 206, 205], [206, 207, 205], [206, 208, 207], [208, 209, 207], [208, 210, 209], [210, 211, 209], [210, 212, 211], [212, 213, 211], [212, 214, 213], [214, 215, 213], [214, 216, 215], [216, 217, 215], [216, 218, 217], [218, 219, 217], [218, 220, 219], [220, 221, 219], [220, 222, 221], [222, 223, 221], [222, 224, 223], [224, 225, 223], [224, 226, 225], [226, 227, 225], [226, 228, 227], [228, 229, 227], [228, 230, 229], [230, 231, 229], [231, 232, 229], [231, 233, 232], [231, 234, 233], [234, 235, 233], [234, 236, 235], [236, 237, 235], [236, 238, 237], [238, 239, 237], [240, 241, 242], [242, 243, 240], [242, 244, 243], [244, 245, 243], [244, 246, 245], [246, 247, 245], [246, 248, 247], [248, 249,
247], [248, 250, 249], [250, 251, 249], [250, 252, 251], [252, 253, 251], [252, 254, 253], [254, 255, 253], [254, 256, 255], [256, 257, 255], [256, 258, 257], [258, 259, 257], [259, 260, 257], [259, 261, 260], [261, 262, 260], [261, 263, 262], [261, 264, 263], [264, 265, 263], [264, 266, 265], [266, 267, 265], [266, 268, 267], [268, 269, 267], [269, 270, 267], [269, 271, 270], [271, 272, 270], [271, 273, 272], [271,
274, 273], [274, 275, 273], [274, 276, 275], [276, 277, 275], [276, 278, 277], [278, 279, 277], [278, 280, 279], [280, 281, 279], [280, 282, 281], [282, 283, 281], [282, 284, 283], [284, 285, 283], [284, 286, 285], [286, 287, 285]]
A single connected component is actually what you want. Could you perhaps share the Matrixvertices
as a properly formatted list (i.e. with commas) so that I can copy paste them into a Python session?
I am sorry ! here is the right one :
Matrixvertices = [[-0.91, -9.616506e-09, -0.6], [-0.9089955, 0.01492265, -0.6], [-0.9089955, 0.01492265, -0.7], [-0.91, -9.616506e-09, -0.7], [-0.9089955, -0.01492267, -0.6], [-0.91, -9.616506e-09, -0.6], [-0.91, -9.616506e-09, -0.7], [-0.9089955, -0.01492267, -0.7], [-0.9060695, -0.02923627, -0.6], [-0.9089955, -0.01492267, -0.6], [-0.9089955, -0.01492267, -0.7], [-0.9060695, -0.02923627, -0.7], [-0.9013531, -0.04280957, -0.6], [-0.9060695, -0.02923627, -0.6], [-0.9060695, -0.02923627, -0.7], [-0.9013531, -0.04280957, -0.7], [-0.8949779, -0.05551131, -0.6], [-0.9013531, -0.04280957, -0.6], [-0.9013531, -0.04280957, -0.7], [-0.8949779, -0.05551131, -0.7], [-0.8870748, -0.06721026, -0.6], [-0.8949779, -0.05551131, -0.6], [-0.8949779, -0.05551131, -0.7], [-0.8870748, -0.06721026, -0.7], [-0.8777752, -0.07777517, -0.6], [-0.8870748, -0.06721026, -0.6], [-0.8870748, -0.06721026, -0.7], [-0.8777752, -0.07777517, -0.7], [-0.8672102, -0.08707477, -0.6], [-0.8777752, -0.07777517, -0.6], [-0.8777752, -0.07777517, -0.7], [-0.8672102, -0.08707477, -0.7], [-0.8555113, -0.09497786, -0.6], [-0.8672102, -0.08707477, -0.6], [-0.8672102, -0.08707477, -0.7], [-0.8555113, -0.09497786, -0.7], [-0.8428095, -0.1013532, -0.6], [-0.8555113, -0.09497786, -0.6], [-0.8555113, -0.09497786, -0.7], [-0.8428095, -0.1013532, -0.7], [-0.8292362, -0.1060695, -0.6], [-0.8428095, -0.1013532, -0.6], [-0.8428095, -0.1013532, -0.7], [-0.8292362, -0.1060695, -0.7], [-0.8149226, -0.1089955, -0.6], [-0.8292362, -0.1060695, -0.6], [-0.8292362, -0.1060695, -0.7], [-0.8149226, -0.1089955, -0.7], [-0.8, -0.11, -0.6], [-0.8149226, -0.1089955, -0.6], [-0.8149226, -0.1089955, -0.7], [-0.8, -0.11, -0.7], [-0.7850773,
-0.1089955, -0.6], [-0.8, -0.11, -0.6], [-0.8, -0.11, -0.7], [-0.7850773, -0.1089955, -0.7], [-0.7707637, -0.1060695, -0.6], [-0.7850773, -0.1089955, -0.6], [-0.7850773, -0.1089955, -0.7], [-0.7707637, -0.1060695, -0.7], [-0.7571904, -0.1013532, -0.6], [-0.7707637, -0.1060695, -0.6], [-0.7707637, -0.1060695, -0.7], [-0.7571904, -0.1013532, -0.7], [-0.7444887, -0.09497787, -0.6], [-0.7571904, -0.1013532, -0.6], [-0.7571904, -0.1013532, -0.7], [-0.7444887, -0.09497787, -0.7], [-0.7327898, -0.08707479, -0.6], [-0.7444887, -0.09497787, -0.6], [-0.7444887, -0.09497787, -0.7], [-0.7327898, -0.08707479, -0.7], [-0.7222248, -0.07777516, -0.6], [-0.7327898, -0.08707479, -0.6], [-0.7327898, -0.08707479, -0.7], [-0.7222248, -0.07777516, -0.7], [-0.7129253, -0.06721025, -0.6], [-0.7222248, -0.07777516, -0.6], [-0.7222248, -0.07777516, -0.7], [-0.7129253, -0.06721025, -0.7], [-0.7050221, -0.0555113, -0.6], [-0.7129253, -0.06721025, -0.6], [-0.7129253, -0.06721025, -0.7], [-0.7050221, -0.0555113, -0.7], [-0.6986468, -0.04280955, -0.6], [-0.7050221, -0.0555113, -0.6], [-0.7050221, -0.0555113, -0.7], [-0.6986468, -0.04280955, -0.7], [-0.6939305, -0.02923626, -0.6], [-0.6986468, -0.04280955, -0.6], [-0.6986468, -0.04280955, -0.7], [-0.6939305, -0.02923626,
-0.7], [-0.6910045, -0.01492265, -0.6], [-0.6939305, -0.02923626, -0.6], [-0.6939305, -0.02923626, -0.7], [-0.6910045, -0.01492265, -0.7], [-0.69, 9.616506e-09, -0.6], [-0.6910045, -0.01492265, -0.6], [-0.6910045, -0.01492265, -0.7], [-0.69, 9.616506e-09, -0.7], [-0.6910045, 0.01492267, -0.6], [-0.69, 9.616506e-09, -0.6], [-0.69, 9.616506e-09, -0.7], [-0.6910045, 0.01492267, -0.7], [-0.6939305, 0.02923627, -0.6], [-0.6910045, 0.01492267, -0.6], [-0.6910045, 0.01492267, -0.7], [-0.6939305, 0.02923627, -0.7], [-0.6986468, 0.04280957, -0.6], [-0.6939305, 0.02923627, -0.6], [-0.6939305, 0.02923627, -0.7], [-0.6986468, 0.04280957, -0.7], [-0.7050221, 0.05551131, -0.6], [-0.6986468, 0.04280957, -0.6], [-0.6986468, 0.04280957, -0.7], [-0.7050221, 0.05551131, -0.7], [-0.7129252, 0.06721026, -0.6], [-0.7050221, 0.05551131, -0.6], [-0.7050221, 0.05551131, -0.7], [-0.7129252, 0.06721026, -0.7], [-0.7222248, 0.07777517, -0.6], [-0.7129252, 0.06721026, -0.6], [-0.7129252, 0.06721026, -0.7], [-0.7222248, 0.07777517, -0.7], [-0.7327898, 0.08707477, -0.6], [-0.7222248, 0.07777517, -0.6], [-0.7222248, 0.07777517, -0.7], [-0.7327898, 0.08707477, -0.7], [-0.7444887, 0.09497786, -0.6], [-0.7327898, 0.08707477, -0.6], [-0.7327898, 0.08707477, -0.7], [-0.7444887, 0.09497786, -0.7], [-0.7571905, 0.1013532, -0.6], [-0.7444887, 0.09497786, -0.6], [-0.7444887, 0.09497786, -0.7], [-0.7571905, 0.1013532,
-0.7], [-0.7707638, 0.1060695, -0.6], [-0.7571905, 0.1013532, -0.6], [-0.7571905, 0.1013532, -0.7], [-0.7707638, 0.1060695, -0.7], [-0.7850773, 0.1089955, -0.6], [-0.7707638, 0.1060695, -0.6], [-0.7707638, 0.1060695, -0.7], [-0.7850773, 0.1089955, -0.7], [-0.8, 0.11, -0.6], [-0.7850773, 0.1089955, -0.6], [-0.7850773, 0.1089955, -0.7], [-0.8, 0.11, -0.7], [-0.8149226, 0.1089955, -0.6], [-0.8, 0.11, -0.6], [-0.8, 0.11, -0.7], [-0.8149226, 0.1089955, -0.7], [-0.8292363, 0.1060695, -0.6], [-0.8149226, 0.1089955, -0.6], [-0.8149226, 0.1089955, -0.7], [-0.8292363, 0.1060695, -0.7], [-0.8428096, 0.1013532, -0.6], [-0.8292363, 0.1060695, -0.6], [-0.8292363, 0.1060695, -0.7], [-0.8428096, 0.1013532,
-0.7], [-0.8555113, 0.09497787, -0.6], [-0.8428096, 0.1013532, -0.6], [-0.8428096, 0.1013532, -0.7], [-0.8555113, 0.09497787, -0.7], [-0.8672102, 0.08707479, -0.6], [-0.8555113, 0.09497787, -0.6], [-0.8555113, 0.09497787, -0.7], [-0.8672102, 0.08707479, -0.7], [-0.8777752, 0.07777516, -0.6], [-0.8672102, 0.08707479, -0.6], [-0.8672102, 0.08707479, -0.7], [-0.8777752, 0.07777516, -0.7], [-0.8870747, 0.06721025, -0.6], [-0.8777752, 0.07777516, -0.6], [-0.8777752, 0.07777516, -0.7], [-0.8870747, 0.06721025, -0.7], [-0.8949779, 0.0555113, -0.6], [-0.8870747, 0.06721025, -0.6], [-0.8870747, 0.06721025, -0.7], [-0.8949779, 0.0555113, -0.7], [-0.9013531, 0.04280955, -0.6], [-0.8949779, 0.0555113, -0.6], [-0.8949779, 0.0555113, -0.7], [-0.9013531, 0.04280955, -0.7], [-0.9060695, 0.02923626, -0.6], [-0.9013531, 0.04280955, -0.6], [-0.9013531, 0.04280955, -0.7], [-0.9060695, 0.02923626, -0.7], [-0.9089955, 0.01492265, -0.6], [-0.9060695, 0.02923626, -0.6], [-0.9060695, 0.02923626, -0.7], [-0.9089955, 0.01492265, -0.7], [-0.9089955, 0.01492265, -0.6], [-0.91, -9.616506e-09, -0.6], [-0.9089955, -0.01492267, -0.6],
[-0.9060695, 0.02923626, -0.6], [-0.9060695, -0.02923627, -0.6], [-0.9013531, 0.04280955, -0.6], [-0.9013531, -0.04280957, -0.6], [-0.8949779, 0.0555113, -0.6], [-0.8949779, -0.05551131, -0.6], [-0.8870747, 0.06721025, -0.6], [-0.8870748, -0.06721026, -0.6], [-0.8777752, -0.07777517, -0.6], [-0.8777752, 0.07777516, -0.6], [-0.8672102, 0.08707479, -0.6], [-0.8672102, -0.08707477, -0.6], [-0.8555113, 0.09497787, -0.6], [-0.8555113, -0.09497786, -0.6], [-0.8428096, 0.1013532, -0.6], [-0.8428095, -0.1013532, -0.6], [-0.8292363, 0.1060695, -0.6], [-0.8292362, -0.1060695, -0.6], [-0.8149226, 0.1089955, -0.6], [-0.8149226, -0.1089955, -0.6], [-0.8, 0.11, -0.6], [-0.8, -0.11, -0.6], [-0.7850773, 0.1089955, -0.6], [-0.7850773, -0.1089955, -0.6], [-0.7707638, 0.1060695, -0.6], [-0.7707637, -0.1060695, -0.6], [-0.7571905, 0.1013532, -0.6], [-0.7571904, -0.1013532, -0.6], [-0.7444887, 0.09497786, -0.6], [-0.7444887, -0.09497787, -0.6], [-0.7327898, 0.08707477, -0.6], [-0.7327898, -0.08707479, -0.6], [-0.7222248, 0.07777517, -0.6], [-0.7222248, -0.07777516, -0.6], [-0.7129252, 0.06721026, -0.6], [-0.7129253, -0.06721025, -0.6], [-0.7050221, -0.0555113, -0.6], [-0.7050221, 0.05551131, -0.6], [-0.6986468, 0.04280957, -0.6], [-0.6986468, -0.04280955, -0.6], [-0.6939305, 0.02923627, -0.6], [-0.6939305, -0.02923626, -0.6], [-0.6910045, 0.01492267, -0.6], [-0.6910045, -0.01492265, -0.6], [-0.69,
9.616506e-09, -0.6], [-0.9089955, -0.01492267, -0.7], [-0.91, -9.616506e-09, -0.7], [-0.9089955, 0.01492265, -0.7], [-0.9060695, -0.02923627, -0.7], [-0.9060695, 0.02923626, -0.7], [-0.9013531, -0.04280957, -0.7], [-0.9013531, 0.04280955, -0.7], [-0.8949779, -0.05551131, -0.7], [-0.8949779, 0.0555113, -0.7], [-0.8870748, -0.06721026, -0.7], [-0.8870747, 0.06721025, -0.7], [-0.8777752, -0.07777517, -0.7], [-0.8777752, 0.07777516, -0.7], [-0.8672102, -0.08707477, -0.7], [-0.8672102, 0.08707479, -0.7], [-0.8555113, -0.09497786, -0.7], [-0.8555113, 0.09497787, -0.7], [-0.8428095, -0.1013532, -0.7], [-0.8428096, 0.1013532, -0.7], [-0.8292363, 0.1060695, -0.7], [-0.8292362, -0.1060695, -0.7], [-0.8149226, 0.1089955, -0.7], [-0.8149226, -0.1089955, -0.7], [-0.8, -0.11, -0.7], [-0.8, 0.11, -0.7], [-0.7850773, -0.1089955, -0.7], [-0.7850773, 0.1089955, -0.7], [-0.7707637, -0.1060695, -0.7], [-0.7707638, 0.1060695, -0.7], [-0.7571905, 0.1013532, -0.7], [-0.7571904, -0.1013532, -0.7], [-0.7444887, 0.09497786, -0.7], [-0.7444887, -0.09497787, -0.7], [-0.7327898, -0.08707479, -0.7], [-0.7327898, 0.08707477, -0.7], [-0.7222248, -0.07777516, -0.7], [-0.7222248, 0.07777517, -0.7], [-0.7129253, -0.06721025, -0.7], [-0.7129252, 0.06721026, -0.7], [-0.7050221, -0.0555113, -0.7], [-0.7050221, 0.05551131, -0.7], [-0.6986468, -0.04280955, -0.7], [-0.6986468, 0.04280957, -0.7], [-0.6939305, -0.02923626, -0.7], [-0.6939305, 0.02923627, -0.7], [-0.6910045, -0.01492265, -0.7], [-0.6910045, 0.01492267, -0.7], [-0.69, 9.616506e-09, -0.7]]
Ah OK. So here is the rub:
Your set of faces + vertices is disconnected. If you set process=False
and trimesh does not merge duplicate vertices, you get this:
>>> mesh = trimesh.Trimesh(vertices=Matrixvertices,faces=triangle,process=False)
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected component(s)')
Mesh consists of 50 connected component(s)
If you allow trimesh to fix it, things look better:
>>> mesh = trimesh.Trimesh(vertices=Matrixvertices, faces=triangle, process=True)
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected component(s)')
Mesh consists of 1 connected component(s)
Now going back to the skeletonization: I tried the wavefront skeletonization too but increased the number of waves. That helps if your mesh is very small and it therefore matters a lot where the wave starts.
>>> skel = sk.skeletonize.by_wavefront(mesh, waves=10, step_size=1)
It doesn't really look like what you would intuitively expect and the issue is that there are simply too few vertices to go by:
I also checked if a mesh contraction would help but that looses the shape of the cylinder (red) and will hence lead to bad skeletons.
>>> cont = sk.pre.contract(mesh)
I'm not sure it's worth the effort since for a simple shape like this you can perfectly well just draw a skeleton yourself but if you want to try around some more, I would recommend increase the number of vertices and try to get them evenly distributed.
Thanks a lot for the help !
Ok I just found out too that I have to let trimesh fix the duplicates, in order to be sure to have a closed mesh.
I'm not sure it's worth the effort since for a simple shape like this you can perfectly well just draw a skeleton yourself
The fact is that I want to automate this because I have a set of meshes. So I need to get automatically this skeleton.
Thanks again for the help! I will still try to increase the number of vertices to see if it works better.
Have a nice week-end. Bastien
Hi, I have a set of vertices and faces that I have given to Trimesh (my mesh is a perfect cylinder (all surface are closed)) . But when I compute the skeletonization, it seems that something wrong has happened. The mesh isn't complete and so the skeletonization didn't work... What did I do wrong ?
Here is my code for that part :
mesh = trimesh.Trimesh(vertices=Matrixvertices,faces=triangle,process=False)
trimesh.Scene(mesh).show()
fixed = sk.pre.fix_mesh(mesh, remove_disconnected=5, inplace=False)
skel = sk.skeletonize.by_wavefront(fixed, waves=1, step_size=1)
skel.mesh_map
skel.swc.head()
skel.show(mesh=True)