Module OManifold.Sdf3

3d signed-distance functions (convertible to mesh/manifold via a level set algorith)

type t = OCADml.v3 -> float

A negative inside, positive outside signed-distance function.

Shapes

val sphere : float -> t
val cube : ?round:float -> OCADml.v3 -> t
val torus : OCADml.v2 -> t
val cylinder : ?round:float -> height:float -> float -> t

Transformations

val translate : OCADml.v3 -> t -> t
val xtrans : float -> t -> t
val ytrans : float -> t -> t
val ztrans : float -> t -> t
val rotate : ?about:OCADml.v3 -> OCADml.v3 -> t -> t
val xrot : ?about:OCADml.v3 -> float -> t -> t
val yrot : ?about:OCADml.v3 -> float -> t -> t
val zrot : ?about:OCADml.v3 -> float -> t -> t
val quaternion : ?about:OCADml.v3 -> OCADml.Quaternion.t -> t -> t
val axis_rotate : ?about:OCADml.v3 -> OCADml.v3 -> float -> t -> t
val scale : float -> t -> t
val round : float -> t -> t
val onion : float -> t -> t
val elongate : OCADml.v3 -> t -> t

Booleans

val union : ?smooth:float -> t -> t -> t
val difference : ?smooth:float -> t -> t -> t
val intersection : ?smooth:float -> t -> t -> t

Mesh Generation

val to_mmeshgl : ?level:float -> ?edge_length:float -> box:OCADml.Box3.t -> t -> {mmeshgl}2

to_mmeshgl ?level ?edge_length ~box t

Constructs a level-set Mesh from the signed-distance function t. This uses a form of Marching Tetrahedra (akin to Marching Cubes, but better for manifoldness). Instead of using a cubic grid, it uses a body-centered cubic grid (two shifted cubic grids). This means if your function's interior exceeds the given bounds, you will see a kind of egg-crate shape closing off the manifold, which is due to the underlying grid. The output is guaranteed to be manifold, thus should always be an appropriate input to Manifold.of_mmeshgl.

  • box is and axis-aligned bounding box defining the extent of the grid overwhich t is evaluated
  • edge_length is the the approximate maximum edge length of the triangles in the final result. This affects grid spacing, thus strongly impacting performance.
  • level can be provided with a positive value to inset the mesh, or a negative value to outset it (default is 0. -- no offset)