voronoi2.py 529 B

12345678910111213141516
  1. """Voronoi tessellation of a pointcloud on a grid"""
  2. from vedo import dataurl, Points, Grid, show
  3. pts0 = Points(dataurl+'rios.xyz').color('k')
  4. pts1 = pts0.clone().smooth_lloyd_2d()
  5. grid = Grid([14500,61700], s=[22000,24000], res=[30,30]).ps(1)
  6. allpts = pts1.vertices.tolist() + grid.vertices.tolist()
  7. msh = Points(allpts).generate_voronoi(method='scipy')
  8. msh.lw(1).wireframe(False).cmap('terrain_r', 'VoronoiID', on='cells')
  9. # centers = msh.cell_centers().color("k")
  10. show(msh, pts0, __doc__, axes=dict(digits=3), zoom=1.3)