Mesh manipulation#
from vedo import dataurl, Mesh, Arrows, show, settings
settings.default_backend = "vtk"
# Load a mesh
mesh = Mesh(dataurl+"man.vtk").color("white")
mesh
vedo.mesh.Mesh (....embl.es/examples/data/man.vtk)
|
# Create a heavily decimated copy with about 200 points
# (to speed up the computation)
mesh_dec = mesh.clone().triangulate().decimate(n=200)
mesh_dec
vedo.mesh.Mesh (....embl.es/examples/data/man.vtk)
|
sources = [[0.9, 0.0, 0.2]] # this point moves
targets = [[1.2, 0.0, 0.4]] # ...to this.
for pt in mesh_dec.points():
if pt[0] < 0.3: # while these pts don't move
sources.append(pt) # (e.i. source = target)
targets.append(pt)
# Warp the mesh
mesh_warped = mesh.clone().warp(sources, targets)
mesh_warped.c("blue").wireframe()
vedo.mesh.Mesh (....embl.es/examples/data/man.vtk)
|
# Create the arrows representing the displacement
arrow = Arrows(sources, targets)
# Show the meshes and the arrow
show(mesh, mesh_warped, arrow, axes=1).close()