lots more refactoring
This commit is contained in:
parent
941d3e01df
commit
bc218a416b
1 changed files with 1433 additions and 1694 deletions
53
inire/router/_seed_materialization.py
Normal file
53
inire/router/_seed_materialization.py
Normal 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)
|
||||
Loading…
Reference in a new issue