connected_vtx.py 746 B

123456789101112131415161718192021222324
  1. """Find the vertices that are connected
  2. to a specific vertex in a mesh"""
  3. from vedo import Sphere, Point, Points, show
  4. # create a wireframe sphere and color it yellow
  5. s = Sphere(res=12).wireframe().c("yellow")
  6. # select one point on the sphere using its index
  7. index = 12
  8. pt = s.vertices[index]
  9. # find all the vertices that are connected to the selected point
  10. ids = s.connected_vertices(index)
  11. vtxs = s.vertices[ids]
  12. # create a red point at the selected point's location
  13. apt = Point(pt).c("red5").ps(15)
  14. # create blue points at the locations of the vertices
  15. # connected to the selected point
  16. cpts = Points(vtxs).c("blue5").ps(20)
  17. # show the sphere, the selected point, and the connected vertices
  18. show(s, apt, cpts, __doc__, bg='bb').close()