slice_plane3.py 850 B

123456789101112131415161718192021222324252627282930313233343536
  1. """Interactively slice a Volume along a plane.
  2. Middle button + drag to slide the plane along the arrow"""
  3. from vedo import *
  4. normal = [0, 0, 1]
  5. cmap = "gist_stern_r"
  6. def func(w, _):
  7. c, n = pcutter.origin, pcutter.normal
  8. vslice = vol.slice_plane(c, n, autocrop=True).cmap(cmap)
  9. vslice.name = "Slice"
  10. plt.at(1).remove("Slice").add(vslice)
  11. vol = Volume(dataurl + "embryo.slc").cmap(cmap)
  12. vslice = vol.slice_plane(vol.center(), normal).cmap(cmap)
  13. vslice.name = "Slice"
  14. plt = Plotter(axes=0, N=2, bg="k", bg2="bb")
  15. pcutter = PlaneCutter(
  16. vslice,
  17. normal=normal,
  18. alpha=0,
  19. c="white",
  20. padding=0,
  21. )
  22. pcutter.add_observer("interaction", func)
  23. plt.at(0).add(vol, __doc__)
  24. plt.at(1).add(pcutter, vol.box())
  25. pcutter.on() # enable the cutter after adding it to the plotter
  26. plt.show(zoom=1.2)
  27. plt.interactive()
  28. plt.close()