terminology: suffix some single-verb object type names with "Stepper"

This commit is contained in:
Mikolaj Wielgus 2024-10-01 14:11:02 +02:00
parent 632bfb7b63
commit cc0bf1845a
21 changed files with 170 additions and 155 deletions

View File

@ -4,7 +4,7 @@ use crate::{
board::mesadata::AccessMesadata,
drawing::{band::BandTermsegIndex, graph::PrimitiveIndex},
geometry::primitive::PrimitiveShape,
router::{navmesh::Navmesh, route::Route, trace::Trace, Router, RouterStatus},
router::{navmesh::Navmesh, route::RouteStepper, trace::TraceStepper, Router, RouterStatus},
step::Step,
};
@ -30,14 +30,14 @@ impl TryInto<()> for AutorouteStatus {
}
}
pub struct Autoroute {
pub struct AutorouteCommandStepper {
ratlines_iter: Box<dyn Iterator<Item = EdgeIndex<usize>>>,
options: AutorouterOptions,
route: Option<Route>,
route: Option<RouteStepper>,
curr_ratline: Option<EdgeIndex<usize>>,
}
impl Autoroute {
impl AutorouteCommandStepper {
pub fn new(
autorouter: &mut Autorouter<impl AccessMesadata>,
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> {
let Some(curr_ratline) = self.curr_ratline else {
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> {
self.route.as_ref().map(|route| route.navmesh())
}
}
impl GetMaybeTrace for Autoroute {
fn maybe_trace(&self) -> Option<&Trace> {
impl GetMaybeTrace for AutorouteCommandStepper {
fn maybe_trace(&self) -> Option<&TraceStepper> {
self.route.as_ref().map(|route| route.trace())
}
}
impl GetGhosts for Autoroute {
impl GetGhosts for AutorouteCommandStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
self.route.as_ref().map_or(&[], |route| route.ghosts())
}
}
impl GetObstacles for Autoroute {
impl GetObstacles for AutorouteCommandStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
self.route.as_ref().map_or(&[], |route| route.obstacles())
}

View File

@ -16,12 +16,12 @@ use crate::{
};
use super::{
autoroute::Autoroute,
compare_detours::CompareDetours,
measure_length::MeasureLength,
place_via::PlaceVia,
autoroute::AutorouteCommandStepper,
compare_detours::CompareDetoursCommandStepper,
measure_length::MeasureLengthCommandStepper,
place_via::PlaceViaCommandStepper,
ratsnest::{Ratsnest, RatvertexIndex},
remove_bands::RemoveBands,
remove_bands::RemoveBandsCommandStepper,
selection::{BandSelection, PinSelection},
};
@ -62,7 +62,7 @@ impl<M: AccessMesadata> Autorouter<M> {
&mut self,
selection: &PinSelection,
options: AutorouterOptions,
) -> Result<Autoroute, AutorouterError> {
) -> Result<AutorouteCommandStepper, AutorouterError> {
self.autoroute_ratlines(self.selected_ratlines(selection), options)
}
@ -70,8 +70,8 @@ impl<M: AccessMesadata> Autorouter<M> {
&mut self,
ratlines: Vec<EdgeIndex<usize>>,
options: AutorouterOptions,
) -> Result<Autoroute, AutorouterError> {
Autoroute::new(self, ratlines, options)
) -> Result<AutorouteCommandStepper, AutorouterError> {
AutorouteCommandStepper::new(self, ratlines, options)
}
pub fn undo_autoroute(&mut self, selection: &PinSelection) -> Result<(), AutorouterError> {
@ -99,16 +99,19 @@ impl<M: AccessMesadata> Autorouter<M> {
Ok(())
}
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceVia, AutorouterError> {
PlaceVia::new(weight)
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceViaCommandStepper, AutorouterError> {
PlaceViaCommandStepper::new(weight)
}
pub fn undo_place_via(&mut self, _weight: ViaWeight) {
todo!();
}
pub fn remove_bands(&self, selection: &BandSelection) -> Result<RemoveBands, AutorouterError> {
RemoveBands::new(selection)
pub fn remove_bands(
&self,
selection: &BandSelection,
) -> Result<RemoveBandsCommandStepper, AutorouterError> {
RemoveBandsCommandStepper::new(selection)
}
pub fn undo_remove_bands(&mut self, _selection: &BandSelection) {
@ -119,7 +122,7 @@ impl<M: AccessMesadata> Autorouter<M> {
&mut self,
selection: &PinSelection,
options: AutorouterOptions,
) -> Result<CompareDetours, AutorouterError> {
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
let ratlines = self.selected_ratlines(selection);
let ratline1 = *ratlines
.get(0)
@ -135,15 +138,15 @@ impl<M: AccessMesadata> Autorouter<M> {
ratline1: EdgeIndex<usize>,
ratline2: EdgeIndex<usize>,
options: AutorouterOptions,
) -> Result<CompareDetours, AutorouterError> {
CompareDetours::new(self, ratline1, ratline2, options)
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
CompareDetoursCommandStepper::new(self, ratline1, ratline2, options)
}
pub fn measure_length(
&mut self,
selection: &BandSelection,
) -> Result<MeasureLength, AutorouterError> {
MeasureLength::new(selection)
) -> Result<MeasureLengthCommandStepper, AutorouterError> {
MeasureLengthCommandStepper::new(selection)
}
pub fn ratline_endpoints(

View File

@ -4,12 +4,12 @@ use serde::{Deserialize, Serialize};
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::Step};
use super::{
autoroute::{Autoroute, AutorouteStatus},
compare_detours::{CompareDetours, CompareDetoursStatus},
autoroute::{AutorouteCommandStepper, AutorouteStatus},
compare_detours::{CompareDetoursCommandStepper, CompareDetoursStatus},
invoker::{Invoker, InvokerError, InvokerStatus},
measure_length::MeasureLength,
place_via::PlaceVia,
remove_bands::RemoveBands,
measure_length::MeasureLengthCommandStepper,
place_via::PlaceViaCommandStepper,
remove_bands::RemoveBandsCommandStepper,
selection::{BandSelection, PinSelection},
AutorouterOptions,
};
@ -26,40 +26,42 @@ pub enum Command {
}
#[enum_dispatch(GetMaybeNavmesh, GetMaybeTrace, GetGhosts, GetObstacles)]
pub enum Execute {
Autoroute(Autoroute),
PlaceVia(PlaceVia),
RemoveBands(RemoveBands),
CompareDetours(CompareDetours),
MeasureLength(MeasureLength),
pub enum CommandStepper {
Autoroute(AutorouteCommandStepper),
PlaceVia(PlaceViaCommandStepper),
RemoveBands(RemoveBandsCommandStepper),
CompareDetours(CompareDetoursCommandStepper),
MeasureLength(MeasureLengthCommandStepper),
}
impl Execute {
impl CommandStepper {
fn step_catch_err<M: AccessMesadata>(
&mut self,
invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> {
match self {
Execute::Autoroute(autoroute) => match autoroute.step(&mut invoker.autorouter)? {
CommandStepper::Autoroute(autoroute) => {
match autoroute.step(&mut invoker.autorouter)? {
AutorouteStatus::Running => Ok(InvokerStatus::Running),
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running),
AutorouteStatus::Finished => Ok(InvokerStatus::Finished(String::from(
"finished autorouting",
))),
},
Execute::PlaceVia(place_via) => {
}
}
CommandStepper::PlaceVia(place_via) => {
place_via.doit(&mut invoker.autorouter)?;
Ok(InvokerStatus::Finished(String::from(
"finished placing via",
)))
}
Execute::RemoveBands(remove_bands) => {
CommandStepper::RemoveBands(remove_bands) => {
remove_bands.doit(&mut invoker.autorouter)?;
Ok(InvokerStatus::Finished(String::from(
"finished removing bands",
)))
}
Execute::CompareDetours(compare_detours) => {
CommandStepper::CompareDetours(compare_detours) => {
match compare_detours.step(&mut invoker.autorouter)? {
CompareDetoursStatus::Running => Ok(InvokerStatus::Running),
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)?;
Ok(InvokerStatus::Finished(format!(
"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> {
match self.step_catch_err(invoker) {
Ok(InvokerStatus::Running) => Ok(InvokerStatus::Running),

View File

@ -5,12 +5,12 @@ use crate::{
drawing::graph::PrimitiveIndex,
geometry::{primitive::PrimitiveShape, shape::MeasureLength},
graph::MakeRef,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
step::Step,
};
use super::{
autoroute::{Autoroute, AutorouteStatus},
autoroute::{AutorouteCommandStepper, AutorouteStatus},
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles},
Autorouter, AutorouterError, AutorouterOptions,
};
@ -32,9 +32,9 @@ impl TryInto<(f64, f64)> for CompareDetoursStatus {
}
}
pub struct CompareDetours {
autoroute: Autoroute,
next_autoroute: Option<Autoroute>,
pub struct CompareDetoursCommandStepper {
autoroute: AutorouteCommandStepper,
next_autoroute: Option<AutorouteCommandStepper>,
ratline1: EdgeIndex<usize>,
ratline2: EdgeIndex<usize>,
total_length1: f64,
@ -42,7 +42,7 @@ pub struct CompareDetours {
done: bool,
}
impl CompareDetours {
impl CompareDetoursCommandStepper {
pub fn new(
autorouter: &mut Autorouter<impl AccessMesadata>,
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
// aren't steppable either. It may be useful for debugging later on tho.
impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterError, (f64, f64)>
for CompareDetours
for CompareDetoursCommandStepper
{
fn step(
&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> {
self.autoroute.maybe_navmesh()
}
}
impl GetMaybeTrace for CompareDetours {
fn maybe_trace(&self) -> Option<&Trace> {
impl GetMaybeTrace for CompareDetoursCommandStepper {
fn maybe_trace(&self) -> Option<&TraceStepper> {
self.autoroute.maybe_trace()
}
}
impl GetGhosts for CompareDetours {
impl GetGhosts for CompareDetoursCommandStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
self.autoroute.ghosts()
}
}
impl GetObstacles for CompareDetours {
impl GetObstacles for CompareDetoursCommandStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
self.autoroute.obstacles()
}

View File

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::autorouter::execute::Command;
use crate::autorouter::command::Command;
#[derive(Error, Debug, Clone)]
pub enum HistoryError {

View File

@ -8,18 +8,18 @@ use crate::{
board::mesadata::AccessMesadata,
drawing::graph::PrimitiveIndex,
geometry::primitive::PrimitiveShape,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
step::Step,
};
use super::{
autoroute::Autoroute,
compare_detours::CompareDetours,
execute::{Command, Execute},
autoroute::AutorouteCommandStepper,
command::{Command, CommandStepper},
compare_detours::CompareDetoursCommandStepper,
history::{History, HistoryError},
measure_length::MeasureLength,
place_via::PlaceVia,
remove_bands::RemoveBands,
measure_length::MeasureLengthCommandStepper,
place_via::PlaceViaCommandStepper,
remove_bands::RemoveBandsCommandStepper,
Autorouter, AutorouterError,
};
@ -30,7 +30,7 @@ pub trait GetMaybeNavmesh {
#[enum_dispatch]
pub trait GetMaybeTrace {
fn maybe_trace(&self) -> Option<&Trace>;
fn maybe_trace(&self) -> Option<&TraceStepper>;
}
#[enum_dispatch]
@ -108,14 +108,14 @@ impl<M: AccessMesadata> Invoker<M> {
}
#[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);
self.ongoing_command = Some(command);
execute
}
#[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 {
Command::Autoroute(selection, options) => {
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) => {
Execute::RemoveBands(self.autorouter.remove_bands(selection)?)
}
Command::CompareDetours(selection, options) => {
Execute::CompareDetours(self.autorouter.compare_detours(selection, *options)?)
CommandStepper::RemoveBands(self.autorouter.remove_bands(selection)?)
}
Command::CompareDetours(selection, options) => CommandStepper::CompareDetours(
self.autorouter.compare_detours(selection, *options)?,
),
Command::MeasureLength(selection) => {
Execute::MeasureLength(self.autorouter.measure_length(selection)?)
CommandStepper::MeasureLength(self.autorouter.measure_length(selection)?)
}
})
}

View File

@ -3,7 +3,7 @@ use crate::{
drawing::graph::PrimitiveIndex,
geometry::{primitive::PrimitiveShape, shape::MeasureLength as MeasureLengthTrait},
graph::MakeRef,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
};
use super::{
@ -12,12 +12,12 @@ use super::{
Autorouter, AutorouterError,
};
pub struct MeasureLength {
pub struct MeasureLengthCommandStepper {
selection: BandSelection,
maybe_length: Option<f64>,
}
impl MeasureLength {
impl MeasureLengthCommandStepper {
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
Ok(Self {
selection: selection.clone(),
@ -51,25 +51,25 @@ impl MeasureLength {
}
}
impl GetMaybeNavmesh for MeasureLength {
impl GetMaybeNavmesh for MeasureLengthCommandStepper {
fn maybe_navmesh(&self) -> Option<&Navmesh> {
None
}
}
impl GetMaybeTrace for MeasureLength {
fn maybe_trace(&self) -> Option<&Trace> {
impl GetMaybeTrace for MeasureLengthCommandStepper {
fn maybe_trace(&self) -> Option<&TraceStepper> {
None
}
}
impl GetGhosts for MeasureLength {
impl GetGhosts for MeasureLengthCommandStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for MeasureLength {
impl GetObstacles for MeasureLengthCommandStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}

View File

@ -1,7 +1,7 @@
pub mod autoroute;
mod autorouter;
pub mod command;
pub mod compare_detours;
pub mod execute;
pub mod history;
pub mod invoker;
pub mod measure_length;

View File

@ -3,7 +3,7 @@ use crate::{
drawing::graph::PrimitiveIndex,
geometry::primitive::PrimitiveShape,
layout::via::ViaWeight,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
};
use super::{
@ -12,12 +12,12 @@ use super::{
};
#[derive(Debug)]
pub struct PlaceVia {
pub struct PlaceViaCommandStepper {
weight: ViaWeight,
done: bool,
}
impl PlaceVia {
impl PlaceViaCommandStepper {
pub fn new(weight: ViaWeight) -> Result<Self, AutorouterError> {
Ok(Self {
weight,
@ -39,25 +39,25 @@ impl PlaceVia {
}
}
impl GetMaybeNavmesh for PlaceVia {
impl GetMaybeNavmesh for PlaceViaCommandStepper {
fn maybe_navmesh(&self) -> Option<&Navmesh> {
None
}
}
impl GetMaybeTrace for PlaceVia {
fn maybe_trace(&self) -> Option<&Trace> {
impl GetMaybeTrace for PlaceViaCommandStepper {
fn maybe_trace(&self) -> Option<&TraceStepper> {
None
}
}
impl GetGhosts for PlaceVia {
impl GetGhosts for PlaceViaCommandStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for PlaceVia {
impl GetObstacles for PlaceViaCommandStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}

View File

@ -2,7 +2,7 @@ use crate::{
board::mesadata::AccessMesadata,
drawing::graph::PrimitiveIndex,
geometry::primitive::PrimitiveShape,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
};
use super::{
@ -12,12 +12,12 @@ use super::{
};
#[derive(Debug)]
pub struct RemoveBands {
pub struct RemoveBandsCommandStepper {
selection: BandSelection,
done: bool,
}
impl RemoveBands {
impl RemoveBandsCommandStepper {
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
Ok(Self {
selection: selection.clone(),
@ -47,25 +47,25 @@ impl RemoveBands {
}
}
impl GetMaybeNavmesh for RemoveBands {
impl GetMaybeNavmesh for RemoveBandsCommandStepper {
fn maybe_navmesh(&self) -> Option<&Navmesh> {
None
}
}
impl GetMaybeTrace for RemoveBands {
fn maybe_trace(&self) -> Option<&Trace> {
impl GetMaybeTrace for RemoveBandsCommandStepper {
fn maybe_trace(&self) -> Option<&TraceStepper> {
None
}
}
impl GetGhosts for RemoveBands {
impl GetGhosts for RemoveBandsCommandStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for RemoveBands {
impl GetObstacles for RemoveBandsCommandStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}

View File

@ -1,7 +1,7 @@
use thiserror::Error;
use topola::{
autorouter::{
execute::Execute,
command::CommandStepper,
invoker::{
GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError,
InvokerStatus,
@ -10,7 +10,7 @@ use topola::{
board::mesadata::AccessMesadata,
drawing::graph::PrimitiveIndex,
geometry::primitive::PrimitiveShape,
router::{navmesh::Navmesh, trace::Trace},
router::{navmesh::Navmesh, trace::TraceStepper},
specctra::mesadata::SpecctraMesadata,
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)
Execute(Execute),
Command(CommandStepper),
}
impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for Activity {
impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for ActivityStepper {
fn step(
&mut self,
invoker: &mut Invoker<SpecctraMesadata>,
) -> Result<ActivityStatus, ActivityError> {
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.
fn maybe_navmesh(&self) -> Option<&Navmesh> {
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.
fn maybe_trace(&self) -> Option<&Trace> {
fn maybe_trace(&self) -> Option<&TraceStepper> {
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.
fn ghosts(&self) -> &[PrimitiveShape] {
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.
fn obstacles(&self) -> &[PrimitiveIndex] {
match self {
Activity::Execute(execute) => execute.obstacles(),
ActivityStepper::Command(execute) => execute.obstacles(),
}
}
}
pub struct ActivityWithStatus {
activity: Activity,
activity: ActivityStepper,
maybe_status: Option<ActivityStatus>,
}
impl ActivityWithStatus {
pub fn new_execute(execute: Execute) -> ActivityWithStatus {
pub fn new_execute(execute: CommandStepper) -> ActivityWithStatus {
Self {
activity: Activity::Execute(execute),
activity: ActivityStepper::Command(execute),
maybe_status: None,
}
}
@ -132,7 +132,7 @@ impl GetMaybeNavmesh for ActivityWithStatus {
}
impl GetMaybeTrace for ActivityWithStatus {
fn maybe_trace(&self) -> Option<&Trace> {
fn maybe_trace(&self) -> Option<&TraceStepper> {
self.activity.maybe_trace()
}
}

View File

@ -31,7 +31,7 @@ use topola::{
router::{
draw::DrawException,
navmesh::{BinavvertexNodeIndex, Navmesh},
trace::Trace,
trace::TraceStepper,
tracer::Tracer,
},
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},

View File

@ -6,7 +6,7 @@ use std::{
use topola::{
autorouter::{
execute::Command,
command::Command,
invoker::{Invoker, InvokerError, InvokerStatus},
AutorouterOptions,
},

View File

@ -6,7 +6,7 @@ use petgraph::{
use rstar::{Envelope, AABB};
use topola::{
autorouter::{
execute::Command,
command::Command,
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker},
},
board::mesadata::AccessMesadata,

View File

@ -1,7 +1,7 @@
use clap::Parser;
use std::fs::File;
use std::io::BufReader;
use topola::autorouter::execute::Command;
use topola::autorouter::command::Command;
use topola::autorouter::history::History;
use topola::autorouter::invoker::Invoker;
use topola::autorouter::selection::PinSelection;

View File

@ -6,21 +6,21 @@ use crate::{
router::{
astar::{Astar, AstarStatus},
navmesh::Navmesh,
trace::Trace,
trace::TraceStepper,
tracer::Tracer,
Router, RouterAstarStrategy, RouterError, RouterStatus,
},
step::Step,
};
pub struct Route {
pub struct RouteStepper {
astar: Astar<Navmesh, f64>,
trace: Trace,
trace: TraceStepper,
ghosts: Vec<PrimitiveShape>,
obstacles: Vec<PrimitiveIndex>,
}
impl Route {
impl RouteStepper {
pub fn new(
router: &mut Router<impl AccessRules>,
from: FixedDotIndex,
@ -60,7 +60,7 @@ impl Route {
&self.astar.graph
}
pub fn trace(&self) -> &Trace {
pub fn trace(&self) -> &TraceStepper {
&self.trace
}
@ -74,7 +74,7 @@ impl Route {
}
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> {
let tracer = Tracer::new(router.layout_mut());

View File

@ -26,8 +26,8 @@ use super::{
astar::{AstarError, AstarStrategy, PathTracker},
draw::DrawException,
navmesh::{Navmesh, NavmeshEdgeReference, NavmeshError, NavvertexIndex},
route::Route,
trace::{Trace, TraceStepContext},
route::RouteStepper,
trace::{TraceStepContext, TraceStepper},
tracer::{Tracer, TracerException},
};
@ -63,14 +63,14 @@ impl TryInto<BandTermsegIndex> for RouterStatus {
#[derive(Debug)]
pub struct RouterAstarStrategy<'a, R: AccessRules> {
pub tracer: Tracer<'a, R>,
pub trace: &'a mut Trace,
pub trace: &'a mut TraceStepper,
pub target: FixedDotIndex,
pub probe_ghosts: Vec<PrimitiveShape>,
pub probe_obstacles: Vec<PrimitiveIndex>,
}
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 {
tracer,
trace,
@ -200,8 +200,8 @@ impl<'a, R: AccessRules> Router<'a, R> {
from: FixedDotIndex,
to: FixedDotIndex,
width: f64,
) -> Result<Route, RouterError> {
Route::new(self, from, to, width)
) -> Result<RouteStepper, RouterError> {
RouteStepper::new(self, from, to, width)
}
pub fn layout_mut(&mut self) -> &mut Layout<R> {

View File

@ -20,14 +20,18 @@ use super::{
};
#[derive(Debug)]
pub struct Trace {
pub struct TraceStepper {
pub path: Vec<NavvertexIndex>,
pub head: Head,
pub width: f64,
}
impl Trace {
pub fn new(source: FixedDotIndex, source_navvertex: NavvertexIndex, width: f64) -> Trace {
impl TraceStepper {
pub fn new(
source: FixedDotIndex,
source_navvertex: NavvertexIndex,
width: f64,
) -> TraceStepper {
Self {
path: vec![source_navvertex],
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, ()>
for Trace
for TraceStepper
{
#[debug_ensures(ret.is_ok() -> matches!(self.head, Head::Cane(..)))]
#[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))]
fn step_back(&mut self, tracer: &mut Tracer<'a, R>) -> Result<TracerStatus, TracerException> {
if let Head::Cane(head) = self.head {

View File

@ -10,7 +10,7 @@ use crate::{
use super::{
draw::{Draw, DrawException},
navmesh::{Navmesh, NavvertexIndex},
trace::{Trace, TraceStepContext},
trace::{TraceStepContext, TraceStepper},
};
#[derive(Error, Debug, Clone, Copy)]
@ -51,14 +51,14 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
source: FixedDotIndex,
source_navvertex: NavvertexIndex,
width: f64,
) -> Trace {
Trace::new(source, source_navvertex, width)
) -> TraceStepper {
TraceStepper::new(source, source_navvertex, width)
}
pub fn finish(
&mut self,
_navmesh: &Navmesh,
trace: &mut Trace,
trace: &mut TraceStepper,
target: FixedDotIndex,
width: f64,
) -> Result<BandTermsegIndex, TracerException> {
@ -70,7 +70,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
pub fn rework_path(
&mut self,
navmesh: &Navmesh,
trace: &mut Trace,
trace: &mut TraceStepper,
path: &[NavvertexIndex],
width: f64,
) -> Result<(), TracerException> {
@ -90,7 +90,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
pub fn path(
&mut self,
navmesh: &Navmesh,
trace: &mut Trace,
trace: &mut TraceStepper,
path: &[NavvertexIndex],
width: f64,
) -> Result<(), TracerException> {
@ -110,7 +110,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
}
#[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 {
let _ = trace.step_back(self);
}

View File

@ -1,5 +1,5 @@
use topola::{
autorouter::{execute::Command, invoker::InvokerError, AutorouterError},
autorouter::{command::Command, invoker::InvokerError, AutorouterError},
board::mesadata::AccessMesadata,
layout::via::ViaWeight,
math::Circle,

View File

@ -1,6 +1,6 @@
use topola::{
autorouter::{
execute::Command,
command::Command,
invoker::{Invoker, InvokerError},
AutorouterError,
},