meshquality.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. """Metrics of quality for
  2. the cells of a triangular mesh
  3. (zoom to see cell label values)"""
  4. from vedo import dataurl, Mesh, show
  5. from vedo.pyplot import histogram
  6. mesh = Mesh(dataurl + "panther.stl").compute_normals().linewidth(0.1).flat()
  7. # generate a numpy array for mesh quality
  8. mesh.compute_quality(metric=6)
  9. mesh.cmap("RdYlBu")
  10. hist = histogram(mesh.celldata["Quality"], xtitle="mesh quality", ac="w")
  11. # make it smaller and position it, use_bounds makes the cam
  12. # ignore the object when resetting the 3d qscene
  13. hist.scale(0.6).pos(40, -53, 0).use_bounds(False)
  14. # add a scalar bar for the active scalars
  15. mesh.add_scalarbar3d(c="w", title="triangle quality by min(:alpha_i )")
  16. # create numeric labels of active scalar on top of cells
  17. labs = mesh.labels(on="cells", precision=3, scale=0.4, font="Quikhand", c="black")
  18. cam = dict(
  19. pos=(59.8, -191, 78.9),
  20. focal_point=(27.9, -2.94, 3.33),
  21. viewup=(-0.0170, 0.370, 0.929),
  22. distance=205,
  23. clipping_range=(87.8, 355),
  24. )
  25. show(mesh, labs, hist, __doc__, bg="bb", camera=cam, axes=11).close()