mirror of https://codeberg.org/topola/topola.git
terminology: suffix some single-verb object type names with "Stepper"
This commit is contained in:
parent
632bfb7b63
commit
cc0bf1845a
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
drawing::{band::BandTermsegIndex, graph::PrimitiveIndex},
|
drawing::{band::BandTermsegIndex, graph::PrimitiveIndex},
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navmesh::Navmesh, route::Route, trace::Trace, Router, RouterStatus},
|
router::{navmesh::Navmesh, route::RouteStepper, trace::TraceStepper, Router, RouterStatus},
|
||||||
step::Step,
|
step::Step,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -30,14 +30,14 @@ impl TryInto<()> for AutorouteStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Autoroute {
|
pub struct AutorouteCommandStepper {
|
||||||
ratlines_iter: Box<dyn Iterator<Item = EdgeIndex<usize>>>,
|
ratlines_iter: Box<dyn Iterator<Item = EdgeIndex<usize>>>,
|
||||||
options: AutorouterOptions,
|
options: AutorouterOptions,
|
||||||
route: Option<Route>,
|
route: Option<RouteStepper>,
|
||||||
curr_ratline: Option<EdgeIndex<usize>>,
|
curr_ratline: Option<EdgeIndex<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Autoroute {
|
impl AutorouteCommandStepper {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
ratlines: impl IntoIterator<Item = EdgeIndex<usize>> + 'static,
|
ratlines: impl IntoIterator<Item = EdgeIndex<usize>> + 'static,
|
||||||
|
|
@ -63,7 +63,9 @@ impl Autoroute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()> for Autoroute {
|
impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()>
|
||||||
|
for AutorouteCommandStepper
|
||||||
|
{
|
||||||
fn step(&mut self, autorouter: &mut Autorouter<M>) -> Result<AutorouteStatus, AutorouterError> {
|
fn step(&mut self, autorouter: &mut Autorouter<M>) -> Result<AutorouteStatus, AutorouterError> {
|
||||||
let Some(curr_ratline) = self.curr_ratline else {
|
let Some(curr_ratline) = self.curr_ratline else {
|
||||||
return Ok(AutorouteStatus::Finished);
|
return Ok(AutorouteStatus::Finished);
|
||||||
|
|
@ -117,25 +119,25 @@ impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for Autoroute {
|
impl GetMaybeNavmesh for AutorouteCommandStepper {
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
self.route.as_ref().map(|route| route.navmesh())
|
self.route.as_ref().map(|route| route.navmesh())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for Autoroute {
|
impl GetMaybeTrace for AutorouteCommandStepper {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
self.route.as_ref().map(|route| route.trace())
|
self.route.as_ref().map(|route| route.trace())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for Autoroute {
|
impl GetGhosts for AutorouteCommandStepper {
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
self.route.as_ref().map_or(&[], |route| route.ghosts())
|
self.route.as_ref().map_or(&[], |route| route.ghosts())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for Autoroute {
|
impl GetObstacles for AutorouteCommandStepper {
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
self.route.as_ref().map_or(&[], |route| route.obstacles())
|
self.route.as_ref().map_or(&[], |route| route.obstacles())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
autoroute::Autoroute,
|
autoroute::AutorouteCommandStepper,
|
||||||
compare_detours::CompareDetours,
|
compare_detours::CompareDetoursCommandStepper,
|
||||||
measure_length::MeasureLength,
|
measure_length::MeasureLengthCommandStepper,
|
||||||
place_via::PlaceVia,
|
place_via::PlaceViaCommandStepper,
|
||||||
ratsnest::{Ratsnest, RatvertexIndex},
|
ratsnest::{Ratsnest, RatvertexIndex},
|
||||||
remove_bands::RemoveBands,
|
remove_bands::RemoveBandsCommandStepper,
|
||||||
selection::{BandSelection, PinSelection},
|
selection::{BandSelection, PinSelection},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
&mut self,
|
&mut self,
|
||||||
selection: &PinSelection,
|
selection: &PinSelection,
|
||||||
options: AutorouterOptions,
|
options: AutorouterOptions,
|
||||||
) -> Result<Autoroute, AutorouterError> {
|
) -> Result<AutorouteCommandStepper, AutorouterError> {
|
||||||
self.autoroute_ratlines(self.selected_ratlines(selection), options)
|
self.autoroute_ratlines(self.selected_ratlines(selection), options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,8 +70,8 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
&mut self,
|
&mut self,
|
||||||
ratlines: Vec<EdgeIndex<usize>>,
|
ratlines: Vec<EdgeIndex<usize>>,
|
||||||
options: AutorouterOptions,
|
options: AutorouterOptions,
|
||||||
) -> Result<Autoroute, AutorouterError> {
|
) -> Result<AutorouteCommandStepper, AutorouterError> {
|
||||||
Autoroute::new(self, ratlines, options)
|
AutorouteCommandStepper::new(self, ratlines, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn undo_autoroute(&mut self, selection: &PinSelection) -> Result<(), AutorouterError> {
|
pub fn undo_autoroute(&mut self, selection: &PinSelection) -> Result<(), AutorouterError> {
|
||||||
|
|
@ -99,16 +99,19 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceVia, AutorouterError> {
|
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceViaCommandStepper, AutorouterError> {
|
||||||
PlaceVia::new(weight)
|
PlaceViaCommandStepper::new(weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn undo_place_via(&mut self, _weight: ViaWeight) {
|
pub fn undo_place_via(&mut self, _weight: ViaWeight) {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_bands(&self, selection: &BandSelection) -> Result<RemoveBands, AutorouterError> {
|
pub fn remove_bands(
|
||||||
RemoveBands::new(selection)
|
&self,
|
||||||
|
selection: &BandSelection,
|
||||||
|
) -> Result<RemoveBandsCommandStepper, AutorouterError> {
|
||||||
|
RemoveBandsCommandStepper::new(selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn undo_remove_bands(&mut self, _selection: &BandSelection) {
|
pub fn undo_remove_bands(&mut self, _selection: &BandSelection) {
|
||||||
|
|
@ -119,7 +122,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
&mut self,
|
&mut self,
|
||||||
selection: &PinSelection,
|
selection: &PinSelection,
|
||||||
options: AutorouterOptions,
|
options: AutorouterOptions,
|
||||||
) -> Result<CompareDetours, AutorouterError> {
|
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
|
||||||
let ratlines = self.selected_ratlines(selection);
|
let ratlines = self.selected_ratlines(selection);
|
||||||
let ratline1 = *ratlines
|
let ratline1 = *ratlines
|
||||||
.get(0)
|
.get(0)
|
||||||
|
|
@ -135,15 +138,15 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
ratline1: EdgeIndex<usize>,
|
ratline1: EdgeIndex<usize>,
|
||||||
ratline2: EdgeIndex<usize>,
|
ratline2: EdgeIndex<usize>,
|
||||||
options: AutorouterOptions,
|
options: AutorouterOptions,
|
||||||
) -> Result<CompareDetours, AutorouterError> {
|
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
|
||||||
CompareDetours::new(self, ratline1, ratline2, options)
|
CompareDetoursCommandStepper::new(self, ratline1, ratline2, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn measure_length(
|
pub fn measure_length(
|
||||||
&mut self,
|
&mut self,
|
||||||
selection: &BandSelection,
|
selection: &BandSelection,
|
||||||
) -> Result<MeasureLength, AutorouterError> {
|
) -> Result<MeasureLengthCommandStepper, AutorouterError> {
|
||||||
MeasureLength::new(selection)
|
MeasureLengthCommandStepper::new(selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ratline_endpoints(
|
pub fn ratline_endpoints(
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::Step};
|
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::Step};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
autoroute::{Autoroute, AutorouteStatus},
|
autoroute::{AutorouteCommandStepper, AutorouteStatus},
|
||||||
compare_detours::{CompareDetours, CompareDetoursStatus},
|
compare_detours::{CompareDetoursCommandStepper, CompareDetoursStatus},
|
||||||
invoker::{Invoker, InvokerError, InvokerStatus},
|
invoker::{Invoker, InvokerError, InvokerStatus},
|
||||||
measure_length::MeasureLength,
|
measure_length::MeasureLengthCommandStepper,
|
||||||
place_via::PlaceVia,
|
place_via::PlaceViaCommandStepper,
|
||||||
remove_bands::RemoveBands,
|
remove_bands::RemoveBandsCommandStepper,
|
||||||
selection::{BandSelection, PinSelection},
|
selection::{BandSelection, PinSelection},
|
||||||
AutorouterOptions,
|
AutorouterOptions,
|
||||||
};
|
};
|
||||||
|
|
@ -26,40 +26,42 @@ pub enum Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch(GetMaybeNavmesh, GetMaybeTrace, GetGhosts, GetObstacles)]
|
#[enum_dispatch(GetMaybeNavmesh, GetMaybeTrace, GetGhosts, GetObstacles)]
|
||||||
pub enum Execute {
|
pub enum CommandStepper {
|
||||||
Autoroute(Autoroute),
|
Autoroute(AutorouteCommandStepper),
|
||||||
PlaceVia(PlaceVia),
|
PlaceVia(PlaceViaCommandStepper),
|
||||||
RemoveBands(RemoveBands),
|
RemoveBands(RemoveBandsCommandStepper),
|
||||||
CompareDetours(CompareDetours),
|
CompareDetours(CompareDetoursCommandStepper),
|
||||||
MeasureLength(MeasureLength),
|
MeasureLength(MeasureLengthCommandStepper),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Execute {
|
impl CommandStepper {
|
||||||
fn step_catch_err<M: AccessMesadata>(
|
fn step_catch_err<M: AccessMesadata>(
|
||||||
&mut self,
|
&mut self,
|
||||||
invoker: &mut Invoker<M>,
|
invoker: &mut Invoker<M>,
|
||||||
) -> Result<InvokerStatus, InvokerError> {
|
) -> Result<InvokerStatus, InvokerError> {
|
||||||
match self {
|
match self {
|
||||||
Execute::Autoroute(autoroute) => match autoroute.step(&mut invoker.autorouter)? {
|
CommandStepper::Autoroute(autoroute) => {
|
||||||
AutorouteStatus::Running => Ok(InvokerStatus::Running),
|
match autoroute.step(&mut invoker.autorouter)? {
|
||||||
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running),
|
AutorouteStatus::Running => Ok(InvokerStatus::Running),
|
||||||
AutorouteStatus::Finished => Ok(InvokerStatus::Finished(String::from(
|
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running),
|
||||||
"finished autorouting",
|
AutorouteStatus::Finished => Ok(InvokerStatus::Finished(String::from(
|
||||||
))),
|
"finished autorouting",
|
||||||
},
|
))),
|
||||||
Execute::PlaceVia(place_via) => {
|
}
|
||||||
|
}
|
||||||
|
CommandStepper::PlaceVia(place_via) => {
|
||||||
place_via.doit(&mut invoker.autorouter)?;
|
place_via.doit(&mut invoker.autorouter)?;
|
||||||
Ok(InvokerStatus::Finished(String::from(
|
Ok(InvokerStatus::Finished(String::from(
|
||||||
"finished placing via",
|
"finished placing via",
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
Execute::RemoveBands(remove_bands) => {
|
CommandStepper::RemoveBands(remove_bands) => {
|
||||||
remove_bands.doit(&mut invoker.autorouter)?;
|
remove_bands.doit(&mut invoker.autorouter)?;
|
||||||
Ok(InvokerStatus::Finished(String::from(
|
Ok(InvokerStatus::Finished(String::from(
|
||||||
"finished removing bands",
|
"finished removing bands",
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
Execute::CompareDetours(compare_detours) => {
|
CommandStepper::CompareDetours(compare_detours) => {
|
||||||
match compare_detours.step(&mut invoker.autorouter)? {
|
match compare_detours.step(&mut invoker.autorouter)? {
|
||||||
CompareDetoursStatus::Running => Ok(InvokerStatus::Running),
|
CompareDetoursStatus::Running => Ok(InvokerStatus::Running),
|
||||||
CompareDetoursStatus::Finished(total_length1, total_length2) => {
|
CompareDetoursStatus::Finished(total_length1, total_length2) => {
|
||||||
|
|
@ -70,7 +72,7 @@ impl Execute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Execute::MeasureLength(measure_length) => {
|
CommandStepper::MeasureLength(measure_length) => {
|
||||||
let length = measure_length.doit(&mut invoker.autorouter)?;
|
let length = measure_length.doit(&mut invoker.autorouter)?;
|
||||||
Ok(InvokerStatus::Finished(format!(
|
Ok(InvokerStatus::Finished(format!(
|
||||||
"Total length of selected bands: {}",
|
"Total length of selected bands: {}",
|
||||||
|
|
@ -81,7 +83,7 @@ impl Execute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata> Step<Invoker<M>, InvokerStatus, InvokerError, ()> for Execute {
|
impl<M: AccessMesadata> Step<Invoker<M>, InvokerStatus, InvokerError, ()> for CommandStepper {
|
||||||
fn step(&mut self, invoker: &mut Invoker<M>) -> Result<InvokerStatus, InvokerError> {
|
fn step(&mut self, invoker: &mut Invoker<M>) -> Result<InvokerStatus, InvokerError> {
|
||||||
match self.step_catch_err(invoker) {
|
match self.step_catch_err(invoker) {
|
||||||
Ok(InvokerStatus::Running) => Ok(InvokerStatus::Running),
|
Ok(InvokerStatus::Running) => Ok(InvokerStatus::Running),
|
||||||
|
|
@ -5,12 +5,12 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::{primitive::PrimitiveShape, shape::MeasureLength},
|
geometry::{primitive::PrimitiveShape, shape::MeasureLength},
|
||||||
graph::MakeRef,
|
graph::MakeRef,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
step::Step,
|
step::Step,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
autoroute::{Autoroute, AutorouteStatus},
|
autoroute::{AutorouteCommandStepper, AutorouteStatus},
|
||||||
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles},
|
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles},
|
||||||
Autorouter, AutorouterError, AutorouterOptions,
|
Autorouter, AutorouterError, AutorouterOptions,
|
||||||
};
|
};
|
||||||
|
|
@ -32,9 +32,9 @@ impl TryInto<(f64, f64)> for CompareDetoursStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CompareDetours {
|
pub struct CompareDetoursCommandStepper {
|
||||||
autoroute: Autoroute,
|
autoroute: AutorouteCommandStepper,
|
||||||
next_autoroute: Option<Autoroute>,
|
next_autoroute: Option<AutorouteCommandStepper>,
|
||||||
ratline1: EdgeIndex<usize>,
|
ratline1: EdgeIndex<usize>,
|
||||||
ratline2: EdgeIndex<usize>,
|
ratline2: EdgeIndex<usize>,
|
||||||
total_length1: f64,
|
total_length1: f64,
|
||||||
|
|
@ -42,7 +42,7 @@ pub struct CompareDetours {
|
||||||
done: bool,
|
done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareDetours {
|
impl CompareDetoursCommandStepper {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
ratline1: EdgeIndex<usize>,
|
ratline1: EdgeIndex<usize>,
|
||||||
|
|
@ -64,7 +64,7 @@ impl CompareDetours {
|
||||||
// XXX: Do we really need this to be a stepper? We don't use at the moment, as sorting functions
|
// XXX: Do we really need this to be a stepper? We don't use at the moment, as sorting functions
|
||||||
// aren't steppable either. It may be useful for debugging later on tho.
|
// aren't steppable either. It may be useful for debugging later on tho.
|
||||||
impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterError, (f64, f64)>
|
impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterError, (f64, f64)>
|
||||||
for CompareDetours
|
for CompareDetoursCommandStepper
|
||||||
{
|
{
|
||||||
fn step(
|
fn step(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -112,25 +112,25 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for CompareDetours {
|
impl GetMaybeNavmesh for CompareDetoursCommandStepper {
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
self.autoroute.maybe_navmesh()
|
self.autoroute.maybe_navmesh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for CompareDetours {
|
impl GetMaybeTrace for CompareDetoursCommandStepper {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
self.autoroute.maybe_trace()
|
self.autoroute.maybe_trace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for CompareDetours {
|
impl GetGhosts for CompareDetoursCommandStepper {
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
self.autoroute.ghosts()
|
self.autoroute.ghosts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for CompareDetours {
|
impl GetObstacles for CompareDetoursCommandStepper {
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
self.autoroute.obstacles()
|
self.autoroute.obstacles()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::autorouter::execute::Command;
|
use crate::autorouter::command::Command;
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug, Clone)]
|
||||||
pub enum HistoryError {
|
pub enum HistoryError {
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,18 @@ use crate::{
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
step::Step,
|
step::Step,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
autoroute::Autoroute,
|
autoroute::AutorouteCommandStepper,
|
||||||
compare_detours::CompareDetours,
|
command::{Command, CommandStepper},
|
||||||
execute::{Command, Execute},
|
compare_detours::CompareDetoursCommandStepper,
|
||||||
history::{History, HistoryError},
|
history::{History, HistoryError},
|
||||||
measure_length::MeasureLength,
|
measure_length::MeasureLengthCommandStepper,
|
||||||
place_via::PlaceVia,
|
place_via::PlaceViaCommandStepper,
|
||||||
remove_bands::RemoveBands,
|
remove_bands::RemoveBandsCommandStepper,
|
||||||
Autorouter, AutorouterError,
|
Autorouter, AutorouterError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ pub trait GetMaybeNavmesh {
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
pub trait GetMaybeTrace {
|
pub trait GetMaybeTrace {
|
||||||
fn maybe_trace(&self) -> Option<&Trace>;
|
fn maybe_trace(&self) -> Option<&TraceStepper>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
|
|
@ -108,14 +108,14 @@ impl<M: AccessMesadata> Invoker<M> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_requires(self.ongoing_command.is_none())]
|
#[debug_requires(self.ongoing_command.is_none())]
|
||||||
pub fn execute_stepper(&mut self, command: Command) -> Result<Execute, InvokerError> {
|
pub fn execute_stepper(&mut self, command: Command) -> Result<CommandStepper, InvokerError> {
|
||||||
let execute = self.dispatch_command(&command);
|
let execute = self.dispatch_command(&command);
|
||||||
self.ongoing_command = Some(command);
|
self.ongoing_command = Some(command);
|
||||||
execute
|
execute
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_requires(self.ongoing_command.is_none())]
|
#[debug_requires(self.ongoing_command.is_none())]
|
||||||
fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> {
|
fn dispatch_command(&mut self, command: &Command) -> Result<CommandStepper, InvokerError> {
|
||||||
Ok(match command {
|
Ok(match command {
|
||||||
Command::Autoroute(selection, options) => {
|
Command::Autoroute(selection, options) => {
|
||||||
let mut ratlines = self.autorouter.selected_ratlines(selection);
|
let mut ratlines = self.autorouter.selected_ratlines(selection);
|
||||||
|
|
@ -134,17 +134,19 @@ impl<M: AccessMesadata> Invoker<M> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Execute::Autoroute(self.autorouter.autoroute_ratlines(ratlines, *options)?)
|
CommandStepper::Autoroute(self.autorouter.autoroute_ratlines(ratlines, *options)?)
|
||||||
|
}
|
||||||
|
Command::PlaceVia(weight) => {
|
||||||
|
CommandStepper::PlaceVia(self.autorouter.place_via(*weight)?)
|
||||||
}
|
}
|
||||||
Command::PlaceVia(weight) => Execute::PlaceVia(self.autorouter.place_via(*weight)?),
|
|
||||||
Command::RemoveBands(selection) => {
|
Command::RemoveBands(selection) => {
|
||||||
Execute::RemoveBands(self.autorouter.remove_bands(selection)?)
|
CommandStepper::RemoveBands(self.autorouter.remove_bands(selection)?)
|
||||||
}
|
|
||||||
Command::CompareDetours(selection, options) => {
|
|
||||||
Execute::CompareDetours(self.autorouter.compare_detours(selection, *options)?)
|
|
||||||
}
|
}
|
||||||
|
Command::CompareDetours(selection, options) => CommandStepper::CompareDetours(
|
||||||
|
self.autorouter.compare_detours(selection, *options)?,
|
||||||
|
),
|
||||||
Command::MeasureLength(selection) => {
|
Command::MeasureLength(selection) => {
|
||||||
Execute::MeasureLength(self.autorouter.measure_length(selection)?)
|
CommandStepper::MeasureLength(self.autorouter.measure_length(selection)?)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::{primitive::PrimitiveShape, shape::MeasureLength as MeasureLengthTrait},
|
geometry::{primitive::PrimitiveShape, shape::MeasureLength as MeasureLengthTrait},
|
||||||
graph::MakeRef,
|
graph::MakeRef,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -12,12 +12,12 @@ use super::{
|
||||||
Autorouter, AutorouterError,
|
Autorouter, AutorouterError,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct MeasureLength {
|
pub struct MeasureLengthCommandStepper {
|
||||||
selection: BandSelection,
|
selection: BandSelection,
|
||||||
maybe_length: Option<f64>,
|
maybe_length: Option<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MeasureLength {
|
impl MeasureLengthCommandStepper {
|
||||||
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
selection: selection.clone(),
|
selection: selection.clone(),
|
||||||
|
|
@ -51,25 +51,25 @@ impl MeasureLength {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for MeasureLength {
|
impl GetMaybeNavmesh for MeasureLengthCommandStepper {
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for MeasureLength {
|
impl GetMaybeTrace for MeasureLengthCommandStepper {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for MeasureLength {
|
impl GetGhosts for MeasureLengthCommandStepper {
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for MeasureLength {
|
impl GetObstacles for MeasureLengthCommandStepper {
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
pub mod autoroute;
|
pub mod autoroute;
|
||||||
mod autorouter;
|
mod autorouter;
|
||||||
|
pub mod command;
|
||||||
pub mod compare_detours;
|
pub mod compare_detours;
|
||||||
pub mod execute;
|
|
||||||
pub mod history;
|
pub mod history;
|
||||||
pub mod invoker;
|
pub mod invoker;
|
||||||
pub mod measure_length;
|
pub mod measure_length;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
layout::via::ViaWeight,
|
layout::via::ViaWeight,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -12,12 +12,12 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PlaceVia {
|
pub struct PlaceViaCommandStepper {
|
||||||
weight: ViaWeight,
|
weight: ViaWeight,
|
||||||
done: bool,
|
done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlaceVia {
|
impl PlaceViaCommandStepper {
|
||||||
pub fn new(weight: ViaWeight) -> Result<Self, AutorouterError> {
|
pub fn new(weight: ViaWeight) -> Result<Self, AutorouterError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
weight,
|
weight,
|
||||||
|
|
@ -39,25 +39,25 @@ impl PlaceVia {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for PlaceVia {
|
impl GetMaybeNavmesh for PlaceViaCommandStepper {
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for PlaceVia {
|
impl GetMaybeTrace for PlaceViaCommandStepper {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for PlaceVia {
|
impl GetGhosts for PlaceViaCommandStepper {
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for PlaceVia {
|
impl GetObstacles for PlaceViaCommandStepper {
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -12,12 +12,12 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RemoveBands {
|
pub struct RemoveBandsCommandStepper {
|
||||||
selection: BandSelection,
|
selection: BandSelection,
|
||||||
done: bool,
|
done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RemoveBands {
|
impl RemoveBandsCommandStepper {
|
||||||
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
selection: selection.clone(),
|
selection: selection.clone(),
|
||||||
|
|
@ -47,25 +47,25 @@ impl RemoveBands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for RemoveBands {
|
impl GetMaybeNavmesh for RemoveBandsCommandStepper {
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for RemoveBands {
|
impl GetMaybeTrace for RemoveBandsCommandStepper {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for RemoveBands {
|
impl GetGhosts for RemoveBandsCommandStepper {
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for RemoveBands {
|
impl GetObstacles for RemoveBandsCommandStepper {
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
&[]
|
&[]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
execute::Execute,
|
command::CommandStepper,
|
||||||
invoker::{
|
invoker::{
|
||||||
GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError,
|
GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError,
|
||||||
InvokerStatus,
|
InvokerStatus,
|
||||||
|
|
@ -10,7 +10,7 @@ use topola::{
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navmesh::Navmesh, trace::Trace},
|
router::{navmesh::Navmesh, trace::TraceStepper},
|
||||||
specctra::mesadata::SpecctraMesadata,
|
specctra::mesadata::SpecctraMesadata,
|
||||||
step::Step,
|
step::Step,
|
||||||
};
|
};
|
||||||
|
|
@ -46,67 +46,67 @@ impl TryInto<()> for ActivityStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Activity {
|
pub enum ActivityStepper {
|
||||||
// There will be another variant for interactive activities here soon. (TODO)
|
// There will be another variant for interactive activities here soon. (TODO)
|
||||||
Execute(Execute),
|
Command(CommandStepper),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for Activity {
|
impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for ActivityStepper {
|
||||||
fn step(
|
fn step(
|
||||||
&mut self,
|
&mut self,
|
||||||
invoker: &mut Invoker<SpecctraMesadata>,
|
invoker: &mut Invoker<SpecctraMesadata>,
|
||||||
) -> Result<ActivityStatus, ActivityError> {
|
) -> Result<ActivityStatus, ActivityError> {
|
||||||
match self {
|
match self {
|
||||||
Activity::Execute(execute) => Ok(execute.step(invoker)?.into()),
|
ActivityStepper::Command(execute) => Ok(execute.step(invoker)?.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeNavmesh for Activity {
|
impl GetMaybeNavmesh for ActivityStepper {
|
||||||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||||
match self {
|
match self {
|
||||||
Activity::Execute(execute) => execute.maybe_navmesh(),
|
ActivityStepper::Command(execute) => execute.maybe_navmesh(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for Activity {
|
impl GetMaybeTrace for ActivityStepper {
|
||||||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
match self {
|
match self {
|
||||||
Activity::Execute(execute) => execute.maybe_trace(),
|
ActivityStepper::Command(execute) => execute.maybe_trace(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetGhosts for Activity {
|
impl GetGhosts for ActivityStepper {
|
||||||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||||
match self {
|
match self {
|
||||||
Activity::Execute(execute) => execute.ghosts(),
|
ActivityStepper::Command(execute) => execute.ghosts(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetObstacles for Activity {
|
impl GetObstacles for ActivityStepper {
|
||||||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||||
match self {
|
match self {
|
||||||
Activity::Execute(execute) => execute.obstacles(),
|
ActivityStepper::Command(execute) => execute.obstacles(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ActivityWithStatus {
|
pub struct ActivityWithStatus {
|
||||||
activity: Activity,
|
activity: ActivityStepper,
|
||||||
maybe_status: Option<ActivityStatus>,
|
maybe_status: Option<ActivityStatus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActivityWithStatus {
|
impl ActivityWithStatus {
|
||||||
pub fn new_execute(execute: Execute) -> ActivityWithStatus {
|
pub fn new_execute(execute: CommandStepper) -> ActivityWithStatus {
|
||||||
Self {
|
Self {
|
||||||
activity: Activity::Execute(execute),
|
activity: ActivityStepper::Command(execute),
|
||||||
maybe_status: None,
|
maybe_status: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ impl GetMaybeNavmesh for ActivityWithStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetMaybeTrace for ActivityWithStatus {
|
impl GetMaybeTrace for ActivityWithStatus {
|
||||||
fn maybe_trace(&self) -> Option<&Trace> {
|
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||||
self.activity.maybe_trace()
|
self.activity.maybe_trace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ use topola::{
|
||||||
router::{
|
router::{
|
||||||
draw::DrawException,
|
draw::DrawException,
|
||||||
navmesh::{BinavvertexNodeIndex, Navmesh},
|
navmesh::{BinavvertexNodeIndex, Navmesh},
|
||||||
trace::Trace,
|
trace::TraceStepper,
|
||||||
tracer::Tracer,
|
tracer::Tracer,
|
||||||
},
|
},
|
||||||
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
|
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
execute::Command,
|
command::Command,
|
||||||
invoker::{Invoker, InvokerError, InvokerStatus},
|
invoker::{Invoker, InvokerError, InvokerStatus},
|
||||||
AutorouterOptions,
|
AutorouterOptions,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use petgraph::{
|
||||||
use rstar::{Envelope, AABB};
|
use rstar::{Envelope, AABB};
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
execute::Command,
|
command::Command,
|
||||||
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker},
|
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker},
|
||||||
},
|
},
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use topola::autorouter::execute::Command;
|
use topola::autorouter::command::Command;
|
||||||
use topola::autorouter::history::History;
|
use topola::autorouter::history::History;
|
||||||
use topola::autorouter::invoker::Invoker;
|
use topola::autorouter::invoker::Invoker;
|
||||||
use topola::autorouter::selection::PinSelection;
|
use topola::autorouter::selection::PinSelection;
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,21 @@ use crate::{
|
||||||
router::{
|
router::{
|
||||||
astar::{Astar, AstarStatus},
|
astar::{Astar, AstarStatus},
|
||||||
navmesh::Navmesh,
|
navmesh::Navmesh,
|
||||||
trace::Trace,
|
trace::TraceStepper,
|
||||||
tracer::Tracer,
|
tracer::Tracer,
|
||||||
Router, RouterAstarStrategy, RouterError, RouterStatus,
|
Router, RouterAstarStrategy, RouterError, RouterStatus,
|
||||||
},
|
},
|
||||||
step::Step,
|
step::Step,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Route {
|
pub struct RouteStepper {
|
||||||
astar: Astar<Navmesh, f64>,
|
astar: Astar<Navmesh, f64>,
|
||||||
trace: Trace,
|
trace: TraceStepper,
|
||||||
ghosts: Vec<PrimitiveShape>,
|
ghosts: Vec<PrimitiveShape>,
|
||||||
obstacles: Vec<PrimitiveIndex>,
|
obstacles: Vec<PrimitiveIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Route {
|
impl RouteStepper {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
router: &mut Router<impl AccessRules>,
|
router: &mut Router<impl AccessRules>,
|
||||||
from: FixedDotIndex,
|
from: FixedDotIndex,
|
||||||
|
|
@ -60,7 +60,7 @@ impl Route {
|
||||||
&self.astar.graph
|
&self.astar.graph
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trace(&self) -> &Trace {
|
pub fn trace(&self) -> &TraceStepper {
|
||||||
&self.trace
|
&self.trace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ impl Route {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> Step<Router<'a, R>, RouterStatus, RouterError, BandTermsegIndex>
|
impl<'a, R: AccessRules> Step<Router<'a, R>, RouterStatus, RouterError, BandTermsegIndex>
|
||||||
for Route
|
for RouteStepper
|
||||||
{
|
{
|
||||||
fn step(&mut self, router: &mut Router<R>) -> Result<RouterStatus, RouterError> {
|
fn step(&mut self, router: &mut Router<R>) -> Result<RouterStatus, RouterError> {
|
||||||
let tracer = Tracer::new(router.layout_mut());
|
let tracer = Tracer::new(router.layout_mut());
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ use super::{
|
||||||
astar::{AstarError, AstarStrategy, PathTracker},
|
astar::{AstarError, AstarStrategy, PathTracker},
|
||||||
draw::DrawException,
|
draw::DrawException,
|
||||||
navmesh::{Navmesh, NavmeshEdgeReference, NavmeshError, NavvertexIndex},
|
navmesh::{Navmesh, NavmeshEdgeReference, NavmeshError, NavvertexIndex},
|
||||||
route::Route,
|
route::RouteStepper,
|
||||||
trace::{Trace, TraceStepContext},
|
trace::{TraceStepContext, TraceStepper},
|
||||||
tracer::{Tracer, TracerException},
|
tracer::{Tracer, TracerException},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -63,14 +63,14 @@ impl TryInto<BandTermsegIndex> for RouterStatus {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
||||||
pub tracer: Tracer<'a, R>,
|
pub tracer: Tracer<'a, R>,
|
||||||
pub trace: &'a mut Trace,
|
pub trace: &'a mut TraceStepper,
|
||||||
pub target: FixedDotIndex,
|
pub target: FixedDotIndex,
|
||||||
pub probe_ghosts: Vec<PrimitiveShape>,
|
pub probe_ghosts: Vec<PrimitiveShape>,
|
||||||
pub probe_obstacles: Vec<PrimitiveIndex>,
|
pub probe_obstacles: Vec<PrimitiveIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
||||||
pub fn new(tracer: Tracer<'a, R>, trace: &'a mut Trace, target: FixedDotIndex) -> Self {
|
pub fn new(tracer: Tracer<'a, R>, trace: &'a mut TraceStepper, target: FixedDotIndex) -> Self {
|
||||||
Self {
|
Self {
|
||||||
tracer,
|
tracer,
|
||||||
trace,
|
trace,
|
||||||
|
|
@ -200,8 +200,8 @@ impl<'a, R: AccessRules> Router<'a, R> {
|
||||||
from: FixedDotIndex,
|
from: FixedDotIndex,
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Route, RouterError> {
|
) -> Result<RouteStepper, RouterError> {
|
||||||
Route::new(self, from, to, width)
|
RouteStepper::new(self, from, to, width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout_mut(&mut self) -> &mut Layout<R> {
|
pub fn layout_mut(&mut self) -> &mut Layout<R> {
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,18 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Trace {
|
pub struct TraceStepper {
|
||||||
pub path: Vec<NavvertexIndex>,
|
pub path: Vec<NavvertexIndex>,
|
||||||
pub head: Head,
|
pub head: Head,
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trace {
|
impl TraceStepper {
|
||||||
pub fn new(source: FixedDotIndex, source_navvertex: NavvertexIndex, width: f64) -> Trace {
|
pub fn new(
|
||||||
|
source: FixedDotIndex,
|
||||||
|
source_navvertex: NavvertexIndex,
|
||||||
|
width: f64,
|
||||||
|
) -> TraceStepper {
|
||||||
Self {
|
Self {
|
||||||
path: vec![source_navvertex],
|
path: vec![source_navvertex],
|
||||||
head: BareHead { face: source }.into(),
|
head: BareHead { face: source }.into(),
|
||||||
|
|
@ -101,7 +105,7 @@ pub struct TraceStepContext<'a: 'b, 'b, R: AccessRules> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, R: AccessRules> Step<TraceStepContext<'a, 'b, R>, TracerStatus, TracerException, ()>
|
impl<'a, 'b, R: AccessRules> Step<TraceStepContext<'a, 'b, R>, TracerStatus, TracerException, ()>
|
||||||
for Trace
|
for TraceStepper
|
||||||
{
|
{
|
||||||
#[debug_ensures(ret.is_ok() -> matches!(self.head, Head::Cane(..)))]
|
#[debug_ensures(ret.is_ok() -> matches!(self.head, Head::Cane(..)))]
|
||||||
#[debug_ensures(ret.is_ok() -> self.path.len() == old(self.path.len() + 1))]
|
#[debug_ensures(ret.is_ok() -> self.path.len() == old(self.path.len() + 1))]
|
||||||
|
|
@ -125,7 +129,9 @@ impl<'a, 'b, R: AccessRules> Step<TraceStepContext<'a, 'b, R>, TracerStatus, Tra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> StepBack<Tracer<'a, R>, TracerStatus, TracerException, ()> for Trace {
|
impl<'a, R: AccessRules> StepBack<Tracer<'a, R>, TracerStatus, TracerException, ()>
|
||||||
|
for TraceStepper
|
||||||
|
{
|
||||||
#[debug_ensures(self.path.len() == old(self.path.len() - 1))]
|
#[debug_ensures(self.path.len() == old(self.path.len() - 1))]
|
||||||
fn step_back(&mut self, tracer: &mut Tracer<'a, R>) -> Result<TracerStatus, TracerException> {
|
fn step_back(&mut self, tracer: &mut Tracer<'a, R>) -> Result<TracerStatus, TracerException> {
|
||||||
if let Head::Cane(head) = self.head {
|
if let Head::Cane(head) = self.head {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
use super::{
|
use super::{
|
||||||
draw::{Draw, DrawException},
|
draw::{Draw, DrawException},
|
||||||
navmesh::{Navmesh, NavvertexIndex},
|
navmesh::{Navmesh, NavvertexIndex},
|
||||||
trace::{Trace, TraceStepContext},
|
trace::{TraceStepContext, TraceStepper},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone, Copy)]
|
#[derive(Error, Debug, Clone, Copy)]
|
||||||
|
|
@ -51,14 +51,14 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
|
||||||
source: FixedDotIndex,
|
source: FixedDotIndex,
|
||||||
source_navvertex: NavvertexIndex,
|
source_navvertex: NavvertexIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Trace {
|
) -> TraceStepper {
|
||||||
Trace::new(source, source_navvertex, width)
|
TraceStepper::new(source, source_navvertex, width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(
|
pub fn finish(
|
||||||
&mut self,
|
&mut self,
|
||||||
_navmesh: &Navmesh,
|
_navmesh: &Navmesh,
|
||||||
trace: &mut Trace,
|
trace: &mut TraceStepper,
|
||||||
target: FixedDotIndex,
|
target: FixedDotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<BandTermsegIndex, TracerException> {
|
) -> Result<BandTermsegIndex, TracerException> {
|
||||||
|
|
@ -70,7 +70,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
|
||||||
pub fn rework_path(
|
pub fn rework_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
navmesh: &Navmesh,
|
navmesh: &Navmesh,
|
||||||
trace: &mut Trace,
|
trace: &mut TraceStepper,
|
||||||
path: &[NavvertexIndex],
|
path: &[NavvertexIndex],
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(), TracerException> {
|
) -> Result<(), TracerException> {
|
||||||
|
|
@ -90,7 +90,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
|
||||||
pub fn path(
|
pub fn path(
|
||||||
&mut self,
|
&mut self,
|
||||||
navmesh: &Navmesh,
|
navmesh: &Navmesh,
|
||||||
trace: &mut Trace,
|
trace: &mut TraceStepper,
|
||||||
path: &[NavvertexIndex],
|
path: &[NavvertexIndex],
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(), TracerException> {
|
) -> Result<(), TracerException> {
|
||||||
|
|
@ -110,7 +110,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(trace.path.len() == old(trace.path.len() - step_count))]
|
#[debug_ensures(trace.path.len() == old(trace.path.len() - step_count))]
|
||||||
pub fn undo_path(&mut self, trace: &mut Trace, step_count: usize) {
|
pub fn undo_path(&mut self, trace: &mut TraceStepper, step_count: usize) {
|
||||||
for _ in 0..step_count {
|
for _ in 0..step_count {
|
||||||
let _ = trace.step_back(self);
|
let _ = trace.step_back(self);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{execute::Command, invoker::InvokerError, AutorouterError},
|
autorouter::{command::Command, invoker::InvokerError, AutorouterError},
|
||||||
board::mesadata::AccessMesadata,
|
board::mesadata::AccessMesadata,
|
||||||
layout::via::ViaWeight,
|
layout::via::ViaWeight,
|
||||||
math::Circle,
|
math::Circle,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
execute::Command,
|
command::Command,
|
||||||
invoker::{Invoker, InvokerError},
|
invoker::{Invoker, InvokerError},
|
||||||
AutorouterError,
|
AutorouterError,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue