morphogen.primitives

Explicit geometric primitives: spheres and segments (cylinders or spherocylinders).

These are the “vector” description of grain-based microstructures. Rasterization, signed distances and exports all work from these arrays.

class morphogen.primitives.Spheres(centers: 'np.ndarray', radii: 'np.ndarray')[source]

Bases: object

bounds() → tuple[ndarray, ndarray][source]
extent() → float[source]

Largest distance from a primitive’s reference point to its surface.

subset(mask) → Spheres[source]
translated(shift) → Spheres[source]
static concatenate(items: list[Spheres]) → Spheres[source]
volumes() → ndarray[source]
to_dict() → dict[source]
class morphogen.primitives.Segments(start: ndarray, end: ndarray, radii: ndarray, round_caps: bool = True)[source]

Bases: object

Cylinders of axis [start, end] with flat caps, or spherocylinders (round caps).

property lengths: ndarray
property midpoints: ndarray
bounds() → tuple[ndarray, ndarray][source]
extent() → float[source]
subset(mask) → Segments[source]
translated(shift) → Segments[source]
static concatenate(items: list[Segments], round_caps: bool = True) → Segments[source]
volumes() → ndarray[source]
to_dict() → dict[source]
morphogen.primitives.overlapping_box(prims: Spheres | Segments, lower, upper, margin: float = 0.0) → ndarray[source]

Mask of the primitives whose bounding box meets [lower - margin, upper + margin].

morphogen.primitives.with_periodic_images(prims: Spheres | Segments, domain: Domain, margin: float = 0.0) → Spheres | Segments[source]

Primitives plus the periodic copies needed to cover the box (and margin around).

Every primitive whose bounding box, shifted by a combination of box periods, meets the box is added with that shift, so that a non-periodic rasterization of the result over the box equals the periodic microstructure.

morphogen.primitives.restricted_to_box(prims: Spheres | Segments, domain: Domain, margin: float = 0.0) → Spheres | Segments[source]

Primitives whose bounding box meets the (non-periodic) box enlarged by margin.