misc improvements?
This commit is contained in:
parent
91256cbcf9
commit
c6116f88f3
1 changed files with 197 additions and 58 deletions
|
|
@ -34,7 +34,7 @@ class ComponentResult:
|
|||
"""
|
||||
The result of a component generation: geometry, final port, and physical length.
|
||||
"""
|
||||
__slots__ = ('geometry', 'dilated_geometry', 'proxy_geometry', 'actual_geometry', 'end_port', 'length', 'bounds', 'dilated_bounds', '_t_cache')
|
||||
__slots__ = ('geometry', 'dilated_geometry', 'proxy_geometry', 'actual_geometry', 'end_port', 'length', 'bounds', 'dilated_bounds', 'move_type', '_t_cache')
|
||||
|
||||
geometry: list[Polygon]
|
||||
""" List of polygons representing the component geometry (could be proxy or arc) """
|
||||
|
|
@ -60,6 +60,9 @@ class ComponentResult:
|
|||
dilated_bounds: numpy.ndarray | None
|
||||
""" Pre-calculated bounds for each polygon in dilated_geometry """
|
||||
|
||||
move_type: str | None
|
||||
""" Identifier for the type of move (e.g. 'Straight', 'Bend90', 'SBend') """
|
||||
|
||||
_t_cache: dict[tuple[float, float], ComponentResult]
|
||||
""" Cache for translated versions of this result """
|
||||
|
||||
|
|
@ -72,6 +75,7 @@ class ComponentResult:
|
|||
proxy_geometry: list[Polygon] | None = None,
|
||||
actual_geometry: list[Polygon] | None = None,
|
||||
skip_bounds: bool = False,
|
||||
move_type: str | None = None,
|
||||
) -> None:
|
||||
self.geometry = geometry
|
||||
self.dilated_geometry = dilated_geometry
|
||||
|
|
@ -79,6 +83,7 @@ class ComponentResult:
|
|||
self.actual_geometry = actual_geometry
|
||||
self.end_port = end_port
|
||||
self.length = length
|
||||
self.move_type = move_type
|
||||
self._t_cache = {}
|
||||
if not skip_bounds:
|
||||
# Vectorized bounds calculation
|
||||
|
|
@ -121,7 +126,7 @@ class ComponentResult:
|
|||
new_actual = translated[offsets[2]:offsets[3]] if self.actual_geometry is not None else None
|
||||
|
||||
new_port = Port(self.end_port.x + dx, self.end_port.y + dy, self.end_port.orientation)
|
||||
res = ComponentResult(new_geom, new_port, self.length, new_dil, new_proxy, new_actual, skip_bounds=True)
|
||||
res = ComponentResult(new_geom, new_port, self.length, new_dil, new_proxy, new_actual, skip_bounds=True, move_type=self.move_type)
|
||||
|
||||
# Optimize: reuse and translate bounds
|
||||
res.bounds = self.bounds + [dx, dy, dx, dy]
|
||||
|
|
@ -207,7 +212,7 @@ class Straight:
|
|||
dilated_geom = [Polygon(poly_points_dil)]
|
||||
|
||||
# For straight segments, geom IS the actual geometry
|
||||
return ComponentResult(geometry=geom, end_port=end_port, length=actual_length, dilated_geometry=dilated_geom, actual_geometry=geom)
|
||||
return ComponentResult(geometry=geom, end_port=end_port, length=actual_length, dilated_geometry=dilated_geom, actual_geometry=geom, move_type='Straight')
|
||||
|
||||
|
||||
def _get_num_segments(radius: float, angle_deg: float, sagitta: float = 0.01) -> int:
|
||||
|
|
@ -491,7 +496,10 @@ class Bend90:
|
|||
length=actual_radius * numpy.abs(t_end - t_start),
|
||||
dilated_geometry=dilated_geom,
|
||||
proxy_geometry=proxy_geom,
|
||||
actual_geometry=arc_polys
|
||||
actual_geometry=arc_polys,
|
||||
move_type='Bend90'
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -578,5 +586,6 @@ class SBend:
|
|||
length=2 * actual_radius * theta,
|
||||
dilated_geometry=dilated_geom,
|
||||
proxy_geometry=proxy_geom,
|
||||
actual_geometry=arc_polys
|
||||
actual_geometry=arc_polys,
|
||||
move_type='SBend'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue