mirror of https://codeberg.org/topola/topola.git
refactor(drawing/primitive): Rename Primitive<...> to PrimitiveRef<...> with its variants
This commit is contained in:
parent
3b520b56c6
commit
7c4bc87301
|
|
@ -14,7 +14,7 @@ use topola::{
|
|||
drawing::{
|
||||
bend::BendIndex,
|
||||
dot::DotIndex,
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
head::GetFace,
|
||||
primitive::MakePrimitiveShape,
|
||||
},
|
||||
|
|
@ -91,7 +91,7 @@ impl<'a> Displayer<'a> {
|
|||
for i in (0..self.workspace.appearance_panel.visible.len()).rev() {
|
||||
if self.workspace.appearance_panel.visible[i] {
|
||||
for primitive in board.layout().drawing().layer_primitive_nodes(i) {
|
||||
let shape = primitive.primitive(board.layout().drawing()).shape();
|
||||
let shape = primitive.primitive_ref(board.layout().drawing()).shape();
|
||||
|
||||
let color = if self
|
||||
.workspace
|
||||
|
|
@ -181,12 +181,12 @@ impl<'a> Displayer<'a> {
|
|||
for edge in navmesh.edge_references() {
|
||||
let mut from =
|
||||
PrimitiveIndex::from(navmesh.node_weight(edge.source()).unwrap().binavnode)
|
||||
.primitive(board.layout().drawing())
|
||||
.primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center();
|
||||
let mut to =
|
||||
PrimitiveIndex::from(navmesh.node_weight(edge.target()).unwrap().binavnode)
|
||||
.primitive(board.layout().drawing())
|
||||
.primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center();
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ impl<'a> Displayer<'a> {
|
|||
let primitive =
|
||||
PrimitiveIndex::from(navmesh.node_weight(navnode).unwrap().binavnode);
|
||||
let mut pos = primitive
|
||||
.primitive(board.layout().drawing())
|
||||
.primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center();
|
||||
|
||||
|
|
@ -349,11 +349,11 @@ impl<'a> Displayer<'a> {
|
|||
|
||||
for edge in navmesh.prenavmesh().triangulation().edge_references() {
|
||||
let from = PrimitiveIndex::from(BinavnodeNodeIndex::from(edge.source()))
|
||||
.primitive(board.layout().drawing())
|
||||
.primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center();
|
||||
let to = PrimitiveIndex::from(BinavnodeNodeIndex::from(edge.target()))
|
||||
.primitive(board.layout().drawing())
|
||||
.primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center();
|
||||
|
||||
|
|
@ -411,7 +411,9 @@ impl<'a> Displayer<'a> {
|
|||
use topola::router::ng::pie::NavmeshIndex;
|
||||
let mut map = BTreeMap::new();
|
||||
let resolve_primal = |p: &topola::drawing::dot::FixedDotIndex| {
|
||||
(*p).primitive(board.layout().drawing()).shape().center()
|
||||
(*p).primitive_ref(board.layout().drawing())
|
||||
.shape()
|
||||
.center()
|
||||
};
|
||||
|
||||
for (nidx, node) in &*navmesh.nodes {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
autoroute::AutorouteExecutionStepper, presorter::SccIntersectionsAndLengthPresorter,
|
||||
ratline::RatlineIndex, Autorouter, AutorouterOptions,
|
||||
},
|
||||
drawing::graph::MakePrimitive,
|
||||
drawing::graph::MakePrimitiveRef,
|
||||
geometry::{GenericNode, GetLayer},
|
||||
graph::MakeRef,
|
||||
};
|
||||
|
|
@ -141,7 +141,7 @@ impl PermuteRatlines for RatlineCutsRatlinePermuter {
|
|||
.bands_between_nodes(
|
||||
endpoint_dots
|
||||
.0
|
||||
.primitive(autorouter.board().layout().drawing())
|
||||
.primitive_ref(autorouter.board().layout().drawing())
|
||||
.layer(),
|
||||
GenericNode::Primitive(endpoint_dots.0.into()),
|
||||
GenericNode::Primitive(endpoint_dots.1.into()),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandTermsegIndex,
|
||||
dot::FixedDotIndex,
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex},
|
||||
},
|
||||
geometry::{shape::MeasureLength, GetLayer},
|
||||
graph::MakeRef,
|
||||
|
|
@ -91,14 +91,14 @@ impl<'a, M: AccessMesadata> RatlineRef<'a, M> {
|
|||
pub fn layer(&self) -> usize {
|
||||
self.endpoint_dots()
|
||||
.0
|
||||
.primitive(self.autorouter.board().layout().drawing())
|
||||
.primitive_ref(self.autorouter.board().layout().drawing())
|
||||
.layer()
|
||||
}
|
||||
|
||||
pub fn net(&self) -> usize {
|
||||
self.endpoint_dots()
|
||||
.0
|
||||
.primitive(self.autorouter.board().layout().drawing())
|
||||
.primitive_ref(self.autorouter.board().layout().drawing())
|
||||
.maybe_net()
|
||||
.unwrap()
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ impl<'a, M: AccessMesadata> RatlineRef<'a, M> {
|
|||
pub fn cut_other_net_primitives(&self) -> impl Iterator<Item = PrimitiveIndex> + '_ {
|
||||
self.cut_primitives().filter(|primitive_node| {
|
||||
primitive_node
|
||||
.primitive(self.autorouter.board().layout().drawing())
|
||||
.primitive_ref(self.autorouter.board().layout().drawing())
|
||||
.maybe_net()
|
||||
.map(|net| net != self.net())
|
||||
.unwrap_or(true)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandTermsegIndex,
|
||||
dot::FixedDotIndex,
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex},
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
},
|
||||
|
|
@ -108,7 +108,7 @@ impl Ratsnest {
|
|||
handle_ratvertex_weight(
|
||||
layout.drawing().primitive(dot).maybe_net(),
|
||||
RatvertexIndex::FixedDot(dot),
|
||||
node.primitive(layout.drawing()).shape().center(),
|
||||
node.primitive_ref(layout.drawing()).shape().center(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use crate::{
|
||||
board::{AccessMesadata, BandName, Board, ResolvedSelector},
|
||||
drawing::graph::{MakePrimitive, PrimitiveIndex},
|
||||
drawing::graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
geometry::{
|
||||
shape::{AccessShape, Shape},
|
||||
GenericNode, GetLayer,
|
||||
|
|
@ -31,7 +31,7 @@ impl PinSelector {
|
|||
) -> Option<PinSelector> {
|
||||
let layer = match node {
|
||||
NodeIndex::Primitive(primitive) => {
|
||||
primitive.primitive(board.layout().drawing()).layer()
|
||||
primitive.primitive_ref(board.layout().drawing()).layer()
|
||||
}
|
||||
NodeIndex::Compound(compound) => {
|
||||
if let CompoundWeight::Poly(..) = board.layout().drawing().compound_weight(compound)
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ pub enum ResolvedSelector<'a> {
|
|||
|
||||
impl<'a> ResolvedSelector<'a> {
|
||||
pub fn try_from_node(board: &'a Board<impl AccessMesadata>, node: NodeIndex) -> Option<Self> {
|
||||
use crate::{drawing::graph::MakePrimitive, graph::GetPetgraphIndex};
|
||||
use crate::{drawing::graph::MakePrimitiveRef, graph::GetPetgraphIndex};
|
||||
|
||||
let (layer, loose) = match node {
|
||||
NodeIndex::Primitive(primitive) => (
|
||||
primitive.primitive(board.layout().drawing()).layer(),
|
||||
primitive.primitive_ref(board.layout().drawing()).layer(),
|
||||
primitive.try_into().ok(),
|
||||
),
|
||||
NodeIndex::Compound(compound) => {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
graph::MakePrimitive,
|
||||
graph::MakePrimitiveRef,
|
||||
loose::{GetPrevNextLoose, LooseIndex},
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
|
|
@ -42,7 +42,7 @@ impl<'a, CW: 'a, Cel: 'a, R: 'a> BandRef<'a, CW, Cel, R> {
|
|||
|
||||
impl<CW: Clone, Cel: Copy, R: AccessRules> GetLayer for BandRef<'_, CW, Cel, R> {
|
||||
fn layer(&self) -> usize {
|
||||
self.first_seg.primitive(self.drawing).layer()
|
||||
self.first_seg.primitive_ref(self.drawing).layer()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> MeasureLength for BandRef<'_, CW, Cel
|
|||
let mut length = 0.0;
|
||||
|
||||
while let Some(loose) = maybe_loose {
|
||||
length += loose.primitive(self.drawing).shape().length();
|
||||
length += loose.primitive_ref(self.drawing).shape().length();
|
||||
|
||||
let prev_prev = prev;
|
||||
prev = maybe_loose;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use enum_dispatch::enum_dispatch;
|
|||
|
||||
use crate::{
|
||||
drawing::{
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
primitive::{GenericPrimitive, Primitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex, PrimitiveWeight},
|
||||
primitive::{GenericPrimitive, PrimitiveRef},
|
||||
rules::AccessRules,
|
||||
Drawing,
|
||||
},
|
||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
|
||||
use petgraph::stable_graph::NodeIndex;
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub enum BendIndex {
|
||||
Fixed(FixedBendIndex),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use super::{
|
|||
bend::LooseBendIndex,
|
||||
dot::LooseDotIndex,
|
||||
graph::PrimitiveIndex,
|
||||
primitive::{GetInterior, GetJoints, GetOtherJoint, LooseBend, LooseDot},
|
||||
primitive::{GetInterior, GetJoints, GetOtherJoint, LooseBendRef, LooseDotRef},
|
||||
rules::AccessRules,
|
||||
seg::SeqLooseSegIndex,
|
||||
Drawing,
|
||||
|
|
@ -30,9 +30,9 @@ impl Cane {
|
|||
dot: LooseDotIndex,
|
||||
drawing: &Drawing<impl Clone, impl Copy, impl AccessRules>,
|
||||
) -> Self {
|
||||
let bend = LooseDot::new(dot, drawing).bend();
|
||||
let dot = LooseBend::new(bend, drawing).other_joint(dot);
|
||||
let seg = LooseDot::new(dot, drawing).seg().unwrap();
|
||||
let bend = LooseDotRef::new(dot, drawing).bend();
|
||||
let dot = LooseBendRef::new(bend, drawing).other_joint(dot);
|
||||
let seg = LooseDotRef::new(dot, drawing).seg().unwrap();
|
||||
Self { bend, dot, seg }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use petgraph::stable_graph::NodeIndex;
|
|||
|
||||
use crate::{
|
||||
drawing::{
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
primitive::{GenericPrimitive, Primitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex, PrimitiveWeight},
|
||||
primitive::{GenericPrimitive, PrimitiveRef},
|
||||
rules::AccessRules,
|
||||
Drawing,
|
||||
},
|
||||
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
math::Circle,
|
||||
};
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub enum DotIndex {
|
||||
Fixed(FixedDotIndex),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
cane::Cane,
|
||||
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
gear::GearIndex,
|
||||
graph::{GetMaybeNet, IsInLayer, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
graph::{GetMaybeNet, IsInLayer, MakePrimitiveRef, PrimitiveIndex, PrimitiveWeight},
|
||||
loose::{GetPrevNextLoose, Loose, LooseIndex},
|
||||
primitive::{
|
||||
GenericPrimitive, GetCore, GetJoints, GetLimbs, GetOtherJoint, MakePrimitiveShape,
|
||||
|
|
@ -467,8 +467,8 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
// Check whether the the seg is terminal, that is, whether at
|
||||
// least one of its two joints is a fixed dot.
|
||||
if matches!(from, DotIndex::Fixed(..)) || matches!(to, DotIndex::Fixed(..)) {
|
||||
collider.primitive(drawing).maybe_net()
|
||||
!= collidee.primitive(drawing).maybe_net()
|
||||
collider.primitive_ref(drawing).maybe_net()
|
||||
!= collidee.primitive_ref(drawing).maybe_net()
|
||||
} else {
|
||||
// Cane is non-initial.
|
||||
true
|
||||
|
|
@ -501,7 +501,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
// It makes no sense to wrap something around or under one of its connectables.
|
||||
//
|
||||
if let Some(net) = weight.maybe_net() {
|
||||
if let Some(around_net) = around.primitive(self).maybe_net() {
|
||||
if let Some(around_net) = around.primitive_ref(self).maybe_net() {
|
||||
if net == around_net {
|
||||
return Err(AlreadyConnected(net, around.into()).into());
|
||||
}
|
||||
|
|
@ -509,7 +509,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
//
|
||||
let mut outwards = around.ref_(self).outwards();
|
||||
while let Some(gear) = outwards.walk_next(self) {
|
||||
if let Some(next_gear_net) = gear.primitive(self).maybe_net() {
|
||||
if let Some(next_gear_net) = gear.primitive_ref(self).maybe_net() {
|
||||
if net == next_gear_net {
|
||||
return Err(AlreadyConnected(net, gear.into()).into());
|
||||
}
|
||||
|
|
@ -780,7 +780,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
filter(drawing, infringer, infringee)
|
||||
// Don't infringe upon limbs of the current wraparound.
|
||||
&& !PrimitiveIndex::from(around)
|
||||
.primitive(drawing)
|
||||
.primitive_ref(drawing)
|
||||
.limbs()
|
||||
.contains(&infringee)
|
||||
},
|
||||
|
|
@ -811,7 +811,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
#[cfg(debug_assertions)]
|
||||
use crate::geometry::shape::MeasureLength;
|
||||
#[cfg(debug_assertions)]
|
||||
approx::assert_abs_diff_eq!(bend.primitive(self).shape().length(), 0.0);
|
||||
approx::assert_abs_diff_eq!(bend.primitive_ref(self).shape().length(), 0.0);
|
||||
|
||||
Ok(Cane {
|
||||
seg,
|
||||
|
|
@ -897,7 +897,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
self.recording_geometry_with_rtree
|
||||
.move_dot(recorder, dot, to);
|
||||
|
||||
for limb in dot.primitive(self).limbs() {
|
||||
for limb in dot.primitive_ref(self).limbs() {
|
||||
if let Some(infringement) = self.find_infringement_except(limb, filter) {
|
||||
// Restore previous state.
|
||||
self.recording_geometry_with_rtree
|
||||
|
|
@ -1068,7 +1068,9 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
CW: super::graph::IsInLayer,
|
||||
{
|
||||
match index {
|
||||
GenericNode::Primitive(primitive) => primitive.primitive(self).layer() == active_layer,
|
||||
GenericNode::Primitive(primitive) => {
|
||||
primitive.primitive_ref(self).layer() == active_layer
|
||||
}
|
||||
GenericNode::Compound(compound) => {
|
||||
self.compound_weight(compound).is_in_layer(active_layer)
|
||||
}
|
||||
|
|
@ -1085,7 +1087,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
{
|
||||
match index {
|
||||
GenericNode::Primitive(primitive) => {
|
||||
primitive.primitive(self).is_in_any_layer_of(layers)
|
||||
primitive.primitive_ref(self).is_in_any_layer_of(layers)
|
||||
}
|
||||
GenericNode::Compound(compound) => {
|
||||
self.compound_weight(compound).is_in_any_layer_of(layers)
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ use crate::{
|
|||
drawing::{
|
||||
bend::{BendIndex, FixedBendIndex, LooseBendIndex},
|
||||
dot::FixedDotIndex,
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
primitive::{FixedBend, FixedDot, LooseBend, Primitive},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
primitive::{FixedBendRef, FixedDotRef, LooseBendRef, PrimitiveRef},
|
||||
rules::AccessRules,
|
||||
Drawing,
|
||||
},
|
||||
graph::{GetPetgraphIndex, MakeRef},
|
||||
};
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum GearIndex {
|
||||
FixedDot(FixedDotIndex),
|
||||
|
|
@ -55,9 +55,9 @@ impl From<BendIndex> for GearIndex {
|
|||
|
||||
#[enum_dispatch(GetOuterGears, WalkOutwards, GetDrawing, GetPetgraphIndex)]
|
||||
pub enum GearRef<'a, CW, Cel, R> {
|
||||
FixedDot(FixedDot<'a, CW, Cel, R>),
|
||||
FixedBend(FixedBend<'a, CW, Cel, R>),
|
||||
LooseBend(LooseBend<'a, CW, Cel, R>),
|
||||
FixedDot(FixedDotRef<'a, CW, Cel, R>),
|
||||
FixedBend(FixedBendRef<'a, CW, Cel, R>),
|
||||
LooseBend(LooseBendRef<'a, CW, Cel, R>),
|
||||
}
|
||||
|
||||
impl<'a, CW, Cel, R> GearRef<'a, CW, Cel, R> {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
use super::{
|
||||
bend::{FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
||||
dot::{FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
primitive::Primitive,
|
||||
primitive::PrimitiveRef,
|
||||
rules::AccessRules,
|
||||
seg::{
|
||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
||||
|
|
@ -46,11 +46,11 @@ pub trait GetMaybeNet {
|
|||
}
|
||||
|
||||
#[enum_dispatch]
|
||||
pub trait MakePrimitive {
|
||||
fn primitive<'a, CW: Clone, Cel: Copy, R: AccessRules>(
|
||||
pub trait MakePrimitiveRef {
|
||||
fn primitive_ref<'a, CW: Clone, Cel: Copy, R: AccessRules>(
|
||||
&self,
|
||||
drawing: &'a Drawing<CW, Cel, R>,
|
||||
) -> Primitive<'a, CW, Cel, R>;
|
||||
) -> PrimitiveRef<'a, CW, Cel, R>;
|
||||
}
|
||||
|
||||
macro_rules! impl_weight_forward {
|
||||
|
|
@ -75,12 +75,12 @@ macro_rules! impl_weight_forward {
|
|||
|
||||
pub type $index_struct = GenericIndex<$weight_struct>;
|
||||
|
||||
impl MakePrimitive for $index_struct {
|
||||
fn primitive<'a, CW: Clone, Cel: Copy, R: AccessRules>(
|
||||
impl MakePrimitiveRef for $index_struct {
|
||||
fn primitive_ref<'a, CW: Clone, Cel: Copy, R: AccessRules>(
|
||||
&self,
|
||||
drawing: &'a crate::drawing::Drawing<CW, Cel, R>,
|
||||
) -> Primitive<'a, CW, Cel, R> {
|
||||
Primitive::$weight_variant(GenericPrimitive::new(*self, drawing))
|
||||
) -> PrimitiveRef<'a, CW, Cel, R> {
|
||||
PrimitiveRef::$weight_variant(GenericPrimitive::new(*self, drawing))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -88,7 +88,7 @@ macro_rules! impl_weight_forward {
|
|||
|
||||
// TODO: This enum shouldn't exist: we shouldn't be carrying the tag around like this. Instead we
|
||||
// should be getting it from the graph when it's needed.
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub enum PrimitiveIndex {
|
||||
FixedDot(FixedDotIndex),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
use super::{
|
||||
bend::BendIndex,
|
||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
head::{BareHead, CaneHead, GetFace, Head},
|
||||
primitive::{GetCore, GetJoints, GetOtherJoint, GetWeight, MakePrimitiveShape},
|
||||
rules::{AccessRules, Conditions, GetConditions},
|
||||
|
|
@ -160,7 +160,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
width: f64,
|
||||
guide_conditions: Option<&Conditions<'_>>,
|
||||
) -> Circle {
|
||||
let shape = dot.primitive(self).shape();
|
||||
let shape = dot.primitive_ref(self).shape();
|
||||
Circle {
|
||||
pos: shape.center(),
|
||||
r: shape.width() / 2.0
|
||||
|
|
@ -175,7 +175,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
width: f64,
|
||||
guide_conditions: Option<&Conditions<'_>>,
|
||||
) -> Circle {
|
||||
let outer_circle = match bend.primitive(self).shape() {
|
||||
let outer_circle = match bend.primitive_ref(self).shape() {
|
||||
PrimitiveShape::Bend(shape) => shape.outer_circle(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
|
@ -189,7 +189,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
}
|
||||
|
||||
pub fn conditions(&self, node: PrimitiveIndex) -> Option<Conditions<'_>> {
|
||||
node.primitive(self).conditions()
|
||||
node.primitive_ref(self).conditions()
|
||||
}
|
||||
|
||||
fn clearance(&self, lhs: Option<&Conditions<'_>>, rhs: Option<&Conditions<'_>>) -> f64 {
|
||||
|
|
@ -202,7 +202,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
fn head_circle(&self, head: &Head, width: f64) -> Circle {
|
||||
match *head {
|
||||
Head::Bare(head) => Circle {
|
||||
pos: head.face().primitive(self).shape().center(), // TODO.
|
||||
pos: head.face().primitive_ref(self).shape().center(), // TODO.
|
||||
r: 0.0,
|
||||
},
|
||||
Head::Cane(head) => {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ use crate::{
|
|||
drawing::{
|
||||
bend::LooseBendIndex,
|
||||
dot::{DotIndex, LooseDotIndex},
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
primitive::{GetJoints, LoneLooseSeg, LooseBend, LooseDot, Primitive, SeqLooseSeg},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
primitive::{
|
||||
GetJoints, LoneLooseSegRef, LooseBendRef, LooseDotRef, PrimitiveRef, SeqLooseSegRef,
|
||||
},
|
||||
rules::AccessRules,
|
||||
seg::{LoneLooseSegIndex, SeqLooseSegIndex},
|
||||
},
|
||||
|
|
@ -36,7 +38,7 @@ pub trait GetPrevNextLoose {
|
|||
}
|
||||
}
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum LooseIndex {
|
||||
Dot(LooseDotIndex),
|
||||
|
|
@ -71,10 +73,10 @@ impl TryFrom<PrimitiveIndex> for LooseIndex {
|
|||
|
||||
#[enum_dispatch(GetPrevNextLoose, GetDrawing, GetPetgraphIndex)]
|
||||
pub enum Loose<'a, CW, Cel, R> {
|
||||
Dot(LooseDot<'a, CW, Cel, R>),
|
||||
LoneSeg(LoneLooseSeg<'a, CW, Cel, R>),
|
||||
SeqSeg(SeqLooseSeg<'a, CW, Cel, R>),
|
||||
Bend(LooseBend<'a, CW, Cel, R>),
|
||||
Dot(LooseDotRef<'a, CW, Cel, R>),
|
||||
LoneSeg(LoneLooseSegRef<'a, CW, Cel, R>),
|
||||
SeqSeg(SeqLooseSegRef<'a, CW, Cel, R>),
|
||||
Bend(LooseBendRef<'a, CW, Cel, R>),
|
||||
}
|
||||
|
||||
impl<'a, CW, Cel, R> Loose<'a, CW, Cel, R> {
|
||||
|
|
@ -88,7 +90,7 @@ impl<'a, CW, Cel, R> Loose<'a, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LooseDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LooseDotRef<'_, CW, Cel, R> {
|
||||
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
|
||||
let bend = self.bend();
|
||||
|
||||
|
|
@ -104,13 +106,13 @@ impl<CW, Cel, R> GetPrevNextLoose for LooseDot<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LoneLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LoneLooseSegRef<'_, CW, Cel, R> {
|
||||
fn next_loose(&self, _maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetPrevNextLoose for SeqLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetPrevNextLoose for SeqLooseSegRef<'_, CW, Cel, R> {
|
||||
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
|
||||
let joints = self.joints();
|
||||
let Some(prev) = maybe_prev else {
|
||||
|
|
@ -128,7 +130,7 @@ impl<CW, Cel, R> GetPrevNextLoose for SeqLooseSeg<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetPrevNextLoose for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
|
||||
let joints = self.joints();
|
||||
|
||||
|
|
|
|||
|
|
@ -119,11 +119,11 @@ impl<S: GetDrawing + GetBendIndex> GetCore for S {
|
|||
}
|
||||
|
||||
macro_rules! impl_primitive {
|
||||
($primitive_struct:ident, $weight_struct:ident) => {
|
||||
impl<CW, Cel, R> GetWeight for $primitive_struct<'_, CW, Cel, R> {
|
||||
($primitive_variant:ident, $primitive_refstruct:ident, $weight_struct:ident) => {
|
||||
impl<CW, Cel, R> GetWeight for $primitive_refstruct<'_, CW, Cel, R> {
|
||||
type Weight = $weight_struct;
|
||||
fn weight(&self) -> $weight_struct {
|
||||
if let PrimitiveWeight::$primitive_struct(weight) = self.tagged_weight() {
|
||||
if let PrimitiveWeight::$primitive_variant(weight) = self.tagged_weight() {
|
||||
weight
|
||||
} else {
|
||||
unreachable!()
|
||||
|
|
@ -131,13 +131,13 @@ macro_rules! impl_primitive {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLayer for $primitive_struct<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetLayer for $primitive_refstruct<'_, CW, Cel, R> {
|
||||
fn layer(&self) -> usize {
|
||||
self.weight().layer()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetMaybeNet for $primitive_struct<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetMaybeNet for $primitive_refstruct<'_, CW, Cel, R> {
|
||||
fn maybe_net(&self) -> Option<usize> {
|
||||
self.weight().maybe_net()
|
||||
}
|
||||
|
|
@ -146,14 +146,14 @@ macro_rules! impl_primitive {
|
|||
}
|
||||
|
||||
macro_rules! impl_fixed_primitive {
|
||||
($primitive_struct:ident, $weight_struct:ident) => {
|
||||
impl_primitive!($primitive_struct, $weight_struct);
|
||||
($primitive_variant:ident, $primitive_struct:ident, $weight_struct:ident) => {
|
||||
impl_primitive!($primitive_variant, $primitive_struct, $weight_struct);
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_loose_primitive {
|
||||
($primitive_struct:ident, $weight_struct:ident) => {
|
||||
impl_primitive!($primitive_struct, $weight_struct);
|
||||
($primitive_variant:ident, $primitive_struct:ident, $weight_struct:ident) => {
|
||||
impl_primitive!($primitive_variant, $primitive_struct, $weight_struct);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -165,26 +165,26 @@ macro_rules! impl_loose_primitive {
|
|||
MakePrimitiveShape,
|
||||
GetLimbs
|
||||
)]
|
||||
pub enum Primitive<'a, CW, Cel, R> {
|
||||
FixedDot(FixedDot<'a, CW, Cel, R>),
|
||||
LooseDot(LooseDot<'a, CW, Cel, R>),
|
||||
FixedSeg(FixedSeg<'a, CW, Cel, R>),
|
||||
LoneLooseSeg(LoneLooseSeg<'a, CW, Cel, R>),
|
||||
SeqLooseSeg(SeqLooseSeg<'a, CW, Cel, R>),
|
||||
FixedBend(FixedBend<'a, CW, Cel, R>),
|
||||
LooseBend(LooseBend<'a, CW, Cel, R>),
|
||||
pub enum PrimitiveRef<'a, CW, Cel, R> {
|
||||
FixedDot(FixedDotRef<'a, CW, Cel, R>),
|
||||
LooseDot(LooseDotRef<'a, CW, Cel, R>),
|
||||
FixedSeg(FixedSegRef<'a, CW, Cel, R>),
|
||||
LoneLooseSeg(LoneLooseSegRef<'a, CW, Cel, R>),
|
||||
SeqLooseSeg(SeqLooseSegRef<'a, CW, Cel, R>),
|
||||
FixedBend(FixedBendRef<'a, CW, Cel, R>),
|
||||
LooseBend(LooseBendRef<'a, CW, Cel, R>),
|
||||
}
|
||||
|
||||
impl<'a, CW, Cel, R: AccessRules> GetConditions<'a> for &Primitive<'a, CW, Cel, R> {
|
||||
impl<'a, CW, Cel, R: AccessRules> GetConditions<'a> for &PrimitiveRef<'a, CW, Cel, R> {
|
||||
fn conditions(self) -> Option<Conditions<'a>> {
|
||||
match self {
|
||||
Primitive::FixedDot(x) => x.conditions(),
|
||||
Primitive::LooseDot(x) => x.conditions(),
|
||||
Primitive::FixedSeg(x) => x.conditions(),
|
||||
Primitive::LoneLooseSeg(x) => x.conditions(),
|
||||
Primitive::SeqLooseSeg(x) => x.conditions(),
|
||||
Primitive::FixedBend(x) => x.conditions(),
|
||||
Primitive::LooseBend(x) => x.conditions(),
|
||||
PrimitiveRef::FixedDot(x) => x.conditions(),
|
||||
PrimitiveRef::LooseDot(x) => x.conditions(),
|
||||
PrimitiveRef::FixedSeg(x) => x.conditions(),
|
||||
PrimitiveRef::LoneLooseSeg(x) => x.conditions(),
|
||||
PrimitiveRef::SeqLooseSeg(x) => x.conditions(),
|
||||
PrimitiveRef::FixedBend(x) => x.conditions(),
|
||||
PrimitiveRef::LooseBend(x) => x.conditions(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -258,16 +258,16 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub type FixedDot<'a, CW, Cel, R> = GenericPrimitive<'a, FixedDotWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedDot, FixedDotWeight);
|
||||
pub type FixedDotRef<'a, CW, Cel, R> = GenericPrimitive<'a, FixedDotWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedDot, FixedDotRef, FixedDotWeight);
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedDotRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().dot_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for FixedDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetLimbs for FixedDotRef<'_, CW, Cel, R> {
|
||||
fn segs(&self) -> Vec<SegIndex> {
|
||||
self.drawing
|
||||
.geometry()
|
||||
|
|
@ -283,24 +283,24 @@ impl<CW, Cel, R> GetLimbs for FixedDot<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLowestGears for FixedDot<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLowestGears for FixedDotRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetOuterGears for FixedDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetOuterGears for FixedDotRef<'_, CW, Cel, R> {
|
||||
fn outer_gears(&self) -> Vec<LooseBendIndex> {
|
||||
self.lowest_gears()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> WalkOutwards for FixedDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> WalkOutwards for FixedDotRef<'_, CW, Cel, R> {
|
||||
fn outwards(&self) -> DrawingOutwardWalker {
|
||||
DrawingOutwardWalker::new(self.lowest_gears().into_iter())
|
||||
}
|
||||
}
|
||||
|
||||
pub type LooseDot<'a, CW, Cel, R> = GenericPrimitive<'a, LooseDotWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LooseDot, LooseDotWeight);
|
||||
pub type LooseDotRef<'a, CW, Cel, R> = GenericPrimitive<'a, LooseDotWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LooseDot, LooseDotRef, LooseDotWeight);
|
||||
|
||||
impl<CW, Cel, R> LooseDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> LooseDotRef<'_, CW, Cel, R> {
|
||||
pub fn seg(&self) -> Option<SeqLooseSegIndex> {
|
||||
self.drawing
|
||||
.geometry()
|
||||
|
|
@ -319,13 +319,13 @@ impl<CW, Cel, R> LooseDot<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LooseDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LooseDotRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().dot_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for LooseDot<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetLimbs for LooseDotRef<'_, CW, Cel, R> {
|
||||
fn segs(&self) -> Vec<SegIndex> {
|
||||
if let Some(seg) = self.seg() {
|
||||
vec![seg.into()]
|
||||
|
|
@ -339,18 +339,18 @@ impl<CW, Cel, R> GetLimbs for LooseDot<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type FixedSeg<'a, CW, Cel, R> = GenericPrimitive<'a, FixedSegWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedSeg, FixedSegWeight);
|
||||
pub type FixedSegRef<'a, CW, Cel, R> = GenericPrimitive<'a, FixedSegWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedSeg, FixedSegRef, FixedSegWeight);
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedSegRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().seg_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for FixedSeg<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLimbs for FixedSegRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetJoints for FixedSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetJoints for FixedSegRef<'_, CW, Cel, R> {
|
||||
type F = FixedDotIndex;
|
||||
type T = FixedDotIndex;
|
||||
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
|
||||
|
|
@ -362,18 +362,18 @@ impl<CW, Cel, R> GetJoints for FixedSeg<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type LoneLooseSeg<'a, CW, Cel, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight);
|
||||
pub type LoneLooseSegRef<'a, CW, Cel, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegRef, LoneLooseSegWeight);
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LoneLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LoneLooseSegRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().seg_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for LoneLooseSeg<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLimbs for LoneLooseSegRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetJoints for LoneLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetJoints for LoneLooseSegRef<'_, CW, Cel, R> {
|
||||
type F = FixedDotIndex;
|
||||
type T = FixedDotIndex;
|
||||
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
|
||||
|
|
@ -385,18 +385,18 @@ impl<CW, Cel, R> GetJoints for LoneLooseSeg<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type SeqLooseSeg<'a, CW, Cel, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight);
|
||||
pub type SeqLooseSegRef<'a, CW, Cel, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegRef, SeqLooseSegWeight);
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for SeqLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for SeqLooseSegRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().seg_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for SeqLooseSeg<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLimbs for SeqLooseSegRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetJoints for SeqLooseSeg<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetJoints for SeqLooseSegRef<'_, CW, Cel, R> {
|
||||
type F = DotIndex;
|
||||
type T = LooseDotIndex;
|
||||
fn joints(&self) -> (DotIndex, LooseDotIndex) {
|
||||
|
|
@ -420,24 +420,24 @@ impl<CW, Cel, R> GetJoints for SeqLooseSeg<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type FixedBend<'a, CW, Cel, R> = GenericPrimitive<'a, FixedBendWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedBend, FixedBendWeight);
|
||||
pub type FixedBendRef<'a, CW, Cel, R> = GenericPrimitive<'a, FixedBendWeight, CW, Cel, R>;
|
||||
impl_fixed_primitive!(FixedBend, FixedBendRef, FixedBendWeight);
|
||||
|
||||
impl<CW, Cel, R> GetBendIndex for FixedBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetBendIndex for FixedBendRef<'_, CW, Cel, R> {
|
||||
fn bend_index(&self) -> BendIndex {
|
||||
self.index.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for FixedBendRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().bend_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for FixedBend<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLimbs for FixedBendRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetJoints for FixedBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetJoints for FixedBendRef<'_, CW, Cel, R> {
|
||||
type F = FixedDotIndex;
|
||||
type T = FixedDotIndex;
|
||||
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
|
||||
|
|
@ -449,50 +449,50 @@ impl<CW, Cel, R> GetJoints for FixedBend<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLowestGears for FixedBend<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLowestGears for FixedBendRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetOuterGears for FixedBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetOuterGears for FixedBendRef<'_, CW, Cel, R> {
|
||||
fn outer_gears(&self) -> Vec<LooseBendIndex> {
|
||||
self.lowest_gears()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> WalkOutwards for FixedBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> WalkOutwards for FixedBendRef<'_, CW, Cel, R> {
|
||||
fn outwards(&self) -> DrawingOutwardWalker {
|
||||
DrawingOutwardWalker::new(self.lowest_gears().into_iter())
|
||||
}
|
||||
}
|
||||
|
||||
pub type LooseBend<'a, CW, Cel, R> = GenericPrimitive<'a, LooseBendWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LooseBend, LooseBendWeight);
|
||||
pub type LooseBendRef<'a, CW, Cel, R> = GenericPrimitive<'a, LooseBendWeight, CW, Cel, R>;
|
||||
impl_loose_primitive!(LooseBend, LooseBendRef, LooseBendWeight);
|
||||
|
||||
impl<CW, Cel, R> GetBendIndex for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetBendIndex for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn bend_index(&self) -> BendIndex {
|
||||
self.index.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, CW: Clone, Cel: Copy, R: AccessRules> From<LooseBend<'a, CW, Cel, R>> for BendIndex {
|
||||
fn from(bend: LooseBend<'a, CW, Cel, R>) -> BendIndex {
|
||||
impl<'a, CW: Clone, Cel: Copy, R: AccessRules> From<LooseBendRef<'a, CW, Cel, R>> for BendIndex {
|
||||
fn from(bend: LooseBendRef<'a, CW, Cel, R>) -> BendIndex {
|
||||
bend.index.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> MakePrimitiveShape for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn shape(&self) -> PrimitiveShape {
|
||||
self.drawing.geometry().bend_shape(self.index.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetLimbs for LooseBend<'_, CW, Cel, R> {}
|
||||
impl<CW, Cel, R> GetLimbs for LooseBendRef<'_, CW, Cel, R> {}
|
||||
|
||||
impl<CW, Cel, R> GetOffset for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetOffset for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn offset(&self) -> f64 {
|
||||
self.weight().offset()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetJoints for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetJoints for LooseBendRef<'_, CW, Cel, R> {
|
||||
type F = LooseDotIndex;
|
||||
type T = LooseDotIndex;
|
||||
fn joints(&self) -> (LooseDotIndex, LooseDotIndex) {
|
||||
|
|
@ -504,19 +504,19 @@ impl<CW, Cel, R> GetJoints for LooseBend<'_, CW, Cel, R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> GetOuterGears for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> GetOuterGears for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn outer_gears(&self) -> Vec<LooseBendIndex> {
|
||||
self.outers().collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> WalkOutwards for LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> WalkOutwards for LooseBendRef<'_, CW, Cel, R> {
|
||||
fn outwards(&self) -> DrawingOutwardWalker {
|
||||
DrawingOutwardWalker::new(self.outers())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CW, Cel, R> LooseBend<'_, CW, Cel, R> {
|
||||
impl<CW, Cel, R> LooseBendRef<'_, CW, Cel, R> {
|
||||
pub fn inner(&self) -> Option<LooseBendIndex> {
|
||||
self.drawing()
|
||||
.geometry()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use specctra_core::rules::GetConditions;
|
|||
|
||||
use crate::{
|
||||
drawing::{
|
||||
graph::{GetMaybeNet, MakePrimitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef},
|
||||
primitive::MakePrimitiveShape,
|
||||
Collision, Infringement,
|
||||
},
|
||||
|
|
@ -141,7 +141,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
})
|
||||
.filter_map(move |primitive_node| {
|
||||
limiting_shape
|
||||
.intersects(&primitive_node.primitive(self).shape())
|
||||
.intersects(&primitive_node.primitive_ref(self).shape())
|
||||
.then_some(primitive_node)
|
||||
})
|
||||
}
|
||||
|
|
@ -218,13 +218,13 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
intersector: PrimitiveIndex,
|
||||
it: impl Iterator<Item = PrimitiveIndex> + 'a,
|
||||
) -> impl Iterator<Item = Infringement> + 'a {
|
||||
let conditions = intersector.primitive(self).conditions();
|
||||
let conditions = intersector.primitive_ref(self).conditions();
|
||||
|
||||
it.filter_map(move |primitive_node| {
|
||||
let infringee_conditions = primitive_node.primitive(self).conditions();
|
||||
let infringee_conditions = primitive_node.primitive_ref(self).conditions();
|
||||
|
||||
let epsilon = 1.0;
|
||||
let inflated_shape = intersector.primitive(self).shape().inflate(
|
||||
let inflated_shape = intersector.primitive_ref(self).shape().inflate(
|
||||
match (&conditions, infringee_conditions) {
|
||||
(None, _) | (_, None) => 0.0,
|
||||
(Some(lhs), Some(rhs)) => {
|
||||
|
|
@ -237,7 +237,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
);
|
||||
|
||||
inflated_shape
|
||||
.intersects(&primitive_node.primitive(self).shape())
|
||||
.intersects(&primitive_node.primitive_ref(self).shape())
|
||||
.then_some(Infringement(inflated_shape, primitive_node))
|
||||
})
|
||||
}
|
||||
|
|
@ -246,8 +246,8 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
&self,
|
||||
node: PrimitiveIndex,
|
||||
) -> impl Iterator<Item = GenericNode<PrimitiveIndex, GenericIndex<CW>>> + '_ {
|
||||
let limiting_shape = node.primitive(self).shape().inflate(
|
||||
node.primitive(self)
|
||||
let limiting_shape = node.primitive_ref(self).shape().inflate(
|
||||
node.primitive_ref(self)
|
||||
.maybe_net()
|
||||
.map(|net| self.rules().largest_clearance(Some(net)))
|
||||
.unwrap_or(0.0),
|
||||
|
|
@ -256,7 +256,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
self.recording_geometry_with_rtree()
|
||||
.rtree()
|
||||
.locate_in_envelope_intersecting(
|
||||
&limiting_shape.envelope_3d(0.0, node.primitive(self).layer()),
|
||||
&limiting_shape.envelope_3d(0.0, node.primitive_ref(self).layer()),
|
||||
)
|
||||
.map(|wrapper| wrapper.data)
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
collider: PrimitiveIndex,
|
||||
predicate: &impl Fn(&Self, PrimitiveIndex, PrimitiveIndex) -> bool,
|
||||
) -> Option<Collision> {
|
||||
let shape = collider.primitive(self).shape();
|
||||
let shape = collider.primitive_ref(self).shape();
|
||||
|
||||
self.recording_geometry_with_rtree()
|
||||
.rtree()
|
||||
|
|
@ -290,14 +290,14 @@ impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
|
|||
|| matches!(collidee, PrimitiveIndex::SeqLooseSeg(..))))
|
||||
})
|
||||
.filter(|collidee| predicate(&self, collider, *collidee))
|
||||
.find(|collidee| shape.intersects(&collidee.primitive(self).shape()))
|
||||
.find(|collidee| shape.intersects(&collidee.primitive_ref(self).shape()))
|
||||
.map(|collidee| Collision(shape, collidee))
|
||||
}
|
||||
|
||||
fn are_connectable(&self, node1: PrimitiveIndex, node2: PrimitiveIndex) -> bool {
|
||||
if let (Some(node1_net), Some(node2_net)) = (
|
||||
node1.primitive(self).maybe_net(),
|
||||
node2.primitive(self).maybe_net(),
|
||||
node1.primitive_ref(self).maybe_net(),
|
||||
node2.primitive_ref(self).maybe_net(),
|
||||
) {
|
||||
node1_net == node2_net
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use enum_dispatch::enum_dispatch;
|
|||
|
||||
use crate::{
|
||||
drawing::{
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex, PrimitiveWeight},
|
||||
loose::LooseIndex,
|
||||
primitive::{GenericPrimitive, Primitive},
|
||||
primitive::{GenericPrimitive, PrimitiveRef},
|
||||
rules::AccessRules,
|
||||
Drawing,
|
||||
},
|
||||
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
|
||||
use petgraph::stable_graph::NodeIndex;
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
|
||||
pub enum SegIndex {
|
||||
Fixed(FixedSegIndex),
|
||||
|
|
@ -26,7 +26,7 @@ pub enum SegIndex {
|
|||
SeqLoose(SeqLooseSegIndex),
|
||||
}
|
||||
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitive)]
|
||||
#[enum_dispatch(GetPetgraphIndex, MakePrimitiveRef)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
|
||||
pub enum LooseSegIndex {
|
||||
Lone(LoneLooseSegIndex),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
bend::{BendWeight, FixedBendWeight, LooseBendWeight},
|
||||
dot::{DotWeight, FixedDotWeight, LooseDotWeight},
|
||||
graph::PrimitiveWeight,
|
||||
primitive::Primitive,
|
||||
primitive::PrimitiveRef,
|
||||
seg::{FixedSegWeight, LoneLooseSegWeight, SegWeight, SeqLooseSegWeight},
|
||||
},
|
||||
geometry::{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandUid,
|
||||
dot::DotIndex,
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
loose::LooseIndex,
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
|
|
@ -70,7 +70,7 @@ impl<R: AccessRules> Layout<R> {
|
|||
})
|
||||
.map(|loose| {
|
||||
let prim: PrimitiveIndex = loose.into();
|
||||
let shape = prim.primitive(&self.drawing).shape();
|
||||
let shape = prim.primitive_ref(&self.drawing).shape();
|
||||
(loose, shape)
|
||||
})
|
||||
.filter_map(move |(loose, shape)| {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
LooseDotWeight,
|
||||
},
|
||||
gear::GearIndex,
|
||||
graph::{GetMaybeNet, IsInLayer, MakePrimitive, PrimitiveIndex, PrimitiveWeight},
|
||||
graph::{GetMaybeNet, IsInLayer, MakePrimitiveRef, PrimitiveIndex, PrimitiveWeight},
|
||||
primitive::{GetLimbs, MakePrimitiveShape},
|
||||
rules::AccessRules,
|
||||
seg::{
|
||||
|
|
@ -98,7 +98,7 @@ impl<R: AccessRules> Layout<R> {
|
|||
.overlapees(around.into())
|
||||
.find(|overlapee| {
|
||||
PrimitiveIndex::from(overlapee.1)
|
||||
.primitive(drawing)
|
||||
.primitive_ref(drawing)
|
||||
.limbs()
|
||||
.contains(&infringee)
|
||||
})
|
||||
|
|
@ -340,7 +340,9 @@ impl<R: AccessRules> Layout<R> {
|
|||
|
||||
pub fn node_shape(&self, index: NodeIndex) -> Shape {
|
||||
match index {
|
||||
NodeIndex::Primitive(primitive) => primitive.primitive(&self.drawing).shape().into(),
|
||||
NodeIndex::Primitive(primitive) => {
|
||||
primitive.primitive_ref(&self.drawing).shape().into()
|
||||
}
|
||||
NodeIndex::Compound(compound) => self.compound_shape(compound),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
bend::{BendIndex, GeneralBendWeight, LooseBendWeight},
|
||||
dot::{DotIndex, FixedDotIndex, GeneralDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
gear::GearIndex,
|
||||
graph::{GetMaybeNet, MakePrimitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef},
|
||||
head::{CaneHead, GetFace, Head},
|
||||
primitive::GetOtherJoint,
|
||||
rules::AccessRules,
|
||||
|
|
@ -89,7 +89,7 @@ impl<R: AccessRules> Draw for Layout<R> {
|
|||
.map_err(Into::<DrawException>::into)?;
|
||||
|
||||
let (layer, maybe_net) = {
|
||||
let face = head.face().primitive(self.drawing());
|
||||
let face = head.face().primitive_ref(self.drawing());
|
||||
(face.layer(), face.maybe_net())
|
||||
};
|
||||
|
||||
|
|
@ -287,8 +287,8 @@ impl<R: AccessRules> DrawPrivate for Layout<R> {
|
|||
width: f64,
|
||||
offset: f64,
|
||||
) -> Result<CaneHead, DrawingException> {
|
||||
let layer = head.face().primitive(self.drawing()).layer();
|
||||
let maybe_net = head.face().primitive(self.drawing()).maybe_net();
|
||||
let layer = head.face().primitive_ref(self.drawing()).layer();
|
||||
let maybe_net = head.face().primitive_ref(self.drawing()).maybe_net();
|
||||
|
||||
let dot_weight = LooseDotWeight(GeneralDotWeight {
|
||||
circle: Circle {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandTermsegIndex,
|
||||
dot::FixedDotIndex,
|
||||
graph::MakePrimitive,
|
||||
graph::MakePrimitiveRef,
|
||||
head::{BareHead, CaneHead, Head},
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
|
|
@ -121,7 +121,10 @@ impl Navcord {
|
|||
let final_termseg = layout.finish(navmesh, self, to_dot)?;
|
||||
self.maybe_final_termseg = Some(final_termseg);
|
||||
|
||||
let final_termseg_length = final_termseg.primitive(layout.drawing()).shape().length();
|
||||
let final_termseg_length = final_termseg
|
||||
.primitive_ref(layout.drawing())
|
||||
.shape()
|
||||
.length();
|
||||
|
||||
let bend_length = match self.head {
|
||||
Head::Cane(old_cane_head) => layout
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ use crate::{
|
|||
bend::{FixedBendIndex, LooseBendIndex},
|
||||
dot::FixedDotIndex,
|
||||
gear::{GearIndex, GetOuterGears, WalkOutwards},
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
primitive::Primitive,
|
||||
graph::PrimitiveIndex,
|
||||
rules::AccessRules,
|
||||
Drawing,
|
||||
},
|
||||
graph::{GenericIndex, GetPetgraphIndex, MakeRef},
|
||||
layout::{CompoundEntryLabel, Layout},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandUid,
|
||||
dot::FixedDotIndex,
|
||||
graph::MakePrimitive as _,
|
||||
graph::MakePrimitiveRef as _,
|
||||
head::{BareHead, GetFace as _, Head},
|
||||
primitive::MakePrimitiveShape as _,
|
||||
rules::AccessRules,
|
||||
|
|
@ -130,7 +130,7 @@ impl AstarContext {
|
|||
let mut length = ctx.length;
|
||||
if let Some(old_poly) = sub.polygon.take() {
|
||||
if prim != old_poly.apex {
|
||||
let destination = prim.primitive(layout.drawing()).shape().center();
|
||||
let destination = prim.primitive_ref(layout.drawing()).shape().center();
|
||||
let exit = old_poly.entry_point(destination, true)?;
|
||||
let (new_head, length_delta) = old_poly.route_to_exit(
|
||||
&mut layout,
|
||||
|
|
@ -153,10 +153,10 @@ impl AstarContext {
|
|||
length += sub
|
||||
.active_head
|
||||
.maybe_cane()
|
||||
.map(|cane| cane.bend.primitive(layout.drawing()).shape().length())
|
||||
.map(|cane| cane.bend.primitive_ref(layout.drawing()).shape().length())
|
||||
.unwrap_or(0.0);
|
||||
length += {
|
||||
match fin.primitive(layout.drawing()).shape() {
|
||||
match fin.primitive_ref(layout.drawing()).shape() {
|
||||
PrimitiveShape::Dot(_) => unreachable!(),
|
||||
PrimitiveShape::Seg(seg) => seg.length(),
|
||||
PrimitiveShape::Bend(bend) => bend.length(),
|
||||
|
|
@ -224,8 +224,8 @@ impl AstarContext {
|
|||
(Some(lhs), Some(rhs)) => Some(FloatingRouting::new(
|
||||
&layout,
|
||||
sub.active_head.face(),
|
||||
lhs.primitive(&layout.drawing()).shape().center(),
|
||||
rhs.primitive(&layout.drawing()).shape().center(),
|
||||
lhs.primitive_ref(&layout.drawing()).shape().center(),
|
||||
rhs.primitive_ref(&layout.drawing()).shape().center(),
|
||||
)),
|
||||
_ => None,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use geo::Point;
|
|||
use crate::{
|
||||
drawing::{
|
||||
dot::DotIndex,
|
||||
graph::MakePrimitive as _,
|
||||
primitive::{GetWeight as _, Primitive},
|
||||
graph::MakePrimitiveRef as _,
|
||||
primitive::{GetWeight as _, PrimitiveRef},
|
||||
rules::AccessRules,
|
||||
},
|
||||
geometry::GetSetPos as _,
|
||||
|
|
@ -35,9 +35,9 @@ impl FloatingRouting {
|
|||
lhs: Point,
|
||||
rhs: Point,
|
||||
) -> Self {
|
||||
let active_head_pos = match active_head_face.primitive(layout.drawing()) {
|
||||
Primitive::FixedDot(dot) => dot.weight().0,
|
||||
Primitive::LooseDot(dot) => dot.weight().0,
|
||||
let active_head_pos = match active_head_face.primitive_ref(layout.drawing()) {
|
||||
PrimitiveRef::FixedDot(dot) => dot.weight().0,
|
||||
PrimitiveRef::LooseDot(dot) => dot.weight().0,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
.pos();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use crate::{
|
|||
band::BandUid,
|
||||
bend::BendIndex,
|
||||
dot::{DotIndex, FixedDotIndex},
|
||||
graph::{MakePrimitive as _, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef as _, PrimitiveIndex},
|
||||
head::{CaneHead, GetFace as _, Head},
|
||||
primitive::MakePrimitiveShape as _,
|
||||
rules::AccessRules,
|
||||
|
|
@ -548,7 +548,7 @@ impl SubContext {
|
|||
fn head_center<R: AccessRules>(&self, layout: &Layout<R>) -> Point {
|
||||
self.active_head
|
||||
.face()
|
||||
.primitive(layout.drawing())
|
||||
.primitive_ref(layout.drawing())
|
||||
.shape()
|
||||
.center()
|
||||
}
|
||||
|
|
@ -610,10 +610,15 @@ fn cane_around<R: AccessRules>(
|
|||
}
|
||||
}?;
|
||||
// record the length of the current seg, and the old bend, if any
|
||||
*route_length += ret.cane.seg.primitive(layout.drawing()).shape().length()
|
||||
*route_length += ret
|
||||
.cane
|
||||
.seg
|
||||
.primitive_ref(layout.drawing())
|
||||
.shape()
|
||||
.length()
|
||||
+ old_head
|
||||
.maybe_cane()
|
||||
.map(|cane| cane.bend.primitive(layout.drawing()).shape().length())
|
||||
.map(|cane| cane.bend.primitive_ref(layout.drawing()).shape().length())
|
||||
.unwrap_or(0.0);
|
||||
Ok(ret)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandUid,
|
||||
dot::FixedDotIndex,
|
||||
graph::{MakePrimitive as _, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef as _, PrimitiveIndex},
|
||||
head::{CaneHead, Head},
|
||||
primitive::MakePrimitiveShape as _,
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ impl PolygonRouting {
|
|||
}
|
||||
|
||||
pub fn center<R: AccessRules>(&self, layout: &Layout<R>) -> Point {
|
||||
self.apex.primitive(layout.drawing()).shape().center()
|
||||
self.apex.primitive_ref(layout.drawing()).shape().center()
|
||||
}
|
||||
|
||||
/// calculate the entry or exit point for the polygon (set `invert_cw` to `true` for exit point)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ use crate::{
|
|||
drawing::{
|
||||
bend::FixedBendIndex,
|
||||
dot::{DotIndex, FixedDotIndex},
|
||||
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex},
|
||||
primitive::{GetCore, GetJoints, MakePrimitiveShape, Primitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex},
|
||||
primitive::{GetCore, GetJoints, MakePrimitiveShape},
|
||||
rules::AccessRules,
|
||||
seg::{FixedSegIndex, LoneLooseSegIndex, SeqLooseSegIndex},
|
||||
Drawing,
|
||||
},
|
||||
geometry::{shape::AccessShape, GetLayer},
|
||||
graph::{GenericIndex, GetPetgraphIndex},
|
||||
|
|
@ -68,14 +67,14 @@ impl PrenavmeshWeight {
|
|||
pub fn new_from_fixed_dot(layout: &Layout<impl AccessRules>, dot: FixedDotIndex) -> Self {
|
||||
Self {
|
||||
node: dot.into(),
|
||||
pos: dot.primitive(layout.drawing()).shape().center(),
|
||||
pos: dot.primitive_ref(layout.drawing()).shape().center(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_fixed_bend(layout: &Layout<impl AccessRules>, bend: FixedBendIndex) -> Self {
|
||||
Self {
|
||||
node: bend.into(),
|
||||
pos: bend.primitive(layout.drawing()).shape().center(),
|
||||
pos: bend.primitive_ref(layout.drawing()).shape().center(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,7 +150,7 @@ impl Prenavmesh {
|
|||
let maybe_net = layout.drawing().primitive(origin).maybe_net();
|
||||
|
||||
for node in layout.drawing().layer_primitive_nodes(layer) {
|
||||
let primitive = node.primitive(layout.drawing());
|
||||
let primitive = node.primitive_ref(layout.drawing());
|
||||
|
||||
let Some(primitive_net) = primitive.maybe_net() else {
|
||||
continue;
|
||||
|
|
@ -203,7 +202,7 @@ impl Prenavmesh {
|
|||
}
|
||||
|
||||
for node in layout.drawing().layer_primitive_nodes(layer) {
|
||||
let primitive = node.primitive(layout.drawing());
|
||||
let primitive = node.primitive_ref(layout.drawing());
|
||||
|
||||
let Some(primitive_net) = primitive.maybe_net() else {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
drawing::{
|
||||
band::BandTermsegIndex,
|
||||
dot::FixedDotIndex,
|
||||
graph::{MakePrimitive, PrimitiveIndex},
|
||||
graph::{MakePrimitiveRef, PrimitiveIndex},
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
},
|
||||
|
|
@ -182,7 +182,7 @@ impl<R: AccessRules> ThetastarStrategy<Navmesh, f64, BandTermsegIndex>
|
|||
|
||||
fn estimate_cost_to_goal(&mut self, navmesh: &Navmesh, vertex: NavnodeIndex) -> f64 {
|
||||
let start_point = PrimitiveIndex::from(navmesh.node_weight(vertex).unwrap().binavnode)
|
||||
.primitive(self.layout.drawing())
|
||||
.primitive_ref(self.layout.drawing())
|
||||
.shape()
|
||||
.center();
|
||||
let end_point = self
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
board::{edit::BoardEdit, AccessMesadata, Board},
|
||||
drawing::{
|
||||
dot::{FixedDotIndex, FixedDotWeight, GeneralDotWeight},
|
||||
graph::{GetMaybeNet, MakePrimitive},
|
||||
graph::{GetMaybeNet, MakePrimitiveRef},
|
||||
primitive::MakePrimitiveShape,
|
||||
seg::{FixedSegWeight, GeneralSegWeight},
|
||||
Drawing,
|
||||
|
|
@ -78,7 +78,7 @@ impl SpecctraDesign {
|
|||
|
||||
let mut net_outs = BTreeMap::<usize, structure::NetOut>::new();
|
||||
for index in drawing.primitive_nodes() {
|
||||
let primitive = index.primitive(drawing);
|
||||
let primitive = index.primitive_ref(drawing);
|
||||
|
||||
if let Some(net) = primitive.maybe_net() {
|
||||
let coords = match primitive.shape() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue