hannobraun/fornjot

Intersecting half-edges cause panic

hannobraun opened this issue · 0 comments

When creating a cycle with intersecting half-edges, I get this error when I'm trying to display a model:

thread 'main' panicked at crates/fj-core/src/objects/kinds/cycle.rs:80:9:
internal error: entered unreachable code: Encountered invalid cycle: Cycle {
    half_edges: ObjectSet {
        inner: [
            HalfEdge @ 0x7f53f7c7a010 => HalfEdge {
                path: Line(
                    Line {
                        origin: [
                            1.5,
                            -1.0,
                        ],
                        direction: [
                            -3.0,
                            0.0,
                        ],
                    },
                ),
                boundary: CurveBoundary {
                    inner: [
                        [
                            0.0,
                        ],
                        [
                            1.0,
                        ],
                    ],
                },
                curve: Curve @ 0x5648a2ec2e90 => Curve,
                start_vertex: Vertex @ 0x5648a2ec71e0 => Vertex,
            },
            HalfEdge @ 0x7f53f7c7a098 => HalfEdge {
                path: Line(
                    Line {
                        origin: [
                            -1.5,
                            -1.0,
                        ],
                        direction: [
                            3.0,
                            2.0,
                        ],
                    },
                ),
                boundary: CurveBoundary {
                    inner: [
                        [
                            0.0,
                        ],
                        [
                            1.0,
                        ],
                    ],
                },
                curve: Curve @ 0x5648a2ec2e91 => Curve,
                start_vertex: Vertex @ 0x5648a2ec71e1 => Vertex,
            },
            HalfEdge @ 0x7f53f7c7a120 => HalfEdge {
                path: Line(
                    Line {
                        origin: [
                            1.5,
                            1.0,
                        ],
                        direction: [
                            -3.0,
                            0.0,
                        ],
                    },
                ),
                boundary: CurveBoundary {
                    inner: [
                        [
                            0.0,
                        ],
                        [
                            1.0,
                        ],
                    ],
                },
                curve: Curve @ 0x5648a2ec2e92 => Curve,
                start_vertex: Vertex @ 0x5648a2ec71e2 => Vertex,
            },
            HalfEdge @ 0x7f53f7c7a1a8 => HalfEdge {
                path: Line(
                    Line {
                        origin: [
                            -1.5,
                            1.0,
                        ],
                        direction: [
                            3.0,
                            -2.0,
                        ],
                    },
                ),
                boundary: CurveBoundary {
                    inner: [
                        [
                            0.0,
                        ],
                        [
                            1.0,
                        ],
                    ],
                },
                curve: Curve @ 0x5648a2ec2e93 => Curve,
                start_vertex: Vertex @ 0x5648a2ec71e3 => Vertex,
            },
        ],
    },
}
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is easy to reproduce, by switching the positions of two of those lines in the cuboid model.

The error originates in Cycle::winding, and I have some suspicions that this method is buggy in more ways than that (pending investigation). It probably doesn't make much sense to fix this until the new geometry representation is here (or, alternatively, if we realize that it won't be here for some time).