spade icon indicating copy to clipboard operation
spade copied to clipboard

[Bug] Incorrect error case for "constraint edges must not intersect each other"

Open Seldom-SE opened this issue 2 years ago • 0 comments

I'm getting an error for code that I believe should work. Here's my minimal reproduction:

use spade::{ConstrainedDelaunayTriangulation, Point2, Triangulation};

fn main() {
    let vertices = vec![
        Point2::new(60.0, 20.0),
        Point2::new(84.0, 20.0),
        Point2::new(236.0, 20.0),
        Point2::new(60.0, 36.0),
        Point2::new(84.0, 36.0),
        Point2::new(92.0, 28.0),
        Point2::new(60.0, 44.0),
        Point2::new(92.0, 44.0),
        Point2::new(212.0, 44.0),
        Point2::new(20.0, 60.0),
        Point2::new(156.0, 68.0),
    ];

    let edges = vec![(1, 2), (0, 3)];

    let mut triangulation =
        ConstrainedDelaunayTriangulation::<Point2<f32>>::bulk_load(vertices.clone()).unwrap();
    let vertex_handles = triangulation.fixed_vertices().collect::<Vec<_>>();

    for (from, to) in edges {
        println!(
            "{:?} ({:?}), {:?} ({:?})",
            vertices[from], vertex_handles[from], vertices[to], vertex_handles[to]
        );
        triangulation.add_constraint(vertex_handles[from], vertex_handles[to]);
    }
}
Point2 { x: 84.0, y: 20.0 } (FixedHandle { index: 1 }), Point2 { x: 236.0, y: 20.0 } (FixedHandle { index: 2 })
Point2 { x: 60.0, y: 20.0 } (FixedHandle { index: 0 }), Point2 { x: 60.0, y: 36.0 } (FixedHandle { index: 3 })
thread 'main' panicked at 'Error - constraint edges must not intersect each other', C:\Users\Hayde\.cargo\registry\src\github.com-1ecc6299db9ec823\spade-2.0.0\src\cdt.rs:363:17 

I've removed as many points and edges as I can while preserving the error. Note that the edges don't actually intersect: image Thanks!

Seldom-SE avatar Sep 21 '22 05:09 Seldom-SE