meshing.diagnostics.surface_deviation
meshing.diagnostics.surface_deviation(sdf, mesh, *, samples=2048, seed=0)Sampled one-sided deviation of the mesh from the implicit surface.
Draws samples points uniformly by triangle area (triangles chosen with probability proportional to their area, then uniform barycentric coordinates within each) using the deterministic np.random.default_rng(seed), and evaluates |sdf| at every point. For a signed distance field this is the exact mesh-to-surface distance at the samples; for a general implicit field it is the field residual.
This is one-sided: it bounds how far the mesh strays from the zero set, but says nothing about surface regions the mesh misses entirely. The opposite direction (surface-to-mesh) needs a closest-point query against the mesh and is out of scope here.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sdf | Callable[[Array], Array] | Implicit field mapping one point (3,) to a scalar; sampled points are evaluated through jax.vmap. |
required |
| mesh | Mesh | The extracted mesh to measure. | required |
| samples | int | Number of surface samples; must be positive. | 2048 |
| seed | int | Seed for the deterministic sample draw. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| dict[str, Any] | Dict with max_abs and mean_abs (floats, the absolute field |
|
| dict[str, Any] | values over the samples) and samples (the count actually drawn). |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If samples is not positive, the mesh has no faces, or the total triangle area is zero. |