mirror of https://codeberg.org/topola/topola.git
Compare commits
2 Commits
6e5352e426
...
066f9b82df
| Author | SHA1 | Date |
|---|---|---|
|
|
066f9b82df | |
|
|
5e8d5974f4 |
|
|
@ -94,6 +94,7 @@ allowed_scopes = [
|
|||
"router/router",
|
||||
"router/thetastar",
|
||||
"specctra/design",
|
||||
"astar",
|
||||
"stepper",
|
||||
"triangulation",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -51,17 +51,17 @@ tr-menu-route-options-squeeze-through-under-bends = 弯曲处挤线
|
|||
tr-menu-view-kdb-scroll-delta-factor = 键盘滚动增量因子
|
||||
tr-menu-debug-show-pathfinding-scores = 显示路径查找分数
|
||||
tr-menu-place-place-route-plan = 放置布线规划
|
||||
tr-menu-route-topo-autoroute = 拓扑平面自动布线
|
||||
tr-menu-route-topo-autoroute = 拓扑平面自动布线
|
||||
tr-menu-debug-show-triangulation = 显示三角剖分
|
||||
tr-menu-debug-show-triangulation-constraints = 显示三角剖分约束条件
|
||||
tr-menu-route-options-presort-by = 预排序依据
|
||||
tr-menu-route-options-presort-by-ratline-intersection-count-and-length = 交叉点数量及长度
|
||||
tr-menu-route-options-presort-by-ratline-intersection-count-and-length = 交叉点数量及长度
|
||||
tr-menu-route-options-permutate = 排列组合
|
||||
tr-menu-debug-show-guide-circles = 显示辅助圆
|
||||
tr-menu-debug-show-guide-bitangents = 显示双切线
|
||||
tr-menu-debug-show-primitive-indices = 显示图元索引
|
||||
tr-menu-debug-show-primitive-indices = 显示图元索引
|
||||
tr-menu-route-planar-autoroute = 平面自动布线
|
||||
tr-menu-route-fanout-clearance = 扇出间距
|
||||
tr-menu-route-fanout-clearance = 扇出间距
|
||||
tr-menu-debug = 调试
|
||||
tr-menu-debug-fix-step-rate = 固定步进速率
|
||||
tr-menu-debug-highlight-obstacles = 高亮障碍物
|
||||
|
|
|
|||
51
src/astar.rs
51
src/astar.rs
|
|
@ -36,30 +36,37 @@ impl<N: Clone + Ord, S: Add<S, Output = S> + Copy + Default + PartialOrd> Astar<
|
|||
}
|
||||
|
||||
pub fn expand(&mut self, new_nodes: &[(S, S, N)]) -> Option<N> {
|
||||
let curr_g_score = self.g_scores.get(&self.curr_node).unwrap().clone();
|
||||
|
||||
for (edge_g_cost, h_heuristic, node) in new_nodes {
|
||||
match self.g_scores.entry(node.clone()) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
let entry_score = *entry.get();
|
||||
|
||||
if curr_g_score + *edge_g_cost >= entry_score {
|
||||
continue;
|
||||
}
|
||||
|
||||
entry.insert(curr_g_score + *edge_g_cost);
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(curr_g_score + *edge_g_cost);
|
||||
}
|
||||
}
|
||||
|
||||
self.frontier.push(MinScored(
|
||||
curr_g_score + *edge_g_cost + *h_heuristic,
|
||||
node.clone(),
|
||||
));
|
||||
for new_node in new_nodes {
|
||||
self.push(new_node.clone());
|
||||
}
|
||||
|
||||
self.pop()
|
||||
}
|
||||
|
||||
pub fn push(&mut self, new_node: (S, S, N)) {
|
||||
let curr_g_score = self.g_scores.get(&self.curr_node).unwrap().clone();
|
||||
let (edge_g_cost, h_heuristic, node) = new_node;
|
||||
|
||||
match self.g_scores.entry(node.clone()) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
let entry_score = *entry.get();
|
||||
|
||||
if curr_g_score + edge_g_cost >= entry_score {
|
||||
return;
|
||||
}
|
||||
|
||||
entry.insert(curr_g_score + edge_g_cost);
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(curr_g_score + edge_g_cost);
|
||||
}
|
||||
}
|
||||
|
||||
self.frontier
|
||||
.push(MinScored(curr_g_score + edge_g_cost + h_heuristic, node));
|
||||
}
|
||||
|
||||
pub fn pop(&mut self) -> Option<N> {
|
||||
MinScored(_ /*f_score*/, self.curr_node) = self.frontier.pop()?;
|
||||
Some(self.curr_node.clone())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue