boundaries.py 682 B

12345678910111213141516171819
  1. """Extract points on the boundary of a mesh.
  2. Add an ID label to all vertices."""
  3. from vedo import Mesh, dataurl, Points, show
  4. # Load a mesh from a URL, compute normals, and clean duplicate points
  5. b = Mesh(dataurl+'290.vtk')
  6. b.compute_normals().clean().linewidth(0.1)
  7. # Get the point IDs on the boundary of the mesh
  8. pids = b.boundaries(return_point_ids=True)
  9. # Create a Points object to represent the boundary points
  10. pts = Points(b.vertices[pids]).c('red5').ps(10)
  11. # Create a Label object for all the vertices in the mesh
  12. labels = b.labels('id', scale=10).c('green2')
  13. # Show the mesh, boundary points, vertex labels, and docstring
  14. show(b, pts, labels, __doc__, zoom=2).close()