morphogen.models.union

Microstructures made of a union of spheres and segments (grains, fibres, struts).

class morphogen.models.union.PrimitiveUnion(domain: Domain, spheres: Spheres | None = None, segments: Segments | None = None, **kwargs)[source]

Bases: Microstructure

Phase 1 is the union of the spheres and segments, phase 0 its complement.

For periodic domains the primitives are stored once (reference points inside the box) and their periodic images are added when the structure is rasterized.

voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling=1)[source]

Phase image (uint8), or partial volume fractions of phase 1 (float32) when supersampling > 1 (supersampling**3 sub-samples per voxel).

level_set(shape=None, *, voxel_size=None, grid: Grid | None = None, band: float | None = None) → VoxelImage[source]

Signed distance to the union (negative inside), exact outside the grains and clipped to [-band, band] (default: 4 voxels).

contains(points) → ndarray[source]

Whether points lie in phase 1.

level_set_at(points, reach: float = inf) → ndarray[source]

The signed distance to the union (negative inside), clipped to [-reach, reach] (default: a tenth of the smallest side of the box).

signed_distance(points, band: float) → ndarray[source]

Signed distance at arbitrary points, clipped to [-band, band].

implicit_pieces(depth: float = 0.0) → tuple[list, int] | None[source]

The primitives grouped so that no two of a group overlap: the pieces of phase 1, in what phase 0 leaves (see morphogen.models.pieces); None for the unions of more phases.

summary() → dict[source]

Counts and sizes describing the realization.