// SPDX-FileCopyrightText: 2024 Topola contributors // // SPDX-License-Identifier: MIT use std::ops::ControlFlow; use geo::Point; use crate::{ board::{edit::BoardEdit, AccessMesadata}, drawing::{ band::BandTermsegIndex, dot::{FixedDotIndex, FixedDotWeight, GeneralDotWeight}, }, layout::LayoutEdit, math::Circle, router::{RouteStepper, Router}, stepper::Step, }; use super::{Autorouter, AutorouterError, AutorouterOptions}; pub struct PointrouteExecutionStepper { route: RouteStepper, options: AutorouterOptions, } impl PointrouteExecutionStepper { pub fn new( autorouter: &mut Autorouter, origin: FixedDotIndex, point: Point, options: AutorouterOptions, ) -> Result { let destination = autorouter.board.add_fixed_dot_infringably( &mut BoardEdit::new(), // TODO? FixedDotWeight(GeneralDotWeight { circle: Circle { pos: point, r: options.router_options.routed_band_width / 2.0, }, layer: 0, maybe_net: None, }), None, ); let mut router = Router::new(autorouter.board.layout_mut(), options.router_options); Ok(Self { route: router.route( LayoutEdit::new(), // TODO? origin, destination, options.router_options.routed_band_width, )?, options, }) } } impl Step, BandTermsegIndex> for PointrouteExecutionStepper { type Error = AutorouterError; fn step( &mut self, autorouter: &mut Autorouter, ) -> Result, AutorouterError> { let mut router = Router::new(autorouter.board.layout_mut(), self.options.router_options); Ok(self.route.step(&mut router)?) } }