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;
|
use super::rules::RulesTrait;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Segbend {
|
pub struct Cane {
|
||||||
pub seg: SeqLooseSegIndex,
|
pub seg: SeqLooseSegIndex,
|
||||||
pub dot: LooseDotIndex,
|
pub dot: LooseDotIndex,
|
||||||
pub bend: LooseBendIndex,
|
pub bend: LooseBendIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Segbend {
|
impl Cane {
|
||||||
pub fn from_dot(dot: LooseDotIndex, drawing: &Drawing<impl Copy, impl RulesTrait>) -> Self {
|
pub fn from_dot(dot: LooseDotIndex, drawing: &Drawing<impl Copy, impl RulesTrait>) -> Self {
|
||||||
let bend = LooseDot::new(dot, drawing).bend();
|
let bend = LooseDot::new(dot, drawing).bend();
|
||||||
let dot = LooseBend::new(bend, drawing).other_joint(dot);
|
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> {
|
fn interior(&self) -> Vec<PrimitiveIndex> {
|
||||||
vec![self.bend.into(), self.dot.into(), self.seg.into()]
|
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) {
|
fn joints(&self) -> (SeqLooseSegIndex, LooseBendIndex) {
|
||||||
(self.seg, self.bend)
|
(self.seg, self.bend)
|
||||||
}
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ use thiserror::Error;
|
||||||
use crate::drawing::{
|
use crate::drawing::{
|
||||||
band::BandIndex,
|
band::BandIndex,
|
||||||
bend::{BendIndex, BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
bend::{BendIndex, BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
||||||
|
cane::Cane,
|
||||||
collect::Collect,
|
collect::Collect,
|
||||||
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||||
|
|
@ -22,7 +23,6 @@ use crate::drawing::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight,
|
||||||
SeqLooseSegIndex, SeqLooseSegWeight,
|
SeqLooseSegIndex, SeqLooseSegWeight,
|
||||||
},
|
},
|
||||||
segbend::Segbend,
|
|
||||||
wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex},
|
wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex},
|
||||||
};
|
};
|
||||||
use crate::geometry::{
|
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_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().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()))]
|
#[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,
|
&mut self,
|
||||||
from: DotIndex,
|
from: DotIndex,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -417,11 +417,11 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
||||||
seg_weight: SeqLooseSegWeight,
|
seg_weight: SeqLooseSegWeight,
|
||||||
bend_weight: LooseBendWeight,
|
bend_weight: LooseBendWeight,
|
||||||
cw: bool,
|
cw: bool,
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Cane, LayoutException> {
|
||||||
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
||||||
let infringables = self.collect().wraparounded_bows(around);
|
let infringables = self.collect().wraparounded_bows(around);
|
||||||
|
|
||||||
let segbend = self.add_segbend_with_infringables(
|
let cane = self.add_cane_with_infringables(
|
||||||
from,
|
from,
|
||||||
around,
|
around,
|
||||||
dot_weight,
|
dot_weight,
|
||||||
|
|
@ -432,25 +432,25 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if let Some(wraparound) = maybe_wraparound {
|
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| {
|
self.update_this_and_outward_bows(outer).map_err(|err| {
|
||||||
let joint = self.primitive(segbend.bend).other_joint(segbend.dot);
|
let joint = self.primitive(cane.bend).other_joint(cane.dot);
|
||||||
self.remove_segbend(&segbend, joint.into());
|
self.remove_cane(&cane, joint.into());
|
||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Segs must not cross.
|
// Segs must not cross.
|
||||||
if let Some(collision) = self.detect_collision(segbend.seg.into()) {
|
if let Some(collision) = self.detect_collision(cane.seg.into()) {
|
||||||
let joint = self.primitive(segbend.bend).other_joint(segbend.dot);
|
let joint = self.primitive(cane.bend).other_joint(cane.dot);
|
||||||
self.remove_segbend(&segbend, joint.into());
|
self.remove_cane(&cane, joint.into());
|
||||||
return Err(collision.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()))]
|
#[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_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().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()))]
|
#[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,
|
&mut self,
|
||||||
from: DotIndex,
|
from: DotIndex,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -571,8 +571,8 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
||||||
seg_weight: SeqLooseSegWeight,
|
seg_weight: SeqLooseSegWeight,
|
||||||
bend_weight: LooseBendWeight,
|
bend_weight: LooseBendWeight,
|
||||||
cw: bool,
|
cw: bool,
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Cane, LayoutException> {
|
||||||
self.add_segbend_with_infringables(
|
self.add_cane_with_infringables(
|
||||||
from,
|
from,
|
||||||
around,
|
around,
|
||||||
dot_weight,
|
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_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().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()))]
|
#[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,
|
&mut self,
|
||||||
from: DotIndex,
|
from: DotIndex,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -596,7 +596,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
||||||
bend_weight: LooseBendWeight,
|
bend_weight: LooseBendWeight,
|
||||||
cw: bool,
|
cw: bool,
|
||||||
infringables: Option<&[PrimitiveIndex]>,
|
infringables: Option<&[PrimitiveIndex]>,
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Cane, LayoutException> {
|
||||||
let seg_to = self.add_dot_with_infringables(dot_weight, infringables)?;
|
let seg_to = self.add_dot_with_infringables(dot_weight, infringables)?;
|
||||||
let seg = self
|
let seg = self
|
||||||
.add_seg_with_infringables(from, seg_to.into(), seg_weight, infringables)
|
.add_seg_with_infringables(from, seg_to.into(), seg_weight, infringables)
|
||||||
|
|
@ -624,7 +624,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
|
||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok::<Segbend, LayoutException>(Segbend {
|
Ok::<Cane, LayoutException>(Cane {
|
||||||
seg,
|
seg,
|
||||||
dot: seg_to,
|
dot: seg_to,
|
||||||
bend,
|
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))]
|
#[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) {
|
pub fn remove_cane(&mut self, cane: &Cane, face: LooseDotIndex) {
|
||||||
let maybe_outer = self.primitive(segbend.bend).outer();
|
let maybe_outer = self.primitive(cane.bend).outer();
|
||||||
|
|
||||||
// Removing a loose bend affects its outer bends.
|
// Removing a loose bend affects its outer bends.
|
||||||
if let Some(outer) = maybe_outer {
|
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_bend(cane.bend.into());
|
||||||
self.geometry_with_rtree.remove_seg(segbend.seg.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
|
// 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.
|
// 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(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 {
|
if let Some(outer) = maybe_outer {
|
||||||
self.update_this_and_outward_bows(outer).unwrap(); // Must never fail.
|
self.update_this_and_outward_bows(outer).unwrap(); // Must never fail.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn segbend(&self, dot: LooseDotIndex) -> Segbend {
|
pub fn cane(&self, dot: LooseDotIndex) -> Cane {
|
||||||
Segbend::from_dot(dot, self)
|
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()))]
|
#[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::{
|
use super::{
|
||||||
|
cane::Cane,
|
||||||
graph::PrimitiveIndex,
|
graph::PrimitiveIndex,
|
||||||
primitive::GetJoints,
|
primitive::GetJoints,
|
||||||
rules::{Conditions, RulesTrait},
|
rules::{Conditions, RulesTrait},
|
||||||
segbend::Segbend,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
|
|
@ -33,7 +33,7 @@ pub trait HeadTrait {
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Head {
|
pub enum Head {
|
||||||
Bare(BareHead),
|
Bare(BareHead),
|
||||||
Segbend(SegbendHead),
|
Cane(CaneHead),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
@ -48,12 +48,12 @@ impl HeadTrait for BareHead {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct SegbendHead {
|
pub struct CaneHead {
|
||||||
pub face: LooseDotIndex,
|
pub face: LooseDotIndex,
|
||||||
pub segbend: Segbend,
|
pub cane: Cane,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeadTrait for SegbendHead {
|
impl HeadTrait for CaneHead {
|
||||||
fn face(&self) -> DotIndex {
|
fn face(&self) -> DotIndex {
|
||||||
self.face.into()
|
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> {
|
pub fn head_cw(&self, head: &Head) -> Option<bool> {
|
||||||
if let Head::Segbend(head) = head {
|
if let Head::Cane(head) = head {
|
||||||
let joints = self.drawing.primitive(head.segbend.bend).joints();
|
let joints = self.drawing.primitive(head.cane.bend).joints();
|
||||||
|
|
||||||
if head.face() == joints.0.into() {
|
if head.face() == joints.0.into() {
|
||||||
Some(false)
|
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.
|
pos: head.face().primitive(self.drawing).shape().center(), // TODO.
|
||||||
r: 0.0,
|
r: 0.0,
|
||||||
},
|
},
|
||||||
Head::Segbend(head) => {
|
Head::Cane(head) => {
|
||||||
if let Some(inner) = self.drawing.primitive(head.segbend.bend).inner() {
|
if let Some(inner) = self.drawing.primitive(head.cane.bend).inner() {
|
||||||
self.bend_circle(inner.into(), width, &self.conditions(head.face().into()))
|
self.bend_circle(inner.into(), width, &self.conditions(head.face().into()))
|
||||||
} else {
|
} else {
|
||||||
self.dot_circle(
|
self.dot_circle(
|
||||||
self.drawing.primitive(head.segbend.bend).core().into(),
|
self.drawing.primitive(head.cane.bend).core().into(),
|
||||||
width,
|
width,
|
||||||
&self.conditions(head.face().into()),
|
&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 {
|
pub fn cane_head(&self, dot: LooseDotIndex) -> CaneHead {
|
||||||
SegbendHead {
|
CaneHead {
|
||||||
face: dot,
|
face: dot,
|
||||||
segbend: self.drawing.segbend(dot),
|
cane: self.drawing.cane(dot),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rear_head(&self, dot: LooseDotIndex) -> Head {
|
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 {
|
pub fn head(&self, dot: DotIndex) -> Head {
|
||||||
match dot {
|
match dot {
|
||||||
DotIndex::Fixed(fixed) => BareHead { dot: fixed }.into(),
|
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
|
self.drawing
|
||||||
.primitive(head.segbend.seg)
|
.primitive(head.cane.seg)
|
||||||
.other_joint(head.segbend.dot.into())
|
.other_joint(head.cane.dot.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn conditions(&self, node: PrimitiveIndex) -> Conditions {
|
fn conditions(&self, node: PrimitiveIndex) -> Conditions {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
pub mod graph;
|
pub mod graph;
|
||||||
pub mod band;
|
pub mod band;
|
||||||
pub mod bend;
|
pub mod bend;
|
||||||
|
pub mod cane;
|
||||||
pub mod collect;
|
pub mod collect;
|
||||||
pub mod dot;
|
pub mod dot;
|
||||||
mod drawing;
|
mod drawing;
|
||||||
|
|
@ -10,7 +11,6 @@ pub mod loose;
|
||||||
pub mod primitive;
|
pub mod primitive;
|
||||||
pub mod rules;
|
pub mod rules;
|
||||||
pub mod seg;
|
pub mod seg;
|
||||||
pub mod segbend;
|
|
||||||
pub mod wraparoundable;
|
pub mod wraparoundable;
|
||||||
|
|
||||||
pub use drawing::*;
|
pub use drawing::*;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use crate::{
|
||||||
drawing::{
|
drawing::{
|
||||||
band::BandIndex,
|
band::BandIndex,
|
||||||
bend::LooseBendWeight,
|
bend::LooseBendWeight,
|
||||||
|
cane::Cane,
|
||||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
graph::{GetMaybeNet, PrimitiveIndex},
|
graph::{GetMaybeNet, PrimitiveIndex},
|
||||||
primitive::{GetJoints, GetOtherJoint},
|
primitive::{GetJoints, GetOtherJoint},
|
||||||
|
|
@ -15,7 +16,6 @@ use crate::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
||||||
SeqLooseSegWeight,
|
SeqLooseSegWeight,
|
||||||
},
|
},
|
||||||
segbend::Segbend,
|
|
||||||
wraparoundable::WraparoundableIndex,
|
wraparoundable::WraparoundableIndex,
|
||||||
Drawing, Infringement, LayoutException,
|
Drawing, Infringement, LayoutException,
|
||||||
},
|
},
|
||||||
|
|
@ -50,11 +50,11 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
self.drawing.remove_band(band);
|
self.drawing.remove_band(band);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_segbend(&mut self, segbend: &Segbend, face: LooseDotIndex) {
|
pub fn remove_cane(&mut self, cane: &Cane, face: LooseDotIndex) {
|
||||||
self.drawing.remove_segbend(segbend, face)
|
self.drawing.remove_cane(cane, face)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_segbend(
|
pub fn insert_cane(
|
||||||
&mut self,
|
&mut self,
|
||||||
from: DotIndex,
|
from: DotIndex,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -62,9 +62,9 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
seg_weight: SeqLooseSegWeight,
|
seg_weight: SeqLooseSegWeight,
|
||||||
bend_weight: LooseBendWeight,
|
bend_weight: LooseBendWeight,
|
||||||
cw: bool,
|
cw: bool,
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Cane, LayoutException> {
|
||||||
self.drawing
|
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)]
|
#[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},
|
bend::{BendIndex, LooseBendWeight},
|
||||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||||
graph::{GetLayer, GetMaybeNet, MakePrimitive},
|
graph::{GetLayer, GetMaybeNet, MakePrimitive},
|
||||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
guide::{CaneHead, Guide, Head, HeadTrait},
|
||||||
primitive::GetOtherJoint,
|
primitive::GetOtherJoint,
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||||
|
|
@ -41,7 +41,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self, from: LooseDotIndex) -> Head {
|
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))]
|
#[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_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()))]
|
#[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,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: FixedDotIndex,
|
around: FixedDotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let mut tangents = self
|
let mut tangents = self
|
||||||
.guide()
|
.guide()
|
||||||
.head_around_dot_segments(&head, around.into(), width)?;
|
.head_around_dot_segments(&head, around.into(), width)?;
|
||||||
|
|
@ -116,7 +116,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
let mut errs = vec![];
|
let mut errs = vec![];
|
||||||
|
|
||||||
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
||||||
match self.segbend_around(
|
match self.cane_around(
|
||||||
head,
|
head,
|
||||||
around.into(),
|
around.into(),
|
||||||
tangent.start_point(),
|
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_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()))]
|
#[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,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let mut tangents = self
|
let mut tangents = self
|
||||||
.guide()
|
.guide()
|
||||||
.head_around_bend_segments(&head, around.into(), width)?;
|
.head_around_bend_segments(&head, around.into(), width)?;
|
||||||
|
|
@ -161,7 +161,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
let mut errs = vec![];
|
let mut errs = vec![];
|
||||||
|
|
||||||
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
|
||||||
match self.segbend_around(
|
match self.cane_around(
|
||||||
head,
|
head,
|
||||||
around.into(),
|
around.into(),
|
||||||
tangent.start_point(),
|
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_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()))]
|
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||||
fn segbend_around(
|
fn cane_around(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -193,16 +193,16 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
cw: bool,
|
cw: bool,
|
||||||
width: f64,
|
width: f64,
|
||||||
offset: f64,
|
offset: f64,
|
||||||
) -> Result<SegbendHead, LayoutException> {
|
) -> Result<CaneHead, LayoutException> {
|
||||||
let head = self.extend_head(head, from)?;
|
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()))]
|
#[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> {
|
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)?;
|
self.layout.move_dot(head.face.into(), to)?;
|
||||||
Ok(Head::Segbend(head))
|
Ok(Head::Cane(head))
|
||||||
} else {
|
} else {
|
||||||
Ok(head)
|
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_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()))]
|
#[debug_ensures(ret.is_err() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count()))]
|
||||||
fn segbend(
|
fn cane(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: WraparoundableIndex,
|
around: WraparoundableIndex,
|
||||||
|
|
@ -218,10 +218,10 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
cw: bool,
|
cw: bool,
|
||||||
width: f64,
|
width: f64,
|
||||||
offset: f64,
|
offset: f64,
|
||||||
) -> Result<SegbendHead, LayoutException> {
|
) -> Result<CaneHead, LayoutException> {
|
||||||
let layer = head.face().primitive(self.layout.drawing()).layer();
|
let layer = head.face().primitive(self.layout.drawing()).layer();
|
||||||
let maybe_net = head.face().primitive(self.layout.drawing()).maybe_net();
|
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(),
|
head.face(),
|
||||||
around,
|
around,
|
||||||
LooseDotWeight {
|
LooseDotWeight {
|
||||||
|
|
@ -245,26 +245,26 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
},
|
},
|
||||||
cw,
|
cw,
|
||||||
)?;
|
)?;
|
||||||
Ok::<SegbendHead, LayoutException>(SegbendHead {
|
Ok::<CaneHead, LayoutException>(CaneHead {
|
||||||
face: self
|
face: self
|
||||||
.layout
|
.layout
|
||||||
.drawing()
|
.drawing()
|
||||||
.primitive(segbend.bend)
|
.primitive(cane.bend)
|
||||||
.other_joint(segbend.dot),
|
.other_joint(cane.dot),
|
||||||
segbend,
|
cane,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(ret.is_some() -> self.layout.drawing().node_count() == old(self.layout.drawing().node_count() - 4))]
|
#[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()))]
|
#[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
|
let prev_dot = self
|
||||||
.layout
|
.layout
|
||||||
.drawing()
|
.drawing()
|
||||||
.primitive(head.segbend.seg)
|
.primitive(head.cane.seg)
|
||||||
.other_joint(head.segbend.dot.into());
|
.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))
|
Some(self.guide().head(prev_dot))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
band::BandIndex,
|
band::BandIndex,
|
||||||
bend::LooseBendIndex,
|
bend::LooseBendIndex,
|
||||||
dot::FixedDotIndex,
|
dot::FixedDotIndex,
|
||||||
guide::{BareHead, Head, SegbendHead},
|
guide::{BareHead, CaneHead, Head},
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
},
|
},
|
||||||
layout::Layout,
|
layout::Layout,
|
||||||
|
|
@ -111,7 +111,7 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
head: Head,
|
head: Head,
|
||||||
around: NavvertexIndex,
|
around: NavvertexIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
match around {
|
match around {
|
||||||
NavvertexIndex::FixedDot(dot) => self.wrap_around_fixed_dot(head, dot, width),
|
NavvertexIndex::FixedDot(dot) => self.wrap_around_fixed_dot(head, dot, width),
|
||||||
NavvertexIndex::FixedBend(_fixed_bend) => todo!(),
|
NavvertexIndex::FixedBend(_fixed_bend) => todo!(),
|
||||||
|
|
@ -126,8 +126,8 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
head: Head,
|
head: Head,
|
||||||
around: FixedDotIndex,
|
around: FixedDotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let head = Draw::new(self.layout).segbend_around_dot(head, around.into(), width)?;
|
let head = Draw::new(self.layout).cane_around_dot(head, around.into(), width)?;
|
||||||
Ok(head)
|
Ok(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,16 +136,16 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
head: Head,
|
head: Head,
|
||||||
around: LooseBendIndex,
|
around: LooseBendIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let head = Draw::new(self.layout).segbend_around_bend(head, around.into(), width)?;
|
let head = Draw::new(self.layout).cane_around_bend(head, around.into(), width)?;
|
||||||
|
|
||||||
Ok(head)
|
Ok(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(trace.path.len() == old(trace.path.len() - 1))]
|
#[debug_ensures(trace.path.len() == old(trace.path.len() - 1))]
|
||||||
pub fn undo_step(&mut self, trace: &mut Trace) {
|
pub fn undo_step(&mut self, trace: &mut Trace) {
|
||||||
if let Head::Segbend(head) = trace.head {
|
if let Head::Cane(head) = trace.head {
|
||||||
trace.head = Draw::new(self.layout).undo_segbend(head).unwrap();
|
trace.head = Draw::new(self.layout).undo_cane(head).unwrap();
|
||||||
} else {
|
} else {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ use crate::{
|
||||||
layout::{zone::SolidZoneWeight, Layout},
|
layout::{zone::SolidZoneWeight, Layout},
|
||||||
math::Circle,
|
math::Circle,
|
||||||
specctra::{
|
specctra::{
|
||||||
read::{self, ListTokenizer},
|
|
||||||
mesadata::SpecctraMesadata,
|
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 mut list_reader = read::ListTokenizer::new(reader);
|
||||||
let dsn = list_reader.read_value::<DsnFile>()?;
|
let dsn = list_reader.read_value::<DsnFile>()?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { pcb: dsn.pcb })
|
||||||
pcb: dsn.pcb,
|
|
||||||
})
|
|
||||||
|
|
||||||
//use super::structure::*;
|
//use super::structure::*;
|
||||||
|
|
||||||
|
|
@ -111,9 +109,7 @@ impl SpecctraDesign {
|
||||||
let mut list_reader = ListTokenizer::new(contents.as_bytes());
|
let mut list_reader = ListTokenizer::new(contents.as_bytes());
|
||||||
let dsn = list_reader.read_value::<DsnFile>()?;
|
let dsn = list_reader.read_value::<DsnFile>()?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { pcb: dsn.pcb })
|
||||||
pcb: dsn.pcb,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
||||||
|
|
@ -601,14 +597,7 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
// iterate through path coords starting from the second
|
// iterate through path coords starting from the second
|
||||||
for coord in coords.iter().skip(1) {
|
for coord in coords.iter().skip(1) {
|
||||||
let pos = Self::pos(
|
let pos = Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y);
|
||||||
place_pos,
|
|
||||||
place_rot,
|
|
||||||
pin_pos,
|
|
||||||
pin_rot,
|
|
||||||
coord.x,
|
|
||||||
coord.y,
|
|
||||||
);
|
|
||||||
|
|
||||||
if pos == prev_pos {
|
if pos == prev_pos {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -691,14 +680,7 @@ impl SpecctraDesign {
|
||||||
let index = board.add_zone_fixed_dot_infringably(
|
let index = board.add_zone_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(
|
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y)
|
||||||
place_pos,
|
|
||||||
place_rot,
|
|
||||||
pin_pos,
|
|
||||||
pin_rot,
|
|
||||||
coord.x,
|
|
||||||
coord.y,
|
|
||||||
)
|
|
||||||
.into(),
|
.into(),
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue