delaunay2d.py 725 B

12345678910111213141516171819
  1. """Delaunay 2D meshing with point loops defining holes"""
  2. from vedo import Grid, show
  3. # Generate a grid and add gaussian noise to it
  4. # then extract the points from the grid and store them in the variable gp
  5. gp = Grid().add_gaussian_noise([0.5,0.5,0]).point_size(8)
  6. # Define two internal holes using point ids
  7. ids = [[24,35,36,37,26,15,14,25], [84,95,96,85]]
  8. # Use the Delaunay triangulation algorithm to create a 2D mesh
  9. # from the points in gp, with the given boundary ids
  10. dly = gp.generate_delaunay2d(mode='xy', boundaries=ids)
  11. dly.c('white').lc('orange').lw(1)
  12. # Create labels for the point ids and set their z to 0.01
  13. labels = gp.labels('id').z(0.01)
  14. show(gp, labels, dly, __doc__, bg="Mint", zoom='tight').close()