mascaf.cable_fitting¶
- class mascaf.cable_fitting.FitOptions(max_edge_length=1.0, radius_strategy='equivalent_area', section_probe_eps=0.0001, section_probe_tries=3, multi_tangent_reduction='mean', basis_optimizer_options=None)[source]¶
Bases:
objectConfiguration options for cable fitting and local radius estimation.
- Attributes:
- max_edge_length: Maximum edge length along unbranching sections in mesh
units. Resampling keeps section endpoints fixed and introduces interior samples so no segment exceeds this value.
- radius_strategy: Strategy for estimating node radii. One of:
“equivalent_area” (default): r = sqrt(A/pi) using cross-section area.
“equivalent_perimeter”: r = L/(2*pi) using exterior boundary length.
“section_median”: median ray-to-boundary distance in the local section plane from the sample origin.
“section_circle_fit”: algebraic circle fit (Kasa) to the section boundary.
“nearest_surface”: distance from the sample point to nearest mesh surface.
- section_probe_eps: Step size (scaled by mesh bbox) for offsetting
the section plane origin along the local normal when the exact plane yields no curves.
- section_probe_tries: Number of +/- k*eps offsets to try when seeking a
section.
- multi_tangent_reduction: Reduction applied to the per-edge radii
computed at each node. One of “mean”, “min”, “max”, or “median”.
- basis_optimizer_options: Optional configuration for geometry
optimization of the downsampled MorphologyGraph basis prior to radius fitting.
- Parameters:
- basis_optimizer_options: BasisOptimizerOptions | None = None¶
- __init__(max_edge_length=1.0, radius_strategy='equivalent_area', section_probe_eps=0.0001, section_probe_tries=3, multi_tangent_reduction='mean', basis_optimizer_options=None)¶
- class mascaf.cable_fitting.CableFitter(options=None)[source]¶
Bases:
objectFit a cable-style
MorphologyGraphfrom a mesh and skeleton.The fitter resamples each unbranching section of the skeleton so that no segment exceeds
FitOptions.max_edge_length, optionally optimizes the intermediate basis withBasisOptimizer, then estimates local radii from mesh cross-sections.- Parameters:
options (
Optional[FitOptions]) – Fitting configuration. Defaults toFitOptionswith all defaults whenNone.
Examples
>>> fitter = CableFitter(FitOptions(max_edge_length=1.0)) >>> morphology = fitter.fit(mesh_mgr, skeleton)
- __init__(options=None)[source]¶
Store fitter configuration, using defaults when none are provided.
- Parameters:
options (FitOptions | None)
- Return type:
None
- fit(mesh, skeleton)[source]¶
Build a
MorphologyGraphfrom a mesh and skeleton.- Parameters:
mesh (
Union[Trimesh,MeshManager]) – The closed triangle mesh used to estimate local radii.skeleton (
SkeletonGraph) – The curve skeleton that defines morphology topology and geometry.
- Returns:
Fitted morphology with node positions and radii. Returns an empty graph if
skeletonhas no nodes.- Return type:
- Raises:
ValueError – If
meshis empty.TypeError – If
meshorskeletonare not the expected types.