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)
|
||||
}
|
||||
|
||||
#[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(
|
||||
&mut self,
|
||||
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 inner = inner.into();
|
||||
let from = self.head_around_bend_segment(
|
||||
let from = self.guide_for_head_around_bend_segment(
|
||||
&from_head,
|
||||
inner,
|
||||
RotationSense::Counterclockwise,
|
||||
width,
|
||||
)?;
|
||||
let to = self.head_around_bend_segment(
|
||||
let to = self.guide_for_head_around_bend_segment(
|
||||
&to_head,
|
||||
inner,
|
||||
RotationSense::Clockwise,
|
||||
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)
|
||||
} else {
|
||||
let core = rail_primitive.core().into();
|
||||
let from = self.head_around_dot_segment(
|
||||
let from = self.guide_for_head_around_dot_segment(
|
||||
&from_head,
|
||||
core,
|
||||
RotationSense::Counterclockwise,
|
||||
width,
|
||||
)?;
|
||||
let to =
|
||||
self.head_around_dot_segment(&to_head, core, RotationSense::Clockwise, width)?;
|
||||
let offset = self.head_around_dot_offset(&from_head, core, width);
|
||||
let to = self.guide_for_head_around_dot_segment(
|
||||
&to_head,
|
||||
core,
|
||||
RotationSense::Clockwise,
|
||||
width,
|
||||
)?;
|
||||
let offset = self.guide_for_head_around_dot_offset(&from_head, core, width);
|
||||
(from, to, offset)
|
||||
};
|
||||
|
||||
let rail_outer_bows = self.bend_outer_bows(rail);
|
||||
|
||||
// Commenting out these two makes the crash go away.
|
||||
self.move_dot_with_infringement_filtering(
|
||||
recorder,
|
||||
joints.0.into(),
|
||||
|
|
|
|||
|
|
@ -20,21 +20,21 @@ use super::{
|
|||
};
|
||||
|
||||
pub trait Guide {
|
||||
fn head_into_dot_segment(
|
||||
fn guide_for_head_into_dot_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
into: FixedDotIndex,
|
||||
width: f64,
|
||||
) -> Result<Line, NoTangents>;
|
||||
|
||||
fn head_around_dot_segments(
|
||||
fn guide_for_head_around_dot_segments(
|
||||
&self,
|
||||
head: &Head,
|
||||
around: DotIndex,
|
||||
width: f64,
|
||||
) -> Result<(Line, Line), NoTangents>;
|
||||
|
||||
fn head_around_dot_segment(
|
||||
fn guide_for_head_around_dot_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
around: DotIndex,
|
||||
|
|
@ -42,16 +42,16 @@ pub trait Guide {
|
|||
width: f64,
|
||||
) -> 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,
|
||||
head: &Head,
|
||||
around: BendIndex,
|
||||
width: f64,
|
||||
) -> Result<(Line, Line), NoTangents>;
|
||||
|
||||
fn head_around_bend_segment(
|
||||
fn guide_for_head_around_bend_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
around: BendIndex,
|
||||
|
|
@ -59,7 +59,8 @@ pub trait Guide {
|
|||
width: f64,
|
||||
) -> 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>;
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ pub trait Guide {
|
|||
}
|
||||
|
||||
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,
|
||||
head: &Head,
|
||||
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)
|
||||
}
|
||||
|
||||
fn head_around_dot_segments(
|
||||
fn guide_for_head_around_dot_segments(
|
||||
&self,
|
||||
head: &Head,
|
||||
around: DotIndex,
|
||||
|
|
@ -103,7 +104,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
|||
Ok((tangents[0], tangents[1]))
|
||||
}
|
||||
|
||||
fn head_around_dot_segment(
|
||||
fn guide_for_head_around_dot_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
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))
|
||||
}
|
||||
|
||||
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.conditions(around.into()).as_ref(),
|
||||
self.conditions(head.face().into()).as_ref(),
|
||||
)
|
||||
}
|
||||
|
||||
fn head_around_bend_segments(
|
||||
fn guide_for_head_around_bend_segments(
|
||||
&self,
|
||||
head: &Head,
|
||||
around: BendIndex,
|
||||
|
|
@ -141,7 +142,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
|
|||
Ok((tangents[0], tangents[1]))
|
||||
}
|
||||
|
||||
fn head_around_bend_segment(
|
||||
fn guide_for_head_around_bend_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
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))
|
||||
}
|
||||
|
||||
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.conditions(head.face().into()).as_ref(),
|
||||
self.conditions(around.into()).as_ref(),
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ impl<
|
|||
edit: &BTreeMap<I, (Option<D>, Option<D>)>,
|
||||
) {
|
||||
for (index, (old, new)) in edit {
|
||||
// TODO: Delete `(None, None)`s.
|
||||
match main.entry(*index) {
|
||||
Entry::Vacant(vac) => {
|
||||
vac.insert((old.clone(), new.clone()));
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ impl<R: AccessRules> Draw for Layout<R> {
|
|||
) -> Result<BandTermsegIndex, DrawException> {
|
||||
let tangent = self
|
||||
.drawing()
|
||||
.head_into_dot_segment(&head, into, width)
|
||||
.guide_for_head_into_dot_segment(&head, into, width)
|
||||
.map_err(Into::<DrawException>::into)?;
|
||||
|
||||
let (layer, maybe_net) = {
|
||||
|
|
@ -137,12 +137,12 @@ impl<R: AccessRules> Draw for Layout<R> {
|
|||
sense: RotationSense,
|
||||
width: f64,
|
||||
) -> Result<CaneHead, DrawException> {
|
||||
let tangent = self
|
||||
.drawing()
|
||||
.head_around_dot_segment(&head, around.into(), sense, width)?;
|
||||
let tangent =
|
||||
self.drawing()
|
||||
.guide_for_head_around_dot_segment(&head, around.into(), sense, width)?;
|
||||
let offset = self
|
||||
.drawing()
|
||||
.head_around_dot_offset(&head, around.into(), width);
|
||||
.guide_for_head_around_dot_offset(&head, around.into(), width);
|
||||
self.cane_around(
|
||||
recorder,
|
||||
head,
|
||||
|
|
@ -168,8 +168,10 @@ impl<R: AccessRules> Draw for Layout<R> {
|
|||
) -> Result<CaneHead, DrawException> {
|
||||
let tangent = self
|
||||
.drawing()
|
||||
.head_around_bend_segment(&head, around, sense, width)?;
|
||||
let offset = self.drawing().head_around_bend_offset(&head, around, width);
|
||||
.guide_for_head_around_bend_segment(&head, around, sense, width)?;
|
||||
let offset = self
|
||||
.drawing()
|
||||
.guide_for_head_around_bend_offset(&head, around, width);
|
||||
|
||||
self.cane_around(
|
||||
recorder,
|
||||
|
|
|
|||
Loading…
Reference in New Issue