marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.05k stars 266 forks source link

mesh colors not showing #1009

Open danafd opened 10 months ago

danafd commented 10 months ago

I've saved meshes from free hand-cutting volumes as .ply objects. When I open the .ply file as a Mesh, I am unable to define the color of the mesh. Any idea how to fix this? I tried .linecolor() which works, but I lose the needed translucency of my mesh. Any help is appreciated.

Screenshot 2024-01-09 at 11 53 18
marcomusy commented 10 months ago

hi, what happens if you reset it outside of the constructor:

nkx = Mesh("nkx.ply")
# nkx.pointdata.remove("RGB") # also try this
nkx.color("green5").alpha(0.5)
nkx
danafd commented 10 months ago

nkx.pointdata.remove("RGB") did not work, but It worked when I did nkx.pointdata.remove("Normals")

I don't understand why though...

Screenshot 2024-01-09 at 18 34 11
marcomusy commented 10 months ago

There might be something wrong with the normals (?) in the original mesh. This seems to work for me:


import vedo
from vedo.applications import FreeHandCutPlotter

msh = vedo.Volume(vedo.dataurl+'embryo.tif').isosurface().color('gold', 0.25) # Mesh

plt = FreeHandCutPlotter(msh).add_hover_legend()
plt.start(axes=1, bg2='lightblue')
plt.mesh.write("test.ply")
plt.close()

m = Mesh("test.ply").color('pink')
show(m).close()