mirror of https://codeberg.org/topola/topola.git
layout: store rotation direction as joint order instead of in weights
This commit is contained in:
parent
a395da4740
commit
fd73531687
|
|
@ -231,8 +231,8 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
band: head.band(),
|
||||
width,
|
||||
offset,
|
||||
cw,
|
||||
},
|
||||
cw,
|
||||
)?;
|
||||
Ok::<SegbendHead, LayoutException>(SegbendHead {
|
||||
face: self.layout.primitive(segbend.bend).other_joint(segbend.dot),
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ pub struct FixedBendWeight {
|
|||
pub component: ComponentIndex,
|
||||
pub width: f64,
|
||||
pub offset: f64,
|
||||
pub cw: bool,
|
||||
}
|
||||
|
||||
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
|
||||
|
|
@ -103,7 +102,6 @@ pub struct LooseBendWeight {
|
|||
pub band: BandIndex,
|
||||
pub width: f64,
|
||||
pub offset: f64,
|
||||
pub cw: bool,
|
||||
}
|
||||
|
||||
impl GetOffset for LooseBendWeight {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use crate::{
|
|||
|
||||
use super::{
|
||||
graph::GeometryIndex,
|
||||
primitive::GetJoints,
|
||||
rules::{Conditions, RulesTrait},
|
||||
segbend::Segbend,
|
||||
};
|
||||
|
|
@ -166,7 +167,13 @@ impl<'a, R: RulesTrait> Guide<'a, R> {
|
|||
|
||||
pub fn head_cw(&self, head: &Head) -> Option<bool> {
|
||||
if let Head::Segbend(head) = head {
|
||||
Some(self.layout.primitive(head.segbend.bend).weight().cw)
|
||||
let joints = self.layout.primitive(head.segbend.bend).joints();
|
||||
|
||||
if head.face() == joints.0.into() {
|
||||
Some(false)
|
||||
} else {
|
||||
Some(true)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ impl<R: RulesTrait> Layout<R> {
|
|||
dot_weight: LooseDotWeight,
|
||||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
||||
let mut infringables = self.this_and_wraparound_bow(around);
|
||||
|
|
@ -268,6 +269,7 @@ impl<R: RulesTrait> Layout<R> {
|
|||
dot_weight,
|
||||
seg_weight,
|
||||
bend_weight,
|
||||
cw,
|
||||
&infringables,
|
||||
)?;
|
||||
|
||||
|
|
@ -411,26 +413,18 @@ impl<R: RulesTrait> Layout<R> {
|
|||
|
||||
while let Some(rail) = maybe_rail {
|
||||
let rail_primitive = self.primitive(rail);
|
||||
let cw = rail_primitive.weight().cw;
|
||||
let ends = rail_primitive.joints();
|
||||
|
||||
let inner_conditions = Conditions::from(if let Some(inner) = rail_primitive.inner() {
|
||||
self.primitive(inner).conditions()
|
||||
} else {
|
||||
self.primitive(rail_primitive.core()).conditions()
|
||||
});
|
||||
let rail_conditions = Conditions::from(rail_primitive.conditions());
|
||||
|
||||
let guide = Guide::new(self);
|
||||
let from_head = guide.rear_head(ends.1);
|
||||
let to_head = guide.rear_head(ends.0);
|
||||
|
||||
if let Some(inner) = rail_primitive.inner() {
|
||||
let from = guide
|
||||
.head_around_bend_segment(&from_head.into(), inner.into(), !cw, 6.0)?
|
||||
.head_around_bend_segment(&from_head.into(), inner.into(), true, 6.0)?
|
||||
.end_point();
|
||||
let to = guide
|
||||
.head_around_bend_segment(&to_head.into(), inner.into(), cw, 6.0)?
|
||||
.head_around_bend_segment(&to_head.into(), inner.into(), false, 6.0)?
|
||||
.end_point();
|
||||
self.move_dot_infringably(
|
||||
ends.0.into(),
|
||||
|
|
@ -441,10 +435,10 @@ impl<R: RulesTrait> Layout<R> {
|
|||
} else {
|
||||
let core = rail_primitive.core();
|
||||
let from = guide
|
||||
.head_around_dot_segment(&from_head.into(), core.into(), !cw, 6.0)?
|
||||
.head_around_dot_segment(&from_head.into(), core.into(), true, 6.0)?
|
||||
.end_point();
|
||||
let to = guide
|
||||
.head_around_dot_segment(&to_head.into(), core.into(), cw, 6.0)?
|
||||
.head_around_dot_segment(&to_head.into(), core.into(), false, 6.0)?
|
||||
.end_point();
|
||||
self.move_dot_infringably(
|
||||
ends.0.into(),
|
||||
|
|
@ -471,6 +465,7 @@ impl<R: RulesTrait> Layout<R> {
|
|||
dot_weight: LooseDotWeight,
|
||||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
self.add_segbend_infringably(
|
||||
from,
|
||||
|
|
@ -478,6 +473,7 @@ impl<R: RulesTrait> Layout<R> {
|
|||
dot_weight,
|
||||
seg_weight,
|
||||
bend_weight,
|
||||
cw,
|
||||
&self.this_and_wraparound_bow(around),
|
||||
)
|
||||
}
|
||||
|
|
@ -493,6 +489,7 @@ impl<R: RulesTrait> Layout<R> {
|
|||
dot_weight: LooseDotWeight,
|
||||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
cw: bool,
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
let seg_to = self.add_dot_infringably(dot_weight, infringables)?;
|
||||
|
|
@ -503,17 +500,20 @@ impl<R: RulesTrait> Layout<R> {
|
|||
err
|
||||
})?;
|
||||
|
||||
let bend_to = self
|
||||
let to = self
|
||||
.add_dot_infringably(dot_weight, infringables)
|
||||
.map_err(|err| {
|
||||
self.geometry_with_rtree.remove_seg(seg.into());
|
||||
self.geometry_with_rtree.remove_dot(seg_to.into());
|
||||
err
|
||||
})?;
|
||||
|
||||
let (bend_from, bend_to) = if cw { (to, seg_to) } else { (seg_to, to) };
|
||||
|
||||
let bend = self
|
||||
.add_loose_bend_infringably(seg_to, bend_to, around, bend_weight, infringables)
|
||||
.add_loose_bend_infringably(bend_from, bend_to, around, bend_weight, infringables)
|
||||
.map_err(|err| {
|
||||
self.geometry_with_rtree.remove_dot(bend_to.into());
|
||||
self.geometry_with_rtree.remove_dot(to.into());
|
||||
self.geometry_with_rtree.remove_seg(seg.into());
|
||||
self.geometry_with_rtree.remove_dot(seg_to.into());
|
||||
err
|
||||
|
|
|
|||
Loading…
Reference in New Issue