-
Notifications
You must be signed in to change notification settings - Fork 75
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
Flesh out 2D subsystem #127
Comments
Thinking about this recently, I wonder if we really need a 2D subsystem at all (for now). I think we can just write a simple wrapper to convert |
That's a clever idea - I guess |
I think Clipper2 is worth considering for wrapping. OpenSCAD actually uses Clipper1 (v6.4.2) for its 2D booleans with a small utility translation layer. Evolving out of Clipper1 it's pretty well used, and has benefitted from recent improvements. |
I think I can just implement it for TypeScript now, other users can implement their own wrapper as this is not complicated. Eventually we should use something like Clipper2, but it will take some time and I prefer having something that works first (kind of sick writing custom polygon generation code...) |
@geoffder is there a WASM build of clipper2 maybe ? |
I've thrown together a minimal example of using Clipper2 in the 2d-via-clipper branch of my fork. I left There are more methods from clipper2 (offset, path simplification, minkowski) that I haven't done yet, and transformations/shapes other than translate and square that need filling out, but this skeleton gets from end-to-end in the |
@geoffder Awesome! Would you mind opening a draft PR to make it a bit easier to peruse and comment on? I'd like to think through API shape for this, but it'll help to have some code to look at. |
We currently use
Polygons
as input to severalManifold
constructors, and they could easily be output as well (thinkSlice
), but we have no way to operate on them in 2D. I would like to think ofPolygon
as the 2D equivalent toMesh
, and I'd like to create aCrossSection
class that is the 2D equivalent toManifold
.A
CrossSection
will always be geometrically-valid (non-overlapping), as any inputPolygons
will be automatically fixed up according to winding number. Clipper lib seems like a good candidate to support useful 2D operations. I propose we adopt the "strictly positive" fill rule; this will allow Boolean-style operations simply by adding Polygons with the proper winding direction. This class will be totally independent of theManifold
class; they can simply interact through exportedPolygons
.The text was updated successfully, but these errors were encountered: