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

Rewrite parts of sweep code #1593

Merged
merged 7 commits into from
Feb 16, 2023
Merged

Rewrite parts of sweep code #1593

merged 7 commits into from
Feb 16, 2023

Conversation

hannobraun
Copy link
Owner

This is part of the ongoing HalfEdge cleanup (#1525).

From the message of the main commit:

The rewrite of the edge sweeping code uses the builder API, making the
code more compact, and making the sweep code for Vertex redundant (it
can be removed in a follow-up commit.

The rewrite of the face sweeping code is less of a slam dunk. It adds a
fair bit of complexity over the previous version, but I think this is
okay, due to two factors:

  1. I believe that this complexity can be reigned in later, once the core
    data structures have been simplified. This is an ongoing effort.
  2. It fixes existing bugs. See below.

The initial reason for the rewrite was the ongoing HalfEdge cleanup:
As part of the celanup, the Reverse implementation for HalfEdge
needs to be removed, and this new code no longer uses it.

However, as it turned out, there is a significant side effect: The new
code generates different (but still correct) curves, which are less
uniform than the ones generated by the old code, which happens to
trigger approximation failures that exposed existing bugs.

Those bugs basically boil down to the previous sweep code generating
coincident edges that don't refer to the same global edge. This was
already known (#1162), but so far a proper fix was blocked on missing
validation code, to ensure all instances of this bug are fixed.

That validation code still needs to be written, but the approximation
failures already did a pretty good job of guiding me towards the various
sources of the bug.

This rewrite caused me so many problems. I literally spent weeks on getting this right! Not sure if it was worth it in the end, but it is very nice to be able to close those bugs and unblock further work on #1525.

Close #494
Close #1162 (will open follow-up issue about validation checks)

This is potentially panicky, while the destructuring will fail at
compile-time.
This implementation will be removed as part of the ongoing `HalfEdge`
cleanup.
This is going to be required in the face sweep code, to make sure the
top of the solid is properly stitched up with the sides.
The rewrite of the edge sweeping code uses the builder API, making the
code more compact, and making the sweep code for `Vertex` redundant (it
can be removed in a follow-up commit.

The rewrite of the face sweeping code is less of a slam dunk. It adds a
fair bit of complexity over the previous version, but I think this is
okay, due to two factors:

1. I believe that this complexity can be reigned in later, once the core
   data structures have been simplified. This is an ongoing effort.
2. It fixes existing bugs. See below.

The initial reason for the rewrite was the ongoing `HalfEdge` cleanup:
As part of the celanup, the `Reverse` implementation for `HalfEdge`
needs to be removed, and this new code no longer uses it.

However, as it turned out, there is a significant side effect: The new
code generates different (but still correct) curves, which are less
uniform than the ones generated by the old code, which happens to
trigger approximation failures that exposed existing bugs.

Those bugs basically boil down to the previous sweep code generating
coincident edges that don't refer to the same global edge. This was
already known (#1162), but so far a proper fix was blocked on missing
validation code, to ensure all instances of this bug are fixed.

That validation code still needs to be written, but the approximation
failures already did a pretty good job of guiding me towards the various
sources of the bug.
@hannobraun hannobraun enabled auto-merge February 16, 2023 14:09
@hannobraun hannobraun merged commit 15ff811 into main Feb 16, 2023
@hannobraun hannobraun deleted the sweep branch February 16, 2023 14:14
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

Successfully merging this pull request may close these issues.

Sweep code is generating duplicate GlobalCurves Rotating a cylinder causes 3MF validation error
1 participant