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

Incorrect CDT -- points not in the input added #6

Closed
Indy2222 opened this issue Jul 1, 2022 · 2 comments
Closed

Incorrect CDT -- points not in the input added #6

Indy2222 opened this issue Jul 1, 2022 · 2 comments

Comments

@Indy2222
Copy link

Indy2222 commented Jul 1, 2022

The following picture illustrates the issue:

image

All points except 4 in the corners were added as constraint edges (visualized with red color). The triangulation contains triangles (visualized with blue color) with vertices which do not correspond to any input point.

This is fully zoomed out image (scaled to 0-1):

image

Note that I have removed some triangles from the zoomed-out image above (the white areas were correctly covered).

Input points:

[[-500., -1000.], [-500., 1000.], [500., 1000.], [500., -1000.]]

Input edges (list of edges, each is list of a-b points):

[[[-420.56, -920.56], [-379.44, -920.56]], [[-379.44, -920.56], [-379.53156, -840.588]], [[-379.53156, -840.588], [-420.65155, -840.588]], [[-420.65155, -840.588], [-424.31952, -897.4294]], [[-424.31952, -897.4294], [-424.31952, -904.1894]], [[-424.31952, -904.1894], [-420.56, -920.56]], [[-420.56, 920.56], [-420.56, 879.44]], [[-420.56, 879.44], [-379.44, 879.44]], [[-379.44, 879.44], [-379.44, 920.56]], [[-379.44, 920.56], [-420.56, 920.56]], [[379.44, 920.56], [379.44, 879.44]], [[379.44, 879.44], [420.56, 879.44]], [[420.56, 879.44], [420.56, 920.56]], [[420.56, 920.56], [379.44, 920.56]], [[379.44, -879.44], [379.44, -920.56]], [[379.44, -920.56], [420.56, -920.56]], [[420.56, -920.56], [420.56, -879.44]], [[420.56, -879.44], [379.44, -879.44]]]
@Indy2222
Copy link
Author

Indy2222 commented Jul 1, 2022

For completeness, my code looks like this:

let mut triangulation = ConstrainedDelaunayTriangulation::<Point2<_>>::new();
// ...
// For corner points are added like this:
triangulation.insert(Point2::new(...)).unwrap();
// ...
// Then in a for loop:
triangulation
    .add_constraint_edge(edge.a_point2(), edge.b_point2())
    .unwrap();

// And then I get the triangles with:
triangulation
    .inner_faces()
    .filter_map(|f| {
        let vertices = f.vertices().map(|v| {
            let v = v.as_ref();
            Point::new(v.x, v.y)
        });
        let triangle = Triangle::new(vertices[0], vertices[1], vertices[2]);
        if polygon_ids.is_excluded(&triangle) {
            None
        } else {
            Some(triangle)
        }
    })
    .collect()

@Indy2222
Copy link
Author

Indy2222 commented Jul 1, 2022

Never mind, I opened the issue in wrong repository. 😊

@Indy2222 Indy2222 closed this as completed Jul 1, 2022
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

1 participant