Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in add_constraint_and_split #113

Closed
Azorlogh opened this issue Aug 22, 2024 · 3 comments
Closed

Panic in add_constraint_and_split #113

Azorlogh opened this issue Aug 22, 2024 · 3 comments

Comments

@Azorlogh
Copy link

This test case panics:

    #[test]
    fn edge_intersection_precision_test_3() -> Result<(), InsertionError> {
        let edges = [
            [
                Point2 {
                    x: 7.9910984,
                    y: -59.344463,
                },
                Point2 {
                    x: 15.484455,
                    y: -48.762936,
                },
            ],
            [
                Point2 {
                    x: 15.484455,
                    y: -48.762936,
                },
                Point2 {
                    x: -11.673287,
                    y: -28.37192,
                },
            ],
            [
                Point2 {
                    x: -11.673287,
                    y: -28.37192,
                },
                Point2 {
                    x: -16.214716,
                    y: -43.81278,
                },
            ],
            [
                Point2 {
                    x: -16.214716,
                    y: -43.81278,
                },
                Point2 {
                    x: -3.657666,
                    y: -51.41967,
                },
            ],
            [
                Point2 {
                    x: -3.657666,
                    y: -51.41967,
                },
                Point2 {
                    x: 7.9910984,
                    y: -59.344463,
                },
            ],
            [
                Point2 {
                    x: 7.4022045,
                    y: -51.355137,
                },
                Point2 {
                    x: 7.9910984,
                    y: -59.344463,
                },
            ],
            [
                Point2 {
                    x: 7.4022045,
                    y: -51.355137,
                },
                Point2 {
                    x: 15.484455,
                    y: -48.762936,
                },
            ],
            [
                Point2 {
                    x: 7.4022045,
                    y: -51.355137,
                },
                Point2 {
                    x: -13.92232,
                    y: -36.01863,
                },
            ],
        ];
        let mut cdt: ConstrainedDelaunayTriangulation<Point2<f32>> =
            ConstrainedDelaunayTriangulation::new();
        for edge in edges {
            let point_a = cdt.insert(edge[0])?;
            let point_b = cdt.insert(edge[1])?;
            cdt.cdt_sanity_check();
            cdt.add_constraint_and_split(point_a, point_b, |v| v);
            cdt.cdt_sanity_check();
        }

        Ok(())
    }
thread 'cdt::test::edge_intersection_precision_test_3' panicked at src/cdt.rs:876:17:
assertion `left != right` failed
  left: []
 right: []

It panics on this assertion:

assert_ne!(new_edges, Vec::new());

@Stoeoef
Copy link
Owner

Stoeoef commented Aug 22, 2024

Thanks for the report! I'll try to look into that soon.

In the meantime, you could consider to fork the repository and remove that assertion if it's a blocker for you - it's probably not too important. I'll know more once I've looked into that.

@Stoeoef
Copy link
Owner

Stoeoef commented Sep 7, 2024

This one is annoying. When using f64, everything works just fine - the minimized example only requires 2 calls to add_constraint_and_split and looks like this:

image

Note that vertex 3 and 4 overlap visually but they do not share the same position - it's ever so slightly different. There is also a constraint edge going from 1->4, it's just being visually overlapped by the regular edge 1->3.

This triangulation correctly represents the split and has 4 constraint edges: 0->4, 2->4, 3->4 and 1->4

However, for f32, v3 and v4 do end up on the exact same position after downcasting. In this case, the triangulation should end up with 4 vertices in total and only 3 constraint edges: 0->3,1->3, 2->3

What an annoying edge case 😄 . I'm working on a fix.

Stoeoef added a commit that referenced this issue Sep 9, 2024
`ConflictRegionEnd::NewVertex` was renamed to `ConflictRegionEnd::ConstraintEdgeSplit`
Stoeoef added a commit that referenced this issue Sep 9, 2024
`ConflictRegionEnd::NewVertex` was renamed to `ConflictRegionEnd::ConstraintEdgeSplit`
@Stoeoef Stoeoef closed this as completed in 87700f1 Sep 9, 2024
@Stoeoef
Copy link
Owner

Stoeoef commented Sep 9, 2024

Fixed in v2.12.1 (just released) - thanks again for the report 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants