mirror of https://codeberg.org/topola/topola.git
refactor(drawing): deduplicate code in update_this_and_outward_bows
This commit is contained in:
parent
c01c8046bb
commit
da6b825ee7
|
|
@ -540,29 +540,28 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
|
||||||
|
|
||||||
let from_head = self.rear_head(joints.1);
|
let from_head = self.rear_head(joints.1);
|
||||||
let to_head = self.rear_head(joints.0);
|
let to_head = self.rear_head(joints.0);
|
||||||
|
let rail_width = rail_primitive.width();
|
||||||
|
|
||||||
if let Some(inner) = rail_primitive.inner() {
|
let (from, to, offset) = if let Some(inner) = rail_primitive.inner() {
|
||||||
let from = self
|
let from = self
|
||||||
.head_around_bend_segment(
|
.head_around_bend_segment(&from_head, inner.into(), true, rail_width)?
|
||||||
&from_head,
|
|
||||||
inner.into(),
|
|
||||||
true,
|
|
||||||
self.primitive(rail).width(),
|
|
||||||
)?
|
|
||||||
.end_point();
|
.end_point();
|
||||||
let to = self
|
let to = self
|
||||||
.head_around_bend_segment(
|
.head_around_bend_segment(&to_head, inner.into(), false, rail_width)?
|
||||||
&to_head,
|
|
||||||
inner.into(),
|
|
||||||
false,
|
|
||||||
self.primitive(rail).width(),
|
|
||||||
)?
|
|
||||||
.end_point();
|
.end_point();
|
||||||
let offset = self.head_around_bend_offset(
|
let offset = self.head_around_bend_offset(&from_head, inner.into(), rail_width);
|
||||||
&from_head,
|
(from, to, offset)
|
||||||
inner.into(),
|
} else {
|
||||||
self.primitive(rail).width(),
|
let core = rail_primitive.core();
|
||||||
);
|
let from = self
|
||||||
|
.head_around_dot_segment(&from_head, core.into(), true, rail_width)?
|
||||||
|
.end_point();
|
||||||
|
let to = self
|
||||||
|
.head_around_dot_segment(&to_head, core.into(), false, rail_width)?
|
||||||
|
.end_point();
|
||||||
|
let offset = self.head_around_dot_offset(&from_head, core.into(), rail_width);
|
||||||
|
(from, to, offset)
|
||||||
|
};
|
||||||
|
|
||||||
self.move_dot_with_infringables(
|
self.move_dot_with_infringables(
|
||||||
recorder,
|
recorder,
|
||||||
|
|
@ -585,50 +584,6 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Update offsets in case the rule conditions changed.
|
// Update offsets in case the rule conditions changed.
|
||||||
} else {
|
|
||||||
let core = rail_primitive.core();
|
|
||||||
let from = self
|
|
||||||
.head_around_dot_segment(
|
|
||||||
&from_head,
|
|
||||||
core.into(),
|
|
||||||
true,
|
|
||||||
self.primitive(rail).width(),
|
|
||||||
)?
|
|
||||||
.end_point();
|
|
||||||
let to = self
|
|
||||||
.head_around_dot_segment(
|
|
||||||
&to_head,
|
|
||||||
core.into(),
|
|
||||||
false,
|
|
||||||
self.primitive(rail).width(),
|
|
||||||
)?
|
|
||||||
.end_point();
|
|
||||||
let offset = self.head_around_dot_offset(
|
|
||||||
&from_head,
|
|
||||||
core.into(),
|
|
||||||
self.primitive(rail).width(),
|
|
||||||
);
|
|
||||||
|
|
||||||
self.move_dot_with_infringables(
|
|
||||||
recorder,
|
|
||||||
joints.0.into(),
|
|
||||||
from,
|
|
||||||
Some(&self.bend_outer_bows(rail)),
|
|
||||||
)?;
|
|
||||||
self.move_dot_with_infringables(
|
|
||||||
recorder,
|
|
||||||
joints.1.into(),
|
|
||||||
to,
|
|
||||||
Some(&self.bend_outer_bows(rail)),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
self.shift_bend_with_infringables(
|
|
||||||
recorder,
|
|
||||||
rail.into(),
|
|
||||||
offset,
|
|
||||||
Some(&self.bend_outer_bows(rail)),
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
maybe_rail = self.primitive(rail).outer();
|
maybe_rail = self.primitive(rail).outer();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue