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

to_trangulation hang on certain shape #2

Open
gordlea opened this issue Nov 20, 2024 · 7 comments
Open

to_trangulation hang on certain shape #2

gordlea opened this issue Nov 20, 2024 · 7 comments

Comments

@gordlea
Copy link
Contributor

gordlea commented Nov 20, 2024

I've been having an issue where if I try to triangulate the following shape, the code hangs up in the to_trangulation function:
hang_shape

I've created a unit test that reproduces this:

    #[test]
    fn test_crasher4() {
        let shape: Shape<FloatPoint<f32>> = vec![
            vec![
                FloatPoint::<f32>::new(1.0, 1.0),
                FloatPoint::<f32>::new(1.0, 4.0),
                FloatPoint::<f32>::new(2.0, 4.0),
                FloatPoint::<f32>::new(2.0, 3.0),
                FloatPoint::<f32>::new(3.0, 3.0),
                FloatPoint::<f32>::new(3.0, 1.0),
            ]
        ];

        let triangulation = shape.to_triangulation(None, 0.);

        eprintln!("we made it here");
    }

It doesn't seem to matter what FillRule I use, I get the same results. Interestingly, I don't get a crash if I close the shape (end with 1.0, 1.0).

This may be a case of me doing something wrong, but I can't seem to figure it out.

@gordlea
Copy link
Contributor Author

gordlea commented Nov 20, 2024

@gordlea
Copy link
Contributor Author

gordlea commented Nov 20, 2024

Also, just noticed the same things happens with IntShape triangulation:

    #[test]
    fn test_crasher_int() {
        let int_shape: IntShape = vec![
            vec![
                IntPoint::new(1, 1),
                IntPoint::new(1, 4),
                IntPoint::new(2, 4),
                IntPoint::new(2, 3),
                IntPoint::new(3, 3),
                IntPoint::new(3, 1),
            ]
        ];

     
        let triangulation = int_shape.triangulation();

        eprintln!("we made it here");
    }

@NailxSharipov
Copy link
Member

I'm not very proud of this library, as it was originally written 6 years ago and it's time for a rewrite. I don't recommend using it in production yet. But it seems that this bug has already been fixed in the latest version.
Anyway, I added your case to the test dataset.

@gordlea
Copy link
Contributor Author

gordlea commented Nov 21, 2024

Hey, don't sell yourself short, the library works nicely and is well documented, which is more than I can say for most of the other ones out there, having tried them. 😄

I will give the latest version a try and report back.

@gordlea
Copy link
Contributor Author

gordlea commented Nov 21, 2024

Interestingly, when I check out master and run the tests, they pass. In my project, I'm getting failures. I will dig deeper into this.

@gordlea
Copy link
Contributor Author

gordlea commented Nov 21, 2024

Huh, when I check out the i_triangle locally, and include the local version in my workspace using i_triangle = { path = "../iTriangle" }, the tests don't hang. When I use i_triangle = "0.27.4" it hangs.

There doesn't seem to be any new commits since 0.27.4 was released, so I am a little stumped.

@NailxSharipov
Copy link
Member

NailxSharipov commented Nov 21, 2024

Screenshot 2024-11-21 at 17 21 03 Here is a bug you are looking for. Just double check that your version has this fix.

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