performance improvements
This commit is contained in:
parent
8eb0dbf64a
commit
8424171946
12 changed files with 212 additions and 118 deletions
|
|
@ -50,7 +50,7 @@ def test_sbend_generation() -> None:
|
|||
result = SBend.generate(start, offset, radius, width)
|
||||
assert result.end_port.y == 5.0
|
||||
assert result.end_port.orientation == 0.0
|
||||
assert len(result.geometry) == 1 # Now uses unary_union
|
||||
assert len(result.geometry) == 2 # Optimization: returns individual arcs
|
||||
|
||||
# Verify failure for large offset
|
||||
with pytest.raises(ValueError, match=r"SBend offset .* must be less than 2\*radius"):
|
||||
|
|
@ -85,11 +85,13 @@ def test_sbend_collision_models() -> None:
|
|||
width = 2.0
|
||||
|
||||
res_bbox = SBend.generate(start, offset, radius, width, collision_type="bbox")
|
||||
# Geometry should be a single bounding box polygon
|
||||
assert len(res_bbox.geometry) == 1
|
||||
# Geometry should be a list of individual bbox polygons for each arc
|
||||
assert len(res_bbox.geometry) == 2
|
||||
|
||||
res_arc = SBend.generate(start, offset, radius, width, collision_type="arc")
|
||||
assert res_bbox.geometry[0].area > res_arc.geometry[0].area
|
||||
area_bbox = sum(p.area for p in res_bbox.geometry)
|
||||
area_arc = sum(p.area for p in res_arc.geometry)
|
||||
assert area_bbox > area_arc
|
||||
|
||||
|
||||
def test_sbend_continuity() -> None:
|
||||
|
|
@ -107,9 +109,10 @@ def test_sbend_continuity() -> None:
|
|||
# For a port at 90 deg, +offset is a shift in -x direction
|
||||
assert abs(res.end_port.x - (10.0 - offset)) < 1e-6
|
||||
|
||||
# Geometry should be connected (unary_union results in 1 polygon)
|
||||
assert len(res.geometry) == 1
|
||||
assert res.geometry[0].is_valid
|
||||
# Geometry should be a list of valid polygons
|
||||
assert len(res.geometry) == 2
|
||||
for p in res.geometry:
|
||||
assert p.is_valid
|
||||
|
||||
|
||||
def test_arc_sagitta_precision() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue