delaunay3d.py 583 B

12345678910111213141516171819202122
  1. """Delaunay 3D tetralization"""
  2. from vedo import *
  3. import numpy as np
  4. settings.use_depth_peeling = True
  5. pts = (np.random.rand(10000, 3)-0.5)*2
  6. s = Sphere().alpha(0.1)
  7. pin = s.inside_points(pts)
  8. pin.subsample(0.05) # impose min separation (5% of bounding box)
  9. printc("# of points inside the sphere:", pin.npoints)
  10. tmesh = pin.generate_delaunay3d().shrink(0.95)
  11. cmesh = tmesh.cut_with_plane(normal=(1,2,-1))
  12. # cmesh.pipeline.show() # to show the graph of operations
  13. show([(s, pin, "Generate points in a Sphere"),
  14. (cmesh.tomesh(), __doc__),
  15. ], N=2, axes=1,
  16. ).close()