align6.py 927 B

12345678910111213141516171819202122232425262728293031
  1. """Align to bounding boxes. Force the Mesh into the empty box."""
  2. from vedo import Mesh, dataurl, Axes, Cube, Plotter
  3. # Load a mesh and color it silver
  4. msh1 = Mesh(dataurl + "cessna.vtk").color("silver")
  5. # Create axes for the original mesh
  6. axes1 = Axes(msh1)
  7. # Create a wireframe cube at a specified position
  8. cube = Cube().pos(2, 1, 0).wireframe()
  9. # Clone the mesh and align it to the bounding box of the cube
  10. msh2 = msh1.clone().align_to_bounding_box(cube)
  11. # Create axes for the aligned mesh
  12. axes2 = Axes(msh2)
  13. # Set up a Plotter object with 2 subrenderers
  14. plt = Plotter(N=2)
  15. # Add the original mesh, axes, and cube in the left renderer with the script description
  16. plt.at(0).add(msh1, axes1, cube, __doc__)
  17. # Add the aligned mesh and axes in the right renderer, viewing from the top
  18. plt.at(1).add(msh2, axes2, cube)
  19. # Show all and close the plotter when done
  20. plt.show(viewup='z', zoom=0.6)
  21. plt.interactive().close()