mesh_map2cell.py 683 B

123456789101112131415161718192021
  1. """Map an array which is defined on
  2. the vertices of a mesh to its cells"""
  3. from vedo import *
  4. doc = Text2D(__doc__, pos="top-center")
  5. mesh1 = Mesh(dataurl+'icosahedron.vtk').linewidth(0.1).flat()
  6. # let the scalar be the z coordinate of the mesh vertices
  7. msg1 = Text2D("Scalars originally defined on points..", pos="bottom-center")
  8. mesh1.pointdata["myzscalars"] = mesh1.vertices[:, 2]
  9. mesh1.cmap("jet", "myzscalars", on="points")
  10. msg2 = Text2D("..are interpolated to cells.", pos="bottom-center")
  11. mesh2 = mesh1.clone(deep=False).map_points_to_cells()
  12. plt = Plotter(N=2, axes=11)
  13. plt.at(0).show(mesh1, msg1, doc, viewup="z")
  14. plt.at(1).show(mesh2, msg2)
  15. plt.interactive().close()