tests: test via placement failure

This commit is contained in:
Mikolaj Wielgus 2024-06-12 01:51:04 +02:00
parent f91dadf4d3
commit 90bc90350d
4 changed files with 41 additions and 9 deletions

View File

@ -23,6 +23,7 @@ use crate::{
drawing::{
dot::FixedDotIndex,
graph::{GetLayer, GetMaybeNet},
Infringement,
},
layout::{via::ViaWeight, Layout},
math::Circle,
@ -41,6 +42,8 @@ pub enum AutorouterError {
Navmesh(#[from] NavmeshError),
#[error(transparent)]
Router(#[from] RouterError),
#[error("could not place via")]
CouldNotPlaceVia(#[from] Infringement),
}
pub enum AutorouterStatus {
@ -96,7 +99,7 @@ impl<M: MesadataTrait> Autorouter<M> {
}
pub fn place_via(&mut self, weight: ViaWeight) -> Result<(), AutorouterError> {
self.board.layout_mut().add_via(weight);
self.board.layout_mut().add_via(weight)?;
Ok(())
}

View File

@ -383,9 +383,9 @@ impl eframe::App for App {
to_layer: 0,
circle: Circle {
pos: point! {x: latest_pos.x as f64, y: -latest_pos.y as f64},
r: 100.0,
r: 10000.0,
},
maybe_net: None,
maybe_net: Some(1234),
}),
&mut EmptyRouterObserver,
);

View File

@ -780,6 +780,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
&limiting_shape.envelope_3d(0.0, node.primitive(self).layer()),
)
.filter_map(|wrapper| {
dbg!("a");
if let GenericNode::Primitive(primitive_node) = wrapper.data {
Some(primitive_node)
} else {
@ -787,19 +788,21 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
}
})
.filter(|primitive_node| {
dbg!("b");
maybe_except.is_some_and(|except| !except.contains(&primitive_node))
})
.filter(|primitive_node| !self.are_connectable(node, *primitive_node))
.filter(|primitive_node| dbg!(!self.are_connectable(node, *primitive_node)))
.filter(|primitive_node| {
dbg!(node, primitive_node);
let infringee_conditions = primitive_node.primitive(self).conditions();
let epsilon = 1.0;
inflated_shape = node.primitive(self).shape().inflate(
inflated_shape = dbg!(node.primitive(self).shape().inflate(
(self.rules.clearance(&conditions, &infringee_conditions) - epsilon)
.clamp(0.0, f64::INFINITY),
);
));
inflated_shape.intersects(&primitive_node.primitive(self).shape())
dbg!(inflated_shape.intersects(&dbg!(primitive_node.primitive(self).shape())))
})
.map(|primitive_node| primitive_node)
.next()

View File

@ -5,14 +5,19 @@ use petgraph::{
visit::{EdgeRef, IntoEdgeReferences, NodeIndexable},
};
use topola::{
autorouter::{invoker::Invoker, Autorouter},
autorouter::{
invoker::{Command, Invoker, InvokerError},
Autorouter, AutorouterError,
},
drawing::{
graph::{GetLayer, GetMaybeNet},
primitive::GetInnerOuter,
},
dsn::design::DsnDesign,
graph::GetNodeIndex,
layout::NodeIndex,
layout::{via::ViaWeight, NodeIndex},
math::Circle,
router::EmptyRouterObserver,
triangulation::GetTrianvertexIndex,
};
@ -48,6 +53,27 @@ fn test_tht_diode_bridge_rectifier() {
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
//common::assert_number_of_conncomps(&mut autorouter, 4);
common::assert_band_length(autorouter.board(), "J2-2", "D4-2", 15500.0, 0.5);
let mut invoker = Invoker::new(autorouter);
let result = invoker.execute(
Command::PlaceVia(ViaWeight {
from_layer: 0,
to_layer: 1,
circle: Circle {
pos: [0.0, 0.0].into(),
r: 200000.0,
},
maybe_net: Some(1234),
}),
&mut EmptyRouterObserver,
);
let result = dbg!(result);
assert!(matches!(
result,
Err(InvokerError::Autorouter(AutorouterError::CouldNotPlaceVia(
..
)))
));
}
#[test]