Coder Social home page Coder Social logo

Flesh out 2D subsystem about manifold HOT 9 CLOSED

elalish avatar elalish commented on June 21, 2024
Flesh out 2D subsystem

from manifold.

Comments (9)

geoffder avatar geoffder commented on June 21, 2024 2

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.

from manifold.

pca006132 avatar pca006132 commented on June 21, 2024 2

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...)

from manifold.

geoffder avatar geoffder commented on June 21, 2024 1

@elalish Done! #341

from manifold.

pca006132 avatar pca006132 commented on June 21, 2024

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 to3D(2D op 2D) to to3D(2D) op to3D(2D), e.g. extrude(LargeSquare - SmallSquare, n) to extrude(LargeSquare, n) - extrude(SmallSquare, n). This method will be slower than using a 2D subsystem, but it is really simple and I think our performance is good enough that the users will probably not notice this.

from manifold.

elalish avatar elalish commented on June 21, 2024

That's a clever idea - I guess 2Dto3D could basically use Extrude and 3Dto2D would basically be Slice? It does seem like a lot of overhead, but if it's quick to code it seems well worthwhile. We should be able to swap it out later without breaking the API in any case. Do you want to give it a try?

from manifold.

hrgdavor avatar hrgdavor commented on June 21, 2024

@geoffder is there a WASM build of clipper2 maybe ?

from manifold.

geoffder avatar geoffder commented on June 21, 2024

@hrgdavor I'm not really sure, but this issue is the only one that turns up in a search for WASM, and it sounds like building with emcc wasn't cause for much grief at the time after all.

from manifold.

geoffder avatar geoffder commented on June 21, 2024

I've thrown together a minimal example of using Clipper2 in the 2d-via-clipper branch of my fork. I left Polygons as it is in this prototype, since I wasn't sure of the best way to integrate it. I figured a class that could be automatically constructed from the clipper wrapper class would save the need for the overloads on the extrusion functions at least, but I left out an experiment with that for now.

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 clippoly_test.cpp example.

image

from manifold.

elalish avatar elalish commented on June 21, 2024

@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.

from manifold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.