misc cleanup and tuning
This commit is contained in:
parent
f600b52f32
commit
07d079846b
15 changed files with 168 additions and 165 deletions
|
|
@ -87,11 +87,15 @@ class CollisionEngine:
|
|||
"""Count how many other nets collide with this geometry."""
|
||||
dilation = self.clearance / 2.0
|
||||
test_poly = geometry.buffer(dilation)
|
||||
candidates = self.dynamic_paths.intersection(test_poly.bounds)
|
||||
return self.count_congestion_prebuffered(test_poly, net_id)
|
||||
|
||||
def count_congestion_prebuffered(self, dilated_geometry: Polygon, net_id: str) -> int:
|
||||
"""Count how many other nets collide with this pre-dilated geometry."""
|
||||
candidates = self.dynamic_paths.intersection(dilated_geometry.bounds)
|
||||
count = 0
|
||||
for obj_id in candidates:
|
||||
other_net_id, other_poly = self.path_geometries[obj_id]
|
||||
if other_net_id != net_id and test_poly.intersects(other_poly):
|
||||
if other_net_id != net_id and dilated_geometry.intersects(other_poly):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
|
@ -106,17 +110,25 @@ class CollisionEngine:
|
|||
_ = net_width # Width is already integrated into engine dilation settings
|
||||
dilation = self.clearance / 2.0
|
||||
test_poly = geometry.buffer(dilation)
|
||||
return self.is_collision_prebuffered(test_poly, start_port=start_port, end_port=end_port)
|
||||
|
||||
def is_collision_prebuffered(
|
||||
self,
|
||||
dilated_geometry: Polygon,
|
||||
start_port: Port | None = None,
|
||||
end_port: Port | None = None,
|
||||
) -> bool:
|
||||
"""Check if a pre-dilated geometry collides with static obstacles."""
|
||||
# Broad prune with R-Tree
|
||||
candidates = self.static_obstacles.intersection(test_poly.bounds)
|
||||
candidates = self.static_obstacles.intersection(dilated_geometry.bounds)
|
||||
|
||||
for obj_id in candidates:
|
||||
# Use prepared geometry for fast intersection
|
||||
if self.prepared_obstacles[obj_id].intersects(test_poly):
|
||||
if self.prepared_obstacles[obj_id].intersects(dilated_geometry):
|
||||
# Check safety zone (2nm = 0.002 um)
|
||||
if start_port or end_port:
|
||||
obstacle = self.obstacle_geometries[obj_id]
|
||||
intersection = test_poly.intersection(obstacle)
|
||||
intersection = dilated_geometry.intersection(obstacle)
|
||||
|
||||
if intersection.is_empty:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue