lots more refactoring

This commit is contained in:
Jan Petykiewicz 2026-03-30 19:51:37 -07:00
commit bc218a416b

View file

@ -0,0 +1,53 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from inire.model import SearchOptions
from inire.seeds import Bend90Seed, PathSeed, SBendSeed, StraightSeed
if TYPE_CHECKING:
from inire.geometry.components import ComponentResult
from inire.geometry.primitives import Port
def materialize_path_seed(
seed: PathSeed,
*,
start: Port,
net_width: float,
search: SearchOptions,
clearance: float,
) -> tuple[ComponentResult, ...]:
from inire.geometry.components import Bend90, SBend, Straight
path: list[ComponentResult] = []
current = start
dilation = clearance / 2.0
bend_collision_type = search.bend_collision_type
for segment in seed.segments:
if isinstance(segment, StraightSeed):
component = Straight.generate(current, segment.length, net_width, dilation=dilation)
elif isinstance(segment, Bend90Seed):
component = Bend90.generate(
current,
segment.radius,
net_width,
segment.direction,
collision_type=bend_collision_type,
dilation=dilation,
)
elif isinstance(segment, SBendSeed):
component = SBend.generate(
current,
segment.offset,
segment.radius,
net_width,
collision_type=bend_collision_type,
dilation=dilation,
)
else:
raise TypeError(f"Unsupported seed segment: {type(segment)!r}")
path.append(component)
current = component.end_port
return tuple(path)