geometry: rename `Shape*` to `PrimitiveShape*`

This commit is contained in:
Mikolaj Wielgus 2024-04-10 01:34:18 +00:00
parent 2d5998547a
commit 6932a698f6
13 changed files with 74 additions and 70 deletions

View File

@ -7,7 +7,7 @@ use std::{
use topola::{ use topola::{
drawing::{graph::MakePrimitive, primitive::MakeShape, zone::MakePolygon, Drawing}, drawing::{graph::MakePrimitive, primitive::MakeShape, zone::MakePolygon, Drawing},
dsn::{design::DsnDesign, rules::DsnRules}, dsn::{design::DsnDesign, rules::DsnRules},
geometry::shape::{BendShape, DotShape, SegShape, Shape}, geometry::primitive::{BendShape, DotShape, PrimitiveShape, SegShape},
math::Circle, math::Circle,
}; };

View File

@ -1,6 +1,6 @@
use egui::{emath::RectTransform, epaint, Color32, Pos2, Stroke, Ui}; use egui::{emath::RectTransform, epaint, Color32, Pos2, Stroke, Ui};
use geo::{CoordsIter, Point, Polygon}; use geo::{CoordsIter, Point, Polygon};
use topola::geometry::shape::Shape; use topola::geometry::primitive::PrimitiveShape;
pub struct Painter<'a> { pub struct Painter<'a> {
ui: &'a mut Ui, ui: &'a mut Ui,
@ -12,15 +12,15 @@ impl<'a> Painter<'a> {
Self { ui, transform } Self { ui, transform }
} }
pub fn paint_shape(&mut self, shape: &Shape, color: Color32) { pub fn paint_shape(&mut self, shape: &PrimitiveShape, color: Color32) {
let epaint_shape = match shape { let epaint_shape = match shape {
Shape::Dot(dot) => epaint::Shape::circle_filled( PrimitiveShape::Dot(dot) => epaint::Shape::circle_filled(
self.transform self.transform
.transform_pos([dot.c.pos.x() as f32, -dot.c.pos.y() as f32].into()), .transform_pos([dot.c.pos.x() as f32, -dot.c.pos.y() as f32].into()),
dot.c.r as f32 * self.transform.scale().x, dot.c.r as f32 * self.transform.scale().x,
color, color,
), ),
Shape::Seg(seg) => epaint::Shape::line_segment( PrimitiveShape::Seg(seg) => epaint::Shape::line_segment(
[ [
self.transform self.transform
.transform_pos([seg.from.x() as f32, -seg.from.y() as f32].into()), .transform_pos([seg.from.x() as f32, -seg.from.y() as f32].into()),
@ -29,7 +29,7 @@ impl<'a> Painter<'a> {
], ],
Stroke::new(seg.width as f32 * self.transform.scale().x, color), Stroke::new(seg.width as f32 * self.transform.scale().x, color),
), ),
Shape::Bend(bend) => { PrimitiveShape::Bend(bend) => {
let delta_from = bend.from - bend.c.pos; let delta_from = bend.from - bend.c.pos;
let delta_to = bend.to - bend.c.pos; let delta_to = bend.to - bend.c.pos;

View File

@ -21,7 +21,7 @@ use topola::drawing::seg::FixedSegWeight;
use topola::drawing::zone::MakePolygon; use topola::drawing::zone::MakePolygon;
use topola::drawing::{Drawing, Infringement, LayoutException}; use topola::drawing::{Drawing, Infringement, LayoutException};
use topola::dsn::design::DsnDesign; use topola::dsn::design::DsnDesign;
use topola::geometry::shape::{Shape, ShapeTrait}; use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
use topola::layout::connectivity::BandIndex; use topola::layout::connectivity::BandIndex;
use topola::layout::Layout; use topola::layout::Layout;
use topola::mesh::{Mesh, MeshEdgeReference, VertexIndex}; use topola::mesh::{Mesh, MeshEdgeReference, VertexIndex};
@ -326,7 +326,7 @@ fn render_times(
maybe_band: Option<BandIndex>, maybe_band: Option<BandIndex>,
mut maybe_mesh: Option<Mesh>, mut maybe_mesh: Option<Mesh>,
path: &[VertexIndex], path: &[VertexIndex],
ghosts: &[Shape], ghosts: &[PrimitiveShape],
highlighteds: &[PrimitiveIndex], highlighteds: &[PrimitiveIndex],
times: i64, times: i64,
) { ) {

View File

@ -2,7 +2,7 @@ use geo::{CoordsIter, Point, Polygon};
use pathfinder_canvas::{ use pathfinder_canvas::{
vec2f, ArcDirection, Canvas, CanvasRenderingContext2D, ColorU, FillRule, Path2D, RectF, vec2f, ArcDirection, Canvas, CanvasRenderingContext2D, ColorU, FillRule, Path2D, RectF,
}; };
use topola::geometry::shape::{Shape, ShapeTrait}; use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
pub struct Painter<'a> { pub struct Painter<'a> {
canvas: &'a mut CanvasRenderingContext2D, canvas: &'a mut CanvasRenderingContext2D,
@ -13,12 +13,12 @@ impl<'a> Painter<'a> {
Self { canvas } Self { canvas }
} }
pub fn paint_shape(&mut self, shape: &Shape, color: ColorU, zoom: f32) { pub fn paint_shape(&mut self, shape: &PrimitiveShape, color: ColorU, zoom: f32) {
self.canvas.set_stroke_style(color); self.canvas.set_stroke_style(color);
self.canvas.set_fill_style(color); self.canvas.set_fill_style(color);
match shape { match shape {
Shape::Dot(dot) => { PrimitiveShape::Dot(dot) => {
let mut path = Path2D::new(); let mut path = Path2D::new();
path.ellipse( path.ellipse(
vec2f(dot.c.pos.x() as f32, -dot.c.pos.y() as f32), vec2f(dot.c.pos.x() as f32, -dot.c.pos.y() as f32),
@ -29,14 +29,14 @@ impl<'a> Painter<'a> {
); );
self.canvas.fill_path(path, FillRule::Winding); self.canvas.fill_path(path, FillRule::Winding);
} }
Shape::Seg(seg) => { PrimitiveShape::Seg(seg) => {
let mut path = Path2D::new(); let mut path = Path2D::new();
path.move_to(vec2f(seg.from.x() as f32, -seg.from.y() as f32)); path.move_to(vec2f(seg.from.x() as f32, -seg.from.y() as f32));
path.line_to(vec2f(seg.to.x() as f32, -seg.to.y() as f32)); path.line_to(vec2f(seg.to.x() as f32, -seg.to.y() as f32));
self.canvas.set_line_width(seg.width as f32); self.canvas.set_line_width(seg.width as f32);
self.canvas.stroke_path(path); self.canvas.stroke_path(path);
} }
Shape::Bend(bend) => { PrimitiveShape::Bend(bend) => {
let delta1 = bend.from - bend.c.pos; let delta1 = bend.from - bend.c.pos;
let delta2 = bend.to - bend.c.pos; let delta2 = bend.to - bend.c.pos;
@ -56,7 +56,7 @@ impl<'a> Painter<'a> {
} }
} }
let envelope = ShapeTrait::envelope(shape, 0.0); let envelope = PrimitiveShapeTrait::envelope(shape, 0.0);
// XXX: points represented as arrays can't be conveniently converted to vector types // XXX: points represented as arrays can't be conveniently converted to vector types
let topleft = vec2f(envelope.lower()[0] as f32, -envelope.lower()[1] as f32); let topleft = vec2f(envelope.lower()[0] as f32, -envelope.lower()[1] as f32);
let bottomright = vec2f(envelope.upper()[0] as f32, -envelope.upper()[1] as f32); let bottomright = vec2f(envelope.upper()[0] as f32, -envelope.upper()[1] as f32);

View File

@ -30,7 +30,7 @@ use crate::drawing::{
}; };
use crate::geometry::Node; use crate::geometry::Node;
use crate::geometry::{ use crate::geometry::{
shape::{Shape, ShapeTrait}, primitive::{PrimitiveShape, PrimitiveShapeTrait},
with_rtree::GeometryWithRtree, with_rtree::GeometryWithRtree,
BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetOffset, GetPos, GetWidth, BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetOffset, GetPos, GetWidth,
SegWeightTrait, SegWeightTrait,
@ -58,11 +58,11 @@ pub enum LayoutException {
// TODO add real error messages + these should eventually use Display // TODO add real error messages + these should eventually use Display
#[derive(Error, Debug, Clone, Copy)] #[derive(Error, Debug, Clone, Copy)]
#[error("{0:?} infringes on {1:?}")] #[error("{0:?} infringes on {1:?}")]
pub struct Infringement(pub Shape, pub PrimitiveIndex); pub struct Infringement(pub PrimitiveShape, pub PrimitiveIndex);
#[derive(Error, Debug, Clone, Copy)] #[derive(Error, Debug, Clone, Copy)]
#[error("{0:?} collides with {1:?}")] #[error("{0:?} collides with {1:?}")]
pub struct Collision(pub Shape, pub PrimitiveIndex); pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
#[derive(Error, Debug, Clone, Copy)] #[derive(Error, Debug, Clone, Copy)]
#[error("{1:?} is already connected to net {0}")] #[error("{1:?} is already connected to net {0}")]

View File

@ -10,7 +10,7 @@ use crate::{
rules::GetConditions, rules::GetConditions,
Drawing, Drawing,
}, },
geometry::shape::{Shape, ShapeTrait}, geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait},
math::{self, Circle, NoTangents}, math::{self, Circle, NoTangents},
}; };
@ -189,7 +189,7 @@ impl<'a, R: RulesTrait> Guide<'a, R> {
fn bend_circle(&self, bend: BendIndex, width: f64, guide_conditions: &Conditions) -> Circle { fn bend_circle(&self, bend: BendIndex, width: f64, guide_conditions: &Conditions) -> Circle {
let outer_circle = match bend.primitive(self.drawing).shape() { let outer_circle = match bend.primitive(self.drawing).shape() {
Shape::Bend(shape) => shape.outer_circle(), PrimitiveShape::Bend(shape) => shape.outer_circle(),
_ => unreachable!(), _ => unreachable!(),
}; };

View File

@ -2,7 +2,7 @@ use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::NodeIndex; use petgraph::stable_graph::NodeIndex;
use crate::geometry::{ use crate::geometry::{
shape::{Shape, ShapeTrait}, primitive::{PrimitiveShape, PrimitiveShapeTrait},
GetOffset, GetWidth, GetOffset, GetWidth,
}; };
use crate::graph::{GenericIndex, GetNodeIndex}; use crate::graph::{GenericIndex, GetNodeIndex};
@ -35,7 +35,7 @@ pub trait GetWeight<W> {
#[enum_dispatch] #[enum_dispatch]
pub trait MakeShape { pub trait MakeShape {
fn shape(&self) -> Shape; fn shape(&self) -> PrimitiveShape;
} }
#[enum_dispatch] #[enum_dispatch]
@ -270,7 +270,7 @@ impl<'a, R: RulesTrait> FixedDot<'a, R> {
} }
impl<'a, R: RulesTrait> MakeShape for FixedDot<'a, R> { impl<'a, R: RulesTrait> MakeShape for FixedDot<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) self.drawing.geometry().dot_shape(self.index.into())
} }
} }
@ -316,7 +316,7 @@ impl<'a, R: RulesTrait> LooseDot<'a, R> {
} }
impl<'a, R: RulesTrait> MakeShape for LooseDot<'a, R> { impl<'a, R: RulesTrait> MakeShape for LooseDot<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) self.drawing.geometry().dot_shape(self.index.into())
} }
} }
@ -339,7 +339,7 @@ pub type FixedSeg<'a, R> = GenericPrimitive<'a, FixedSegWeight, R>;
impl_fixed_primitive!(FixedSeg, FixedSegWeight); impl_fixed_primitive!(FixedSeg, FixedSegWeight);
impl<'a, R: RulesTrait> MakeShape for FixedSeg<'a, R> { impl<'a, R: RulesTrait> MakeShape for FixedSeg<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
@ -362,7 +362,7 @@ pub type LoneLooseSeg<'a, R> = GenericPrimitive<'a, LoneLooseSegWeight, R>;
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight); impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight);
impl<'a, R: RulesTrait> MakeShape for LoneLooseSeg<'a, R> { impl<'a, R: RulesTrait> MakeShape for LoneLooseSeg<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
@ -385,7 +385,7 @@ pub type SeqLooseSeg<'a, R> = GenericPrimitive<'a, SeqLooseSegWeight, R>;
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight); impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight);
impl<'a, R: RulesTrait> MakeShape for SeqLooseSeg<'a, R> { impl<'a, R: RulesTrait> MakeShape for SeqLooseSeg<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
@ -426,7 +426,7 @@ impl<'a, R: RulesTrait> GetBendIndex for FixedBend<'a, R> {
} }
impl<'a, R: RulesTrait> MakeShape for FixedBend<'a, R> { impl<'a, R: RulesTrait> MakeShape for FixedBend<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) self.drawing.geometry().bend_shape(self.index.into())
} }
} }
@ -464,7 +464,7 @@ impl<'a, R: RulesTrait> From<LooseBend<'a, R>> for BendIndex {
} }
impl<'a, R: RulesTrait> MakeShape for LooseBend<'a, R> { impl<'a, R: RulesTrait> MakeShape for LooseBend<'a, R> {
fn shape(&self) -> Shape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) self.drawing.geometry().bend_shape(self.index.into())
} }
} }

View File

@ -17,7 +17,7 @@ use crate::{
rules::RulesTrait, rules::RulesTrait,
seg::{FixedSegWeight, LoneLooseSegWeight, SegWeight, SeqLooseSegWeight}, seg::{FixedSegWeight, LoneLooseSegWeight, SegWeight, SeqLooseSegWeight},
}, },
geometry::shape::{BendShape, DotShape, SegShape, Shape}, geometry::primitive::{BendShape, DotShape, PrimitiveShape, SegShape},
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
math::Circle, math::Circle,
}; };
@ -234,9 +234,9 @@ impl<
} }
} }
pub fn dot_shape(&self, dot: DI) -> Shape { pub fn dot_shape(&self, dot: DI) -> PrimitiveShape {
let weight = self.dot_weight(dot); let weight = self.dot_weight(dot);
Shape::Dot(DotShape { PrimitiveShape::Dot(DotShape {
c: Circle { c: Circle {
pos: weight.pos(), pos: weight.pos(),
r: weight.width() / 2.0, r: weight.width() / 2.0,
@ -244,19 +244,19 @@ impl<
}) })
} }
pub fn seg_shape(&self, seg: SI) -> Shape { pub fn seg_shape(&self, seg: SI) -> PrimitiveShape {
let (from, to) = self.seg_joints(seg); let (from, to) = self.seg_joints(seg);
Shape::Seg(SegShape { PrimitiveShape::Seg(SegShape {
from: self.dot_weight(from).pos(), from: self.dot_weight(from).pos(),
to: self.dot_weight(to).pos(), to: self.dot_weight(to).pos(),
width: self.primitive_weight(seg.node_index()).width(), width: self.primitive_weight(seg.node_index()).width(),
}) })
} }
pub fn bend_shape(&self, bend: BI) -> Shape { pub fn bend_shape(&self, bend: BI) -> PrimitiveShape {
let (from, to) = self.bend_joints(bend); let (from, to) = self.bend_joints(bend);
let core_weight = self.core_weight(bend); let core_weight = self.core_weight(bend);
Shape::Bend(BendShape { PrimitiveShape::Bend(BendShape {
from: self.dot_weight(from).pos(), from: self.dot_weight(from).pos(),
to: self.dot_weight(to).pos(), to: self.dot_weight(to).pos(),
c: Circle { c: Circle {

View File

@ -1,6 +1,6 @@
#[macro_use] #[macro_use]
mod geometry; mod geometry;
pub mod shape; pub mod primitive;
pub mod with_rtree; pub mod with_rtree;
pub use geometry::*; pub use geometry::*;

View File

@ -5,11 +5,11 @@ use rstar::{RTreeObject, AABB};
use crate::math::{self, Circle}; use crate::math::{self, Circle};
#[enum_dispatch] #[enum_dispatch]
pub trait ShapeTrait { pub trait PrimitiveShapeTrait {
fn priority(&self) -> u64; fn priority(&self) -> u64;
fn inflate(&self, margin: f64) -> Shape; fn inflate(&self, margin: f64) -> PrimitiveShape;
fn center(&self) -> Point; fn center(&self) -> Point;
fn intersects(&self, other: &Shape) -> bool; fn intersects(&self, other: &PrimitiveShape) -> bool;
fn envelope(&self, margin: f64) -> AABB<[f64; 2]>; fn envelope(&self, margin: f64) -> AABB<[f64; 2]>;
fn width(&self) -> f64; fn width(&self) -> f64;
fn length(&self) -> f64; fn length(&self) -> f64;
@ -35,9 +35,9 @@ pub trait ShapeTrait {
} }
} }
#[enum_dispatch(ShapeTrait)] #[enum_dispatch(PrimitiveShapeTrait)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum Shape { pub enum PrimitiveShape {
// Intentionally in different order to reorder `self.intersects(...)` properly. // Intentionally in different order to reorder `self.intersects(...)` properly.
Dot(DotShape), Dot(DotShape),
Seg(SegShape), Seg(SegShape),
@ -49,13 +49,13 @@ pub struct DotShape {
pub c: Circle, pub c: Circle,
} }
impl ShapeTrait for DotShape { impl PrimitiveShapeTrait for DotShape {
fn priority(&self) -> u64 { fn priority(&self) -> u64 {
3 3
} }
fn inflate(&self, margin: f64) -> Shape { fn inflate(&self, margin: f64) -> PrimitiveShape {
Shape::Dot(DotShape { PrimitiveShape::Dot(DotShape {
c: Circle { c: Circle {
pos: self.c.pos, pos: self.c.pos,
r: self.c.r + margin, r: self.c.r + margin,
@ -67,15 +67,19 @@ impl ShapeTrait for DotShape {
self.c.pos self.c.pos
} }
fn intersects(&self, other: &Shape) -> bool { fn intersects(&self, other: &PrimitiveShape) -> bool {
if self.priority() < other.priority() { if self.priority() < other.priority() {
return other.intersects(&Shape::from(*self)); return other.intersects(&PrimitiveShape::from(*self));
} }
match other { match other {
Shape::Dot(other) => self.c.pos.euclidean_distance(&other.c.pos) < self.c.r + other.c.r, PrimitiveShape::Dot(other) => {
Shape::Seg(other) => self.c.pos.euclidean_distance(&other.polygon()) < self.c.r, self.c.pos.euclidean_distance(&other.c.pos) < self.c.r + other.c.r
Shape::Bend(other) => { }
PrimitiveShape::Seg(other) => {
self.c.pos.euclidean_distance(&other.polygon()) < self.c.r
}
PrimitiveShape::Bend(other) => {
for point in math::intersect_circles(&self.c, &other.inner_circle()) { for point in math::intersect_circles(&self.c, &other.inner_circle()) {
if other.between_ends(point) { if other.between_ends(point) {
return true; return true;
@ -139,13 +143,13 @@ impl SegShape {
} }
} }
impl ShapeTrait for SegShape { impl PrimitiveShapeTrait for SegShape {
fn priority(&self) -> u64 { fn priority(&self) -> u64 {
2 2
} }
fn inflate(&self, margin: f64) -> Shape { fn inflate(&self, margin: f64) -> PrimitiveShape {
Shape::Seg(SegShape { PrimitiveShape::Seg(SegShape {
from: self.from, from: self.from,
to: self.to, to: self.to,
width: self.width + 2.0 * margin, width: self.width + 2.0 * margin,
@ -156,15 +160,15 @@ impl ShapeTrait for SegShape {
(self.from + self.to) / 2.0 (self.from + self.to) / 2.0
} }
fn intersects(&self, other: &Shape) -> bool { fn intersects(&self, other: &PrimitiveShape) -> bool {
if self.priority() < other.priority() { if self.priority() < other.priority() {
return other.intersects(&Shape::from(*self)); return other.intersects(&PrimitiveShape::from(*self));
} }
match other { match other {
Shape::Dot(..) => unreachable!(), PrimitiveShape::Dot(..) => unreachable!(),
Shape::Seg(other) => self.polygon().intersects(&other.polygon()), PrimitiveShape::Seg(other) => self.polygon().intersects(&other.polygon()),
Shape::Bend(other) => { PrimitiveShape::Bend(other) => {
for segment in self.polygon().exterior().lines() { for segment in self.polygon().exterior().lines() {
let inner_circle = other.inner_circle(); let inner_circle = other.inner_circle();
let outer_circle = other.outer_circle(); let outer_circle = other.outer_circle();
@ -248,13 +252,13 @@ impl BendShape {
} }
} }
impl ShapeTrait for BendShape { impl PrimitiveShapeTrait for BendShape {
fn priority(&self) -> u64 { fn priority(&self) -> u64 {
1 1
} }
fn inflate(&self, margin: f64) -> Shape { fn inflate(&self, margin: f64) -> PrimitiveShape {
Shape::Bend(BendShape { PrimitiveShape::Bend(BendShape {
from: self.from, // TODO: Is not inflated for now. from: self.from, // TODO: Is not inflated for now.
to: self.to, // TODO: Is not inflated for now. to: self.to, // TODO: Is not inflated for now.
c: Circle { c: Circle {
@ -270,14 +274,14 @@ impl ShapeTrait for BendShape {
self.c.pos + (sum / sum.euclidean_distance(&point! {x: 0.0, y: 0.0})) * self.c.r self.c.pos + (sum / sum.euclidean_distance(&point! {x: 0.0, y: 0.0})) * self.c.r
} }
fn intersects(&self, other: &Shape) -> bool { fn intersects(&self, other: &PrimitiveShape) -> bool {
if self.priority() < other.priority() { if self.priority() < other.priority() {
return other.intersects(&Shape::from(*self)); return other.intersects(&PrimitiveShape::from(*self));
} }
match other { match other {
Shape::Dot(..) | Shape::Seg(..) => unreachable!(), PrimitiveShape::Dot(..) | PrimitiveShape::Seg(..) => unreachable!(),
Shape::Bend(other) => { PrimitiveShape::Bend(other) => {
for point in math::intersect_circles(&self.inner_circle(), &other.inner_circle()) { for point in math::intersect_circles(&self.inner_circle(), &other.inner_circle()) {
if self.between_ends(point) && other.between_ends(point) { if self.between_ends(point) && other.between_ends(point) {
return true; return true;
@ -334,9 +338,9 @@ impl ShapeTrait for BendShape {
} }
} }
impl RTreeObject for Shape { impl RTreeObject for PrimitiveShape {
type Envelope = AABB<[f64; 2]>; type Envelope = AABB<[f64; 2]>;
fn envelope(&self) -> Self::Envelope { fn envelope(&self) -> Self::Envelope {
ShapeTrait::envelope(self, 0.0) PrimitiveShapeTrait::envelope(self, 0.0)
} }
} }

View File

@ -8,7 +8,7 @@ use rstar::{primitives::GeomWithData, Envelope, RTree, RTreeObject, AABB};
use crate::{ use crate::{
drawing::graph::{GetLayer, Retag}, drawing::graph::{GetLayer, Retag},
geometry::{ geometry::{
shape::{Shape, ShapeTrait}, primitive::{PrimitiveShape, PrimitiveShapeTrait},
BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetWidth, Node, SegWeightTrait, BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetWidth, Node, SegWeightTrait,
}, },
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
@ -331,7 +331,7 @@ impl<
BboxedIndex::new(Bbox::new(aabb), Node::Grouping(grouping)) BboxedIndex::new(Bbox::new(aabb), Node::Grouping(grouping))
} }
fn shape(&self, primitive: PI) -> Shape { fn shape(&self, primitive: PI) -> PrimitiveShape {
if let Ok(dot) = <PI as TryInto<DI>>::try_into(primitive) { if let Ok(dot) = <PI as TryInto<DI>>::try_into(primitive) {
self.geometry.dot_shape(dot) self.geometry.dot_shape(dot)
} else if let Ok(seg) = <PI as TryInto<SI>>::try_into(primitive) { } else if let Ok(seg) = <PI as TryInto<SI>>::try_into(primitive) {

View File

@ -17,7 +17,7 @@ use crate::{
primitive::{GetCore, MakeShape, Primitive}, primitive::{GetCore, MakeShape, Primitive},
Drawing, Drawing,
}, },
geometry::shape::ShapeTrait, geometry::primitive::PrimitiveShapeTrait,
graph::GetNodeIndex, graph::GetNodeIndex,
triangulation::{GetVertexIndex, Triangulation}, triangulation::{GetVertexIndex, Triangulation},
}; };

View File

@ -12,7 +12,7 @@ use crate::drawing::{
primitive::MakeShape, primitive::MakeShape,
rules::RulesTrait, rules::RulesTrait,
}; };
use crate::geometry::shape::ShapeTrait; use crate::geometry::primitive::PrimitiveShapeTrait;
use crate::layout::connectivity::BandIndex; use crate::layout::connectivity::BandIndex;
use crate::layout::Layout; use crate::layout::Layout;