File: mesh_map2cell.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 683 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Map an array which is defined on
the vertices of a mesh to its cells"""
from vedo import *

doc = Text2D(__doc__, pos="top-center")

mesh1 = Mesh(dataurl+'icosahedron.vtk').linewidth(0.1).flat()

# let the scalar be the z coordinate of the mesh vertices
msg1 = Text2D("Scalars originally defined on points..", pos="bottom-center")
mesh1.pointdata["myzscalars"] = mesh1.vertices[:, 2]

mesh1.cmap("jet", "myzscalars", on="points")

msg2 = Text2D("..are interpolated to cells.", pos="bottom-center")
mesh2 = mesh1.clone(deep=False).map_points_to_cells()

plt = Plotter(N=2, axes=11)
plt.at(0).show(mesh1, msg1, doc, viewup="z")
plt.at(1).show(mesh2, msg2)
plt.interactive().close()