mirror of https://codeberg.org/topola/topola.git
refactor(drawing/drawing): Some minor changes to method naming, comments, contracts
This commit is contained in:
parent
3c9ce32ff2
commit
4d5fc25ae3
|
|
@ -693,6 +693,8 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
||||||
Ok(cane)
|
Ok(cane)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))]
|
||||||
|
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
|
||||||
fn update_this_and_outward_bows_intern(
|
fn update_this_and_outward_bows_intern(
|
||||||
&mut self,
|
&mut self,
|
||||||
recorder: &mut DrawingEdit<CW, Cel>,
|
recorder: &mut DrawingEdit<CW, Cel>,
|
||||||
|
|
@ -710,36 +712,41 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
||||||
|
|
||||||
let (from, to, offset) = if let Some(inner) = rail_primitive.inner() {
|
let (from, to, offset) = if let Some(inner) = rail_primitive.inner() {
|
||||||
let inner = inner.into();
|
let inner = inner.into();
|
||||||
let from = self.head_around_bend_segment(
|
let from = self.guide_for_head_around_bend_segment(
|
||||||
&from_head,
|
&from_head,
|
||||||
inner,
|
inner,
|
||||||
RotationSense::Counterclockwise,
|
RotationSense::Counterclockwise,
|
||||||
width,
|
width,
|
||||||
)?;
|
)?;
|
||||||
let to = self.head_around_bend_segment(
|
let to = self.guide_for_head_around_bend_segment(
|
||||||
&to_head,
|
&to_head,
|
||||||
inner,
|
inner,
|
||||||
RotationSense::Clockwise,
|
RotationSense::Clockwise,
|
||||||
width,
|
width,
|
||||||
)?;
|
)?;
|
||||||
let offset = self.head_around_bend_offset(&from_head, inner, width);
|
let offset = self.guide_for_head_around_bend_offset(&from_head, inner, width);
|
||||||
(from, to, offset)
|
(from, to, offset)
|
||||||
} else {
|
} else {
|
||||||
let core = rail_primitive.core().into();
|
let core = rail_primitive.core().into();
|
||||||
let from = self.head_around_dot_segment(
|
let from = self.guide_for_head_around_dot_segment(
|
||||||
&from_head,
|
&from_head,
|
||||||
core,
|
core,
|
||||||
RotationSense::Counterclockwise,
|
RotationSense::Counterclockwise,
|
||||||
width,
|
width,
|
||||||
)?;
|
)?;
|
||||||
let to =
|
let to = self.guide_for_head_around_dot_segment(
|
||||||
self.head_around_dot_segment(&to_head, core, RotationSense::Clockwise, width)?;
|
&to_head,
|
||||||
let offset = self.head_around_dot_offset(&from_head, core, width);
|
core,
|
||||||
|
RotationSense::Clockwise,
|
||||||
|
width,
|
||||||
|
)?;
|
||||||
|
let offset = self.guide_for_head_around_dot_offset(&from_head, core, width);
|
||||||
(from, to, offset)
|
(from, to, offset)
|
||||||
};
|
};
|
||||||
|
|
||||||
let rail_outer_bows = self.bend_outer_bows(rail);
|
let rail_outer_bows = self.bend_outer_bows(rail);
|
||||||
|
|
||||||
|
// Commenting out these two makes the crash go away.
|
||||||
self.move_dot_with_infringement_filtering(
|
self.move_dot_with_infringement_filtering(
|
||||||
recorder,
|
recorder,
|
||||||
joints.0.into(),
|
joints.0.into(),
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,21 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Guide {
|
pub trait Guide {
|
||||||
fn head_into_dot_segment(
|
fn guide_for_head_into_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
into: FixedDotIndex,
|
into: FixedDotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Line, NoTangents>;
|
) -> Result<Line, NoTangents>;
|
||||||
|
|
||||||
fn head_around_dot_segments(
|
fn guide_for_head_around_dot_segments(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(Line, Line), NoTangents>;
|
) -> Result<(Line, Line), NoTangents>;
|
||||||
|
|
||||||
fn head_around_dot_segment(
|
fn guide_for_head_around_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
|
|
@ -42,16 +42,16 @@ pub trait Guide {
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Line, NoTangents>;
|
) -> Result<Line, NoTangents>;
|
||||||
|
|
||||||
fn head_around_dot_offset(&self, head: &Head, around: DotIndex, _width: f64) -> f64;
|
fn guide_for_head_around_dot_offset(&self, head: &Head, around: DotIndex, _width: f64) -> f64;
|
||||||
|
|
||||||
fn head_around_bend_segments(
|
fn guide_for_head_around_bend_segments(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(Line, Line), NoTangents>;
|
) -> Result<(Line, Line), NoTangents>;
|
||||||
|
|
||||||
fn head_around_bend_segment(
|
fn guide_for_head_around_bend_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
|
|
@ -59,7 +59,8 @@ pub trait Guide {
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Line, NoTangents>;
|
) -> Result<Line, NoTangents>;
|
||||||
|
|
||||||
fn head_around_bend_offset(&self, head: &Head, around: BendIndex, _width: f64) -> f64;
|
fn guide_for_head_around_bend_offset(&self, head: &Head, around: BendIndex, _width: f64)
|
||||||
|
-> f64;
|
||||||
|
|
||||||
fn head_sense(&self, head: &Head) -> Option<RotationSense>;
|
fn head_sense(&self, head: &Head) -> Option<RotationSense>;
|
||||||
|
|
||||||
|
|
@ -71,7 +72,7 @@ pub trait Guide {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
fn head_into_dot_segment(
|
fn guide_for_head_into_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
into: FixedDotIndex,
|
into: FixedDotIndex,
|
||||||
|
|
@ -87,7 +88,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
math::tangent_segment(from_circle, from_sense, to_circle, None)
|
math::tangent_segment(from_circle, from_sense, to_circle, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_dot_segments(
|
fn guide_for_head_around_dot_segments(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
|
|
@ -103,7 +104,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
Ok((tangents[0], tangents[1]))
|
Ok((tangents[0], tangents[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_dot_segment(
|
fn guide_for_head_around_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
|
|
@ -118,14 +119,14 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
math::tangent_segment(from_circle, from_sense, to_circle, Some(sense))
|
math::tangent_segment(from_circle, from_sense, to_circle, Some(sense))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_dot_offset(&self, head: &Head, around: DotIndex, _width: f64) -> f64 {
|
fn guide_for_head_around_dot_offset(&self, head: &Head, around: DotIndex, _width: f64) -> f64 {
|
||||||
self.clearance(
|
self.clearance(
|
||||||
self.conditions(around.into()).as_ref(),
|
self.conditions(around.into()).as_ref(),
|
||||||
self.conditions(head.face().into()).as_ref(),
|
self.conditions(head.face().into()).as_ref(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_bend_segments(
|
fn guide_for_head_around_bend_segments(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
|
|
@ -141,7 +142,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
Ok((tangents[0], tangents[1]))
|
Ok((tangents[0], tangents[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_bend_segment(
|
fn guide_for_head_around_bend_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
|
|
@ -156,7 +157,12 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
||||||
math::tangent_segment(from_circle, from_sense, to_circle, Some(sense))
|
math::tangent_segment(from_circle, from_sense, to_circle, Some(sense))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn head_around_bend_offset(&self, head: &Head, around: BendIndex, _width: f64) -> f64 {
|
fn guide_for_head_around_bend_offset(
|
||||||
|
&self,
|
||||||
|
head: &Head,
|
||||||
|
around: BendIndex,
|
||||||
|
_width: f64,
|
||||||
|
) -> f64 {
|
||||||
self.clearance(
|
self.clearance(
|
||||||
self.conditions(head.face().into()).as_ref(),
|
self.conditions(head.face().into()).as_ref(),
|
||||||
self.conditions(around.into()).as_ref(),
|
self.conditions(around.into()).as_ref(),
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ impl<
|
||||||
edit: &BTreeMap<I, (Option<D>, Option<D>)>,
|
edit: &BTreeMap<I, (Option<D>, Option<D>)>,
|
||||||
) {
|
) {
|
||||||
for (index, (old, new)) in edit {
|
for (index, (old, new)) in edit {
|
||||||
// TODO: Delete `(None, None)`s.
|
|
||||||
match main.entry(*index) {
|
match main.entry(*index) {
|
||||||
Entry::Vacant(vac) => {
|
Entry::Vacant(vac) => {
|
||||||
vac.insert((old.clone(), new.clone()));
|
vac.insert((old.clone(), new.clone()));
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ impl<R: AccessRules> Draw for Layout<R> {
|
||||||
) -> Result<BandTermsegIndex, DrawException> {
|
) -> Result<BandTermsegIndex, DrawException> {
|
||||||
let tangent = self
|
let tangent = self
|
||||||
.drawing()
|
.drawing()
|
||||||
.head_into_dot_segment(&head, into, width)
|
.guide_for_head_into_dot_segment(&head, into, width)
|
||||||
.map_err(Into::<DrawException>::into)?;
|
.map_err(Into::<DrawException>::into)?;
|
||||||
|
|
||||||
let (layer, maybe_net) = {
|
let (layer, maybe_net) = {
|
||||||
|
|
@ -137,12 +137,12 @@ impl<R: AccessRules> Draw for Layout<R> {
|
||||||
sense: RotationSense,
|
sense: RotationSense,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<CaneHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let tangent = self
|
let tangent =
|
||||||
.drawing()
|
self.drawing()
|
||||||
.head_around_dot_segment(&head, around.into(), sense, width)?;
|
.guide_for_head_around_dot_segment(&head, around.into(), sense, width)?;
|
||||||
let offset = self
|
let offset = self
|
||||||
.drawing()
|
.drawing()
|
||||||
.head_around_dot_offset(&head, around.into(), width);
|
.guide_for_head_around_dot_offset(&head, around.into(), width);
|
||||||
self.cane_around(
|
self.cane_around(
|
||||||
recorder,
|
recorder,
|
||||||
head,
|
head,
|
||||||
|
|
@ -168,8 +168,10 @@ impl<R: AccessRules> Draw for Layout<R> {
|
||||||
) -> Result<CaneHead, DrawException> {
|
) -> Result<CaneHead, DrawException> {
|
||||||
let tangent = self
|
let tangent = self
|
||||||
.drawing()
|
.drawing()
|
||||||
.head_around_bend_segment(&head, around, sense, width)?;
|
.guide_for_head_around_bend_segment(&head, around, sense, width)?;
|
||||||
let offset = self.drawing().head_around_bend_offset(&head, around, width);
|
let offset = self
|
||||||
|
.drawing()
|
||||||
|
.guide_for_head_around_bend_offset(&head, around, width);
|
||||||
|
|
||||||
self.cane_around(
|
self.cane_around(
|
||||||
recorder,
|
recorder,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue