diff --git a/topola/src/math.rs b/topola/src/math.rs index 63351c0..3da9606 100644 --- a/topola/src/math.rs +++ b/topola/src/math.rs @@ -25,7 +25,7 @@ impl From> for [T; 2] { } } -// Check if the point (px, py) is inside the polygon using the ray-casting +// Check if the point (px, py) is inside a polygon using the ray-casting // algorithm. macro_rules! impl_inside_polygon { ($type:ty) => { diff --git a/topola/src/primitives.rs b/topola/src/primitives.rs index e4e4094..c83142a 100644 --- a/topola/src/primitives.rs +++ b/topola/src/primitives.rs @@ -7,9 +7,9 @@ use rstar::{AABB, Envelope, primitives::Rectangle}; use serde::{Deserialize, Serialize}; use crate::{ + Vector2, layout::{NetId, PinId}, selection::PinSelector, - Vector2, }; #[derive( @@ -152,18 +152,18 @@ pub struct Polygon { impl Polygon { pub fn bbox(&self) -> Rectangle<[i64; 3]> { - Rectangle::from_aabb(self.vertices.clone().into_iter().fold( - AABB::new_empty(), - |aabb, vertex| { - aabb.merged(&AABB::from_point([vertex.x, vertex.y, self.layer as i64])) - }, - )) + Rectangle::from_aabb( + self.vertices + .clone() + .into_iter() + .fold(AABB::new_empty(), |aabb, vertex| { + aabb.merged(&AABB::from_point([vertex.x, vertex.y, self.layer as i64])) + }), + ) } pub fn contains_point(&self, point: Vector2) -> bool { - /*Vector2::from(point) - .inside_polygon(&self.vertices.iter().map(Into::into).collect::>())*/ - false + point.inside_polygon(&self.vertices) } pub fn pin_selector(&self) -> Option {