mirror of https://codeberg.org/topola/topola.git
drawing: rename "segbends" to "canes"
In addition to a seg and a bend, a segbend actually also contains a dot, so let's rename it to "cane", which is also easier to translate.
This commit is contained in:
parent
a7b4a84b98
commit
d193ea6565
|
|
@ -10,13 +10,13 @@ use crate::drawing::{
|
|||
use super::rules::RulesTrait;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Segbend {
|
||||
pub struct Cane {
|
||||
pub seg: SeqLooseSegIndex,
|
||||
pub dot: LooseDotIndex,
|
||||
pub bend: LooseBendIndex,
|
||||
}
|
||||
|
||||
impl Segbend {
|
||||
impl Cane {
|
||||
pub fn from_dot(dot: LooseDotIndex, drawing: &Drawing<impl Copy, impl RulesTrait>) -> Self {
|
||||
let bend = LooseDot::new(dot, drawing).bend();
|
||||
let dot = LooseBend::new(bend, drawing).other_joint(dot);
|
||||
|
|
@ -25,13 +25,13 @@ impl Segbend {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetInterior<PrimitiveIndex> for Segbend {
|
||||
impl GetInterior<PrimitiveIndex> for Cane {
|
||||
fn interior(&self) -> Vec<PrimitiveIndex> {
|
||||
vec![self.bend.into(), self.dot.into(), self.seg.into()]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetJoints<SeqLooseSegIndex, LooseBendIndex> for Segbend {
|
||||
impl GetJoints<SeqLooseSegIndex, LooseBendIndex> for Cane {
|
||||
fn joints(&self) -> (SeqLooseSegIndex, LooseBendIndex) {
|
||||
(self.seg, self.bend)
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ use thiserror::Error;
|
|||
use crate::drawing::{
|
||||
band::BandIndex,
|
||||
bend::{BendIndex, BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
||||
cane::Cane,
|
||||
collect::Collect,
|
||||
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
|
|
@ -22,7 +23,6 @@ use crate::drawing::{
|
|||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight,
|
||||
SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
},
|
||||
segbend::Segbend,
|
||||
wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex},
|
||||
};
|
||||
use crate::geometry::{
|
||||
|
|
@ -409,7 +409,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().edge_count() >= old(self.geometry_with_rtree.graph().edge_count() + 5))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
|
||||
pub fn insert_segbend(
|
||||
pub fn insert_cane(
|
||||
&mut self,
|
||||
from: DotIndex,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -417,11 +417,11 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
) -> Result<Cane, LayoutException> {
|
||||
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
||||
let infringables = self.collect().wraparounded_bows(around);
|
||||
|
||||
let segbend = self.add_segbend_with_infringables(
|
||||
let cane = self.add_cane_with_infringables(
|
||||
from,
|
||||
around,
|
||||
dot_weight,
|
||||
|
|
@ -432,25 +432,25 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
)?;
|
||||
|
||||
if let Some(wraparound) = maybe_wraparound {
|
||||
self.reattach_bend(wraparound, Some(segbend.bend));
|
||||
self.reattach_bend(wraparound, Some(cane.bend));
|
||||
}
|
||||
|
||||
if let Some(outer) = self.primitive(segbend.bend).outer() {
|
||||
if let Some(outer) = self.primitive(cane.bend).outer() {
|
||||
self.update_this_and_outward_bows(outer).map_err(|err| {
|
||||
let joint = self.primitive(segbend.bend).other_joint(segbend.dot);
|
||||
self.remove_segbend(&segbend, joint.into());
|
||||
let joint = self.primitive(cane.bend).other_joint(cane.dot);
|
||||
self.remove_cane(&cane, joint.into());
|
||||
err
|
||||
})?;
|
||||
}
|
||||
|
||||
// Segs must not cross.
|
||||
if let Some(collision) = self.detect_collision(segbend.seg.into()) {
|
||||
let joint = self.primitive(segbend.bend).other_joint(segbend.dot);
|
||||
self.remove_segbend(&segbend, joint.into());
|
||||
if let Some(collision) = self.detect_collision(cane.seg.into()) {
|
||||
let joint = self.primitive(cane.bend).other_joint(cane.dot);
|
||||
self.remove_cane(&cane, joint.into());
|
||||
return Err(collision.into());
|
||||
}
|
||||
|
||||
Ok::<Segbend, LayoutException>(segbend)
|
||||
Ok::<Cane, LayoutException>(cane)
|
||||
}
|
||||
|
||||
#[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
|
||||
|
|
@ -563,7 +563,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().edge_count() >= old(self.geometry_with_rtree.graph().edge_count() + 5))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
|
||||
pub fn add_segbend(
|
||||
pub fn add_cane(
|
||||
&mut self,
|
||||
from: DotIndex,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -571,8 +571,8 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
self.add_segbend_with_infringables(
|
||||
) -> Result<Cane, LayoutException> {
|
||||
self.add_cane_with_infringables(
|
||||
from,
|
||||
around,
|
||||
dot_weight,
|
||||
|
|
@ -587,7 +587,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().edge_count() >= old(self.geometry_with_rtree.graph().edge_count() + 5))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
|
||||
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
|
||||
fn add_segbend_with_infringables(
|
||||
fn add_cane_with_infringables(
|
||||
&mut self,
|
||||
from: DotIndex,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -596,7 +596,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
infringables: Option<&[PrimitiveIndex]>,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
) -> Result<Cane, LayoutException> {
|
||||
let seg_to = self.add_dot_with_infringables(dot_weight, infringables)?;
|
||||
let seg = self
|
||||
.add_seg_with_infringables(from, seg_to.into(), seg_weight, infringables)
|
||||
|
|
@ -624,7 +624,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
err
|
||||
})?;
|
||||
|
||||
Ok::<Segbend, LayoutException>(Segbend {
|
||||
Ok::<Cane, LayoutException>(Cane {
|
||||
seg,
|
||||
dot: seg_to,
|
||||
bend,
|
||||
|
|
@ -632,30 +632,30 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
|||
}
|
||||
|
||||
#[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() - 4))]
|
||||
pub fn remove_segbend(&mut self, segbend: &Segbend, face: LooseDotIndex) {
|
||||
let maybe_outer = self.primitive(segbend.bend).outer();
|
||||
pub fn remove_cane(&mut self, cane: &Cane, face: LooseDotIndex) {
|
||||
let maybe_outer = self.primitive(cane.bend).outer();
|
||||
|
||||
// Removing a loose bend affects its outer bends.
|
||||
if let Some(outer) = maybe_outer {
|
||||
self.reattach_bend(outer, self.primitive(segbend.bend).inner());
|
||||
self.reattach_bend(outer, self.primitive(cane.bend).inner());
|
||||
}
|
||||
|
||||
self.geometry_with_rtree.remove_bend(segbend.bend.into());
|
||||
self.geometry_with_rtree.remove_seg(segbend.seg.into());
|
||||
self.geometry_with_rtree.remove_bend(cane.bend.into());
|
||||
self.geometry_with_rtree.remove_seg(cane.seg.into());
|
||||
|
||||
// We must remove the dots only after the segs and bends because we need dots to calculate
|
||||
// the shapes, which we first need unchanged to remove the segs and bends from the R-tree.
|
||||
|
||||
self.geometry_with_rtree.remove_dot(face.into());
|
||||
self.geometry_with_rtree.remove_dot(segbend.dot.into());
|
||||
self.geometry_with_rtree.remove_dot(cane.dot.into());
|
||||
|
||||
if let Some(outer) = maybe_outer {
|
||||
self.update_this_and_outward_bows(outer).unwrap(); // Must never fail.
|
||||
}
|
||||
}
|
||||
|
||||
pub fn segbend(&self, dot: LooseDotIndex) -> Segbend {
|
||||
Segbend::from_dot(dot, self)
|
||||
pub fn cane(&self, dot: LooseDotIndex) -> Cane {
|
||||
Cane::from_dot(dot, self)
|
||||
}
|
||||
|
||||
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
cane::Cane,
|
||||
graph::PrimitiveIndex,
|
||||
primitive::GetJoints,
|
||||
rules::{Conditions, RulesTrait},
|
||||
segbend::Segbend,
|
||||
};
|
||||
|
||||
#[enum_dispatch]
|
||||
|
|
@ -33,7 +33,7 @@ pub trait HeadTrait {
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Head {
|
||||
Bare(BareHead),
|
||||
Segbend(SegbendHead),
|
||||
Cane(CaneHead),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -48,12 +48,12 @@ impl HeadTrait for BareHead {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct SegbendHead {
|
||||
pub struct CaneHead {
|
||||
pub face: LooseDotIndex,
|
||||
pub segbend: Segbend,
|
||||
pub cane: Cane,
|
||||
}
|
||||
|
||||
impl HeadTrait for SegbendHead {
|
||||
impl HeadTrait for CaneHead {
|
||||
fn face(&self) -> DotIndex {
|
||||
self.face.into()
|
||||
}
|
||||
|
|
@ -157,8 +157,8 @@ impl<'a, CW: Copy, R: RulesTrait> Guide<'a, CW, R> {
|
|||
}
|
||||
|
||||
pub fn head_cw(&self, head: &Head) -> Option<bool> {
|
||||
if let Head::Segbend(head) = head {
|
||||
let joints = self.drawing.primitive(head.segbend.bend).joints();
|
||||
if let Head::Cane(head) = head {
|
||||
let joints = self.drawing.primitive(head.cane.bend).joints();
|
||||
|
||||
if head.face() == joints.0.into() {
|
||||
Some(false)
|
||||
|
|
@ -176,12 +176,12 @@ impl<'a, CW: Copy, R: RulesTrait> Guide<'a, CW, R> {
|
|||
pos: head.face().primitive(self.drawing).shape().center(), // TODO.
|
||||
r: 0.0,
|
||||
},
|
||||
Head::Segbend(head) => {
|
||||
if let Some(inner) = self.drawing.primitive(head.segbend.bend).inner() {
|
||||
Head::Cane(head) => {
|
||||
if let Some(inner) = self.drawing.primitive(head.cane.bend).inner() {
|
||||
self.bend_circle(inner.into(), width, &self.conditions(head.face().into()))
|
||||
} else {
|
||||
self.dot_circle(
|
||||
self.drawing.primitive(head.segbend.bend).core().into(),
|
||||
self.drawing.primitive(head.cane.bend).core().into(),
|
||||
width,
|
||||
&self.conditions(head.face().into()),
|
||||
)
|
||||
|
|
@ -220,28 +220,28 @@ impl<'a, CW: Copy, R: RulesTrait> Guide<'a, CW, R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn segbend_head(&self, dot: LooseDotIndex) -> SegbendHead {
|
||||
SegbendHead {
|
||||
pub fn cane_head(&self, dot: LooseDotIndex) -> CaneHead {
|
||||
CaneHead {
|
||||
face: dot,
|
||||
segbend: self.drawing.segbend(dot),
|
||||
cane: self.drawing.cane(dot),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rear_head(&self, dot: LooseDotIndex) -> Head {
|
||||
self.head(self.rear(self.segbend_head(dot)))
|
||||
self.head(self.rear(self.cane_head(dot)))
|
||||
}
|
||||
|
||||
pub fn head(&self, dot: DotIndex) -> Head {
|
||||
match dot {
|
||||
DotIndex::Fixed(fixed) => BareHead { dot: fixed }.into(),
|
||||
DotIndex::Loose(loose) => self.segbend_head(loose).into(),
|
||||
DotIndex::Loose(loose) => self.cane_head(loose).into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rear(&self, head: SegbendHead) -> DotIndex {
|
||||
fn rear(&self, head: CaneHead) -> DotIndex {
|
||||
self.drawing
|
||||
.primitive(head.segbend.seg)
|
||||
.other_joint(head.segbend.dot.into())
|
||||
.primitive(head.cane.seg)
|
||||
.other_joint(head.cane.dot.into())
|
||||
}
|
||||
|
||||
fn conditions(&self, node: PrimitiveIndex) -> Conditions {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
pub mod graph;
|
||||
pub mod band;
|
||||
pub mod bend;
|
||||
pub mod cane;
|
||||
pub mod collect;
|
||||
pub mod dot;
|
||||
mod drawing;
|
||||
|
|
@ -10,7 +11,6 @@ pub mod loose;
|
|||
pub mod primitive;
|
||||
pub mod rules;
|
||||
pub mod seg;
|
||||
pub mod segbend;
|
||||
pub mod wraparoundable;
|
||||
|
||||
pub use drawing::*;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandIndex,
|
||||
bend::LooseBendWeight,
|
||||
cane::Cane,
|
||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
graph::{GetMaybeNet, PrimitiveIndex},
|
||||
primitive::{GetJoints, GetOtherJoint},
|
||||
|
|
@ -15,7 +16,6 @@ use crate::{
|
|||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
||||
SeqLooseSegWeight,
|
||||
},
|
||||
segbend::Segbend,
|
||||
wraparoundable::WraparoundableIndex,
|
||||
Drawing, Infringement, LayoutException,
|
||||
},
|
||||
|
|
@ -50,11 +50,11 @@ impl<R: RulesTrait> Layout<R> {
|
|||
self.drawing.remove_band(band);
|
||||
}
|
||||
|
||||
pub fn remove_segbend(&mut self, segbend: &Segbend, face: LooseDotIndex) {
|
||||
self.drawing.remove_segbend(segbend, face)
|
||||
pub fn remove_cane(&mut self, cane: &Cane, face: LooseDotIndex) {
|
||||
self.drawing.remove_cane(cane, face)
|
||||
}
|
||||
|
||||
pub fn insert_segbend(
|
||||
pub fn insert_cane(
|
||||
&mut self,
|
||||
from: DotIndex,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -62,9 +62,9 @@ impl<R: RulesTrait> Layout<R> {
|
|||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
) -> Result<Cane, LayoutException> {
|
||||
self.drawing
|
||||
.insert_segbend(from, around, dot_weight, seg_weight, bend_weight, cw)
|
||||
.insert_cane(from, around, dot_weight, seg_weight, bend_weight, cw)
|
||||
}
|
||||
|
||||
#[debug_ensures(ret.is_ok() -> self.drawing.node_count() == old(self.drawing.node_count()) + weight.to_layer - weight.from_layer)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
bend::{BendIndex, LooseBendWeight},
|
||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||
graph::{GetLayer, GetMaybeNet, MakePrimitive},
|
||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||
guide::{CaneHead, Guide, Head, HeadTrait},
|
||||
primitive::GetOtherJoint,
|
||||
rules::RulesTrait,
|
||||
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||
|
|
@ -41,7 +41,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
}
|
||||
|
||||
pub fn start(&mut self, from: LooseDotIndex) -> Head {
|
||||
self.guide().segbend_head(from).into()
|
||||
self.guide().cane_head(from).into()
|
||||
}
|
||||
|
||||
#[debug_ensures(ret.is_ok() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() + 1))]
|
||||
|
|
@ -94,12 +94,12 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
|
||||
#[debug_ensures(ret.is_ok() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() + 4))]
|
||||
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
pub fn segbend_around_dot(
|
||||
pub fn cane_around_dot(
|
||||
&mut self,
|
||||
head: Head,
|
||||
around: FixedDotIndex,
|
||||
width: f64,
|
||||
) -> Result<SegbendHead, DrawException> {
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
let mut tangents = self
|
||||
.guide()
|
||||
.head_around_dot_segments(&head, around.into(), width)?;
|
||||
|
|
@ -116,7 +116,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
let mut errs = vec![];
|
||||
|
||||
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
||||
match self.segbend_around(
|
||||
match self.cane_around(
|
||||
head,
|
||||
around.into(),
|
||||
tangent.start_point(),
|
||||
|
|
@ -139,12 +139,12 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
|
||||
#[debug_ensures(ret.is_ok() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() + 4))]
|
||||
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
pub fn segbend_around_bend(
|
||||
pub fn cane_around_bend(
|
||||
&mut self,
|
||||
head: Head,
|
||||
around: BendIndex,
|
||||
width: f64,
|
||||
) -> Result<SegbendHead, DrawException> {
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
let mut tangents = self
|
||||
.guide()
|
||||
.head_around_bend_segments(&head, around.into(), width)?;
|
||||
|
|
@ -161,7 +161,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
let mut errs = vec![];
|
||||
|
||||
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
||||
match self.segbend_around(
|
||||
match self.cane_around(
|
||||
head,
|
||||
around.into(),
|
||||
tangent.start_point(),
|
||||
|
|
@ -184,7 +184,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
|
||||
#[debug_ensures(ret.is_ok() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() + 4))]
|
||||
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
fn segbend_around(
|
||||
fn cane_around(
|
||||
&mut self,
|
||||
head: Head,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -193,16 +193,16 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
cw: bool,
|
||||
width: f64,
|
||||
offset: f64,
|
||||
) -> Result<SegbendHead, LayoutException> {
|
||||
) -> Result<CaneHead, LayoutException> {
|
||||
let head = self.extend_head(head, from)?;
|
||||
self.segbend(head, around, to, cw, width, offset)
|
||||
self.cane(head, around, to, cw, width, offset)
|
||||
}
|
||||
|
||||
#[debug_ensures(self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
fn extend_head(&mut self, head: Head, to: Point) -> Result<Head, Infringement> {
|
||||
if let Head::Segbend(head) = head {
|
||||
if let Head::Cane(head) = head {
|
||||
self.layout.move_dot(head.face.into(), to)?;
|
||||
Ok(Head::Segbend(head))
|
||||
Ok(Head::Cane(head))
|
||||
} else {
|
||||
Ok(head)
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
|
||||
#[debug_ensures(ret.is_ok() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() + 4))]
|
||||
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
fn segbend(
|
||||
fn cane(
|
||||
&mut self,
|
||||
head: Head,
|
||||
around: WraparoundableIndex,
|
||||
|
|
@ -218,10 +218,10 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
cw: bool,
|
||||
width: f64,
|
||||
offset: f64,
|
||||
) -> Result<SegbendHead, LayoutException> {
|
||||
) -> Result<CaneHead, LayoutException> {
|
||||
let layer = head.face().primitive(self.layout.drawing()).layer();
|
||||
let maybe_net = head.face().primitive(self.layout.drawing()).maybe_net();
|
||||
let segbend = self.layout.insert_segbend(
|
||||
let cane = self.layout.insert_cane(
|
||||
head.face(),
|
||||
around,
|
||||
LooseDotWeight {
|
||||
|
|
@ -245,26 +245,26 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
},
|
||||
cw,
|
||||
)?;
|
||||
Ok::<SegbendHead, LayoutException>(SegbendHead {
|
||||
Ok::<CaneHead, LayoutException>(CaneHead {
|
||||
face: self
|
||||
.layout
|
||||
.drawing()
|
||||
.primitive(segbend.bend)
|
||||
.other_joint(segbend.dot),
|
||||
segbend,
|
||||
.primitive(cane.bend)
|
||||
.other_joint(cane.dot),
|
||||
cane,
|
||||
})
|
||||
}
|
||||
|
||||
#[debug_ensures(ret.is_some() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() - 4))]
|
||||
#[debug_ensures(ret.is_none() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||
pub fn undo_segbend(&mut self, head: SegbendHead) -> Option<Head> {
|
||||
pub fn undo_cane(&mut self, head: CaneHead) -> Option<Head> {
|
||||
let prev_dot = self
|
||||
.layout
|
||||
.drawing()
|
||||
.primitive(head.segbend.seg)
|
||||
.other_joint(head.segbend.dot.into());
|
||||
.primitive(head.cane.seg)
|
||||
.other_joint(head.cane.dot.into());
|
||||
|
||||
self.layout.remove_segbend(&head.segbend, head.face);
|
||||
self.layout.remove_cane(&head.cane, head.face);
|
||||
Some(self.guide().head(prev_dot))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
band::BandIndex,
|
||||
bend::LooseBendIndex,
|
||||
dot::FixedDotIndex,
|
||||
guide::{BareHead, Head, SegbendHead},
|
||||
guide::{BareHead, CaneHead, Head},
|
||||
rules::RulesTrait,
|
||||
},
|
||||
layout::Layout,
|
||||
|
|
@ -111,7 +111,7 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
|||
head: Head,
|
||||
around: NavvertexIndex,
|
||||
width: f64,
|
||||
) -> Result<SegbendHead, DrawException> {
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
match around {
|
||||
NavvertexIndex::FixedDot(dot) => self.wrap_around_fixed_dot(head, dot, width),
|
||||
NavvertexIndex::FixedBend(_fixed_bend) => todo!(),
|
||||
|
|
@ -126,8 +126,8 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
|||
head: Head,
|
||||
around: FixedDotIndex,
|
||||
width: f64,
|
||||
) -> Result<SegbendHead, DrawException> {
|
||||
let head = Draw::new(self.layout).segbend_around_dot(head, around.into(), width)?;
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
let head = Draw::new(self.layout).cane_around_dot(head, around.into(), width)?;
|
||||
Ok(head)
|
||||
}
|
||||
|
||||
|
|
@ -136,16 +136,16 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
|||
head: Head,
|
||||
around: LooseBendIndex,
|
||||
width: f64,
|
||||
) -> Result<SegbendHead, DrawException> {
|
||||
let head = Draw::new(self.layout).segbend_around_bend(head, around.into(), width)?;
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
let head = Draw::new(self.layout).cane_around_bend(head, around.into(), width)?;
|
||||
|
||||
Ok(head)
|
||||
}
|
||||
|
||||
#[debug_ensures(trace.path.len() == old(trace.path.len() - 1))]
|
||||
pub fn undo_step(&mut self, trace: &mut Trace) {
|
||||
if let Head::Segbend(head) = trace.head {
|
||||
trace.head = Draw::new(self.layout).undo_segbend(head).unwrap();
|
||||
if let Head::Cane(head) = trace.head {
|
||||
trace.head = Draw::new(self.layout).undo_cane(head).unwrap();
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ use crate::{
|
|||
layout::{zone::SolidZoneWeight, Layout},
|
||||
math::Circle,
|
||||
specctra::{
|
||||
read::{self, ListTokenizer},
|
||||
mesadata::SpecctraMesadata,
|
||||
structure::{self, Layer, Pcb, Shape, DsnFile},
|
||||
read::{self, ListTokenizer},
|
||||
structure::{self, DsnFile, Layer, Pcb, Shape},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -35,9 +35,7 @@ impl SpecctraDesign {
|
|||
let mut list_reader = read::ListTokenizer::new(reader);
|
||||
let dsn = list_reader.read_value::<DsnFile>()?;
|
||||
|
||||
Ok(Self {
|
||||
pcb: dsn.pcb,
|
||||
})
|
||||
Ok(Self { pcb: dsn.pcb })
|
||||
|
||||
//use super::structure::*;
|
||||
|
||||
|
|
@ -111,9 +109,7 @@ impl SpecctraDesign {
|
|||
let mut list_reader = ListTokenizer::new(contents.as_bytes());
|
||||
let dsn = list_reader.read_value::<DsnFile>()?;
|
||||
|
||||
Ok(Self {
|
||||
pcb: dsn.pcb,
|
||||
})
|
||||
Ok(Self { pcb: dsn.pcb })
|
||||
}
|
||||
|
||||
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
||||
|
|
@ -601,14 +597,7 @@ impl SpecctraDesign {
|
|||
|
||||
// iterate through path coords starting from the second
|
||||
for coord in coords.iter().skip(1) {
|
||||
let pos = Self::pos(
|
||||
place_pos,
|
||||
place_rot,
|
||||
pin_pos,
|
||||
pin_rot,
|
||||
coord.x,
|
||||
coord.y,
|
||||
);
|
||||
let pos = Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y);
|
||||
|
||||
if pos == prev_pos {
|
||||
continue;
|
||||
|
|
@ -691,14 +680,7 @@ impl SpecctraDesign {
|
|||
let index = board.add_zone_fixed_dot_infringably(
|
||||
FixedDotWeight {
|
||||
circle: Circle {
|
||||
pos: Self::pos(
|
||||
place_pos,
|
||||
place_rot,
|
||||
pin_pos,
|
||||
pin_rot,
|
||||
coord.x,
|
||||
coord.y,
|
||||
)
|
||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y)
|
||||
.into(),
|
||||
r: width / 2.0,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue