-
Notifications
You must be signed in to change notification settings - Fork 69
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
2d-operations via Clipper2 #341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this is excellent - I'm also really glad to see how much functionality is here with not that much code. @pca006132 what do you think regarding API? Anything we should consider regarding our various bindings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all the comments are now marked outdated due to the rename, would you mind resolving the ones you've finished so we know what's left to do?
Now that usage of CrossSection is forced, 11 of the tests are failing. I'm afraid that I'm not sure which of them are acceptable changes (if any) from my brief looking around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the tests are doing their job! Do you feel comfortable debugging? The simplest thing is probably just to dump out the input polygons and ToPolygon
result and see what changed. Let me know if you get stumped.
Ok, I'll try to get some in later and report on what's happening to the inputs. I'm suspecting that at least some of them are due to the precision rounding step, but there could of course be deeper things going on with the clipping. The outputs are still manifold and the exported model glbs seem fine, but obviously some vertices are moving around to throw off the geometry checks. |
All tests now passing on my machine 👍. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #341 +/- ##
==========================================
- Coverage 91.52% 89.50% -2.02%
==========================================
Files 32 33 +1
Lines 3730 3965 +235
==========================================
+ Hits 3414 3549 +135
- Misses 316 416 +100
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I haven't converted Manifold (and the rest of the codebase) over yet, but I lifted the circular quality static globals into a class |
Yes, that sounds like a great idea. Also, how do you want to approach this PR? We'll want to update various bindings and examples to make use of what you've built. Would you like to keep working here, or get this PR merged and look at follow-ons? I'm not too picky, but I'm working on getting a release out, and I think it's best for this to come after. |
Roger, I'll change things over then.
I think merging first, then updating bindings works fine. Since Polygons has a constructor in CrossSection and everything is working without "knowing" that CrossSections exists, the bindings haven't been broken and from here the changes they need are additive. |
Just curious: Why do we name this as cross section instead of polygon? Other than this I don't think I have anything to comment on, this looks pretty good to me! |
We still have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! What else would you like to do before we merge?
I can't think of anything at the moment that needs to be added in the first go. Probably a good place to call it? |
This reverts commit af8f6c8.
Actually, the last potential piece would be wrapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work! Ready to merge?
Looking at it again I've remembered that I haven't added Transform yet for the 2d types. That would bring them another step closer to the 3d counterparts and make it ready I think. |
Ok, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
@geoffder I would still like to see the equivalent |
@elalish
Sure I'll add myself on there soon, thanks for the offer 🙏. Continuing to collaborate and stay involved sounds good to me. |
* WIP Clipper2 wrapper for 2d subsystem * Working example in clippoly_test * Add clean_ property to clippoly * Square center=false by default * Square defaults to center=false * Shorten union example * + simplification and minkowski functions * + Circle and note on Minkowski * + Offset (InflatePaths) * Clippoly -> CrossSection renaming * Switch from NonZero to Positive fill rule * -(minkowski, simplifs, clean_) + pre-alloc vecs Remove minkowski, simplification algorithms other than simplify, clean (union) arbitrary contours on construction, and pre-allocate vectors when length is known. * - index from polygon conversion + missed vec prealloc * Use Polygon shorthand over std::vector * Update copyright date * Add Rotate * Update copyrights to 2023 * Extrude and Revolve accept CrossSection only * Fix incorrect use of vector constructor * Fix remaining incorrect vector construction * Revert "Update copyrights to 2023" This reverts commit af8f6c8. * Re-update copyright notice in cross_section files * Add missing precision_ argument to cleaning Unions * Lift circular resolution globals into Quality * Replace uses of Manifold globals with Quality * + Ellipse, Mirror, Area * Include mirror in Union example and test area * + Rewind (reverse winding of all contours) * + fillrule/IsEmpty - Ellipse/Rewind * Move Quality into public.h * Remove bad definition * Replace manual circles with CrossSection::Circle * Lists of empty contours are empty * + Rect class, RectClip, + const params/methods * Add Transform to CrossSection and Rect
Fixes #127
Minimal proof of concept of integrating Clipper2 in order to flesh out Manifold's 2d capabilities.