fornjot icon indicating copy to clipboard operation
fornjot copied to clipboard

Face edges not always present in triangulation

Open hannobraun opened this issue 2 years ago • 6 comments

It's possible that edges of a face don't show up in the triangulation, which is obviously an invalid result. It's relatively easy to come up with an example, once you know what to look for. Check out this quick sketch I did:

triangulation

There's a face on the left, and a possible Delaunay triangulation of that face on the right. The long vertical edge that I specially marked is not present in the triangulation.

Thanks to @alexoro412, who reported this issue in #105!

This should be pretty easy to fix, hopefully. Spade can do constrained Delaunay triangulations, which should take care of this issue.

Blocked on #105, since I believe we should have a test suite in place before fixing more triangulation issues.

hannobraun avatar Apr 05 '22 11:04 hannobraun

#105 has been addressed. This issue is no longer blocked.

I forgot to label this as https://github.com/hannobraun/Fornjot/labels/status%3A%20blocked in the first place.

hannobraun avatar Apr 11 '22 14:04 hannobraun

I suspect that the missing triangles here are an instance of this bug: non-symmetric-sweep-new

This is basically the normal star model, except that the let radius = ... line has been replaced with this:

let mut radius = if i % 2 == 0 { r1 } else { r2 };
radius *= (i + 1) as f64 / num_vertices as f64;

hannobraun avatar May 04 '22 11:05 hannobraun

Here's a more minimal example:

#[fj::model]
pub fn model(
) -> fj::Shape {
    let good_x = 0.5;
    let bad_x = 0.4;
    let x = bad_x;
    let mut other = Vec::new();
        other.push([0., 0.]);
        other.push([x, 0.]);
        other.push([0.4, 1.0]);
        other.push([0.1, 0.1]);
        other.push([0., 0.8]);

    let other = fj::Sketch::from_points(other);


    other.into()
}

Selection_043 Selection_044

willhansen avatar Jul 16 '22 01:07 willhansen

Thank you, @willhansen!

hannobraun avatar Jul 16 '22 06:07 hannobraun

Converted example to failing unit test: https://github.com/hannobraun/Fornjot/compare/main...willhansen:Fornjot:bugfix/%23430-triangulation-missing-edges

willhansen avatar Jul 17 '22 18:07 willhansen

That's great, @willhansen, thank you!

Would you mind slapping an #[ignore] on the test and submitting that in a pull request? That way, the test is available to be used right where it will be needed, without making the CI build fail.

hannobraun avatar Jul 18 '22 07:07 hannobraun