Skip to content

Commit

Permalink
Make loop polygons work -- we need to look at polygon holes too
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jun 13, 2024
1 parent f4c304b commit 1c5d839
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions widths/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,16 @@ fn clip_line_to_polygon(
cfg: &Config,
) -> Option<Line> {
let mut hits = Vec::new();
for polygon_line in polygon.exterior().lines() {
if let Some(LineIntersection::SinglePoint { intersection, .. }) =
geo::algorithm::line_intersection::line_intersection(line, polygon_line)
{
hits.push(intersection);
for boundary in vec![polygon.exterior()]
.into_iter()
.chain(polygon.interiors())
{
for polygon_line in boundary.lines() {
if let Some(LineIntersection::SinglePoint { intersection, .. }) =
geo::algorithm::line_intersection::line_intersection(line, polygon_line)
{
hits.push(intersection);
}
}
}

Expand Down

0 comments on commit 1c5d839

Please sign in to comment.