waxmorph.data.sample_mesh_sequence

waxmorph.data.sample_mesh_sequence#

waxmorph.data.sample_mesh_sequence(source_path, target_specs, n_points=2000, *, target_extent=10.0, source_extent=None, seed=0)[source]#

Sample a source cloud and frame-tagged target clouds at exact equal counts.

Each repaired, normalized mesh starts from its own volume-derived radius and spacing:

\[r = \left(\frac{3V}{4\pi N}\right)^{1/3}, \qquad d_{\min} = 1.2\,r.\]

Exact-count sampling may lower each r and d_min together; returned radius fields hold the effective values. Frames are unique, nonnegative, and sorted in the result; trainers interpret them as zero-based post-update rollout steps. Extent sequences match input target_specs before sorting. A scalar or None extent applies to every target, with None meaning 10; per-target extents require source_extent. The source uses seed and sorted target k uses seed+1+k, producing independent reproducible clouds.

Returns:

  • "source_pos" – source agent centers, float32, shape [N, 3].

  • "targets": list of per-target dicts sorted by frame, each with "frame" (int rollout step), "pos" (float32 [N, 3] centers), "mesh" (normalized trimesh.Trimesh), "extent" (float), and "radius" (that target’s effective particle radius, float).

  • "radius": effective source radius (alias of "source_radius").

  • "R_init": initial uniform radius for the rollout (equals the source radius).

  • "n_points": requested count N.

  • "source_extent": source normalization extent (float).

  • "target_extent": per-target extent list if a sequence was given, else the single shared extent (float); ordered by sorted frame.

  • "target_extents": list of per-target extents in sorted-frame order.

  • "source_radius": effective source particle radius (float).

  • "target_radii": effective target radii in sorted-frame order.

Parameters:
Return type:

dict

Invalid specs, frames, extents, or counts raise ValueError. Exact-count sampling failure raises RuntimeError.