Open jo-mueller opened 2 years ago
Hi, I think it's the way vtk builds the mesh, it creates additional edges that one can visualize (in magenta):
import vedo
mesh = vedo.shapes.Torus()
# mesh = vedo.shapes.Disc() # ok
# mesh = vedo.shapes.Circle() # ok
# mesh = vedo.shapes.Cube() # ok
# mesh = vedo.shapes.Sphere(res=(20,30)) # ok
mesh.clean() # remove duplicate faces
bnds = mesh.boundaries()
mesh.lw(1).alpha(0.5).flat()
n_points = len(mesh.points())
n_edges = len(mesh.edges())
n_faces = len(mesh.faces())
euler_characteristic = n_points - n_edges + n_faces
euler_characteristic += bnds.npoints/2 +1 #only for torus correction..
# print(n_points, n_edges, n_faces, bnds.npoints)
print(euler_characteristic)
vedo.show(mesh, bnds, axes=1)
@marcomusy Thanks for looking into this - I also didn't know about the mesh.clean
command. Thanks a bunch! That being said, would you think it desirable to replace the torus dataset by one without duplicate vertices?
Yes.. it could be done manually but it's a bit tricky... I need to think how to do it..
I noticed that when I calculate the euler characteristics for the torus example data I get an euler characteristic of -119, whereas the correct value for a torus should be 0.
Here's some code to reproduce: