Code Monkey home page Code Monkey logo

Comments (12)

z3dev avatar z3dev commented on June 16, 2024

@fischman thanks
I think there was a small bug introduced last release for 2D format exports. I think this is fixed in the pending 0.5.2 release, and will try.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

From @fischman on October 26, 2016 15:14

FWIW I get the same failure on openjscad.org and locally on e16c68a141437321d75b7401d48a851de2b48929

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

@fischman Sadly, it looks to be a issue with the CSG.js library. I'm just starting to work with this library, and will log this as a bug against CSG.js.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

@fischman So, I took a look at this today.

Internally, the CAG sides are converted into CSG walls, and then CSG.unionSub() is called to do the work. The resulting CSG is then converted back to CSG sides. Deep inside CSG.unionSub() there's a problem, as the returned CSG (and therefore the CAG) are not properly closed, i.e. polygons are not clean.

This is going to take some time give that I'm now dealing with 3D math.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

This issue was moved to z3dev/hello-world#3

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

Ooops! The tools automatically closed this. Reopening.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

@fischman This issue does not exist in the latest version of JSCAD. Can you confirm?

I also added a test in the V2 test suite for this. Hopefully, this will not reappear.

from csg.js.

fischman avatar fischman commented on June 16, 2024

Original report still repros on openjscad.org.
I don't have a v2 checkout to test with, if that's what you meant.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

@fischman i have been looking at how to improve the boolean operations for 2D geometry in V2. I have indentifed some issues with points returned from the boolean operations, where there are slight differences in the floating point numbers. In order to prevent these issues, I have added some logic to round the values, and produce points that 'snap' to EPS boundries.

    let x = Math.round(v3[0] / EPS) * EPS + 0 // no more -0
    let y = Math.round(v3[1] / EPS) * EPS + 0 // no more -0
    return vec2.fromValues(x, y)

This definitely helps for anything that I can think about.

However, this issue still fails. The union of CAG c and CAG d is not closed. So, I have some questions...

Do you know that CAG c and CAG d (above) actually have two outlines? If you follow the sides given, you will find two outlines in each of the CAGs.

Having said that... I suspect that those points came from another boolean operation. So, my next question is... how were those set of points created?

I haven't given up but wanted some feedback.

from csg.js.

fischman avatar fischman commented on June 16, 2024

@z3dev load https://openjscad.org/#https://gist.githubusercontent.com/fischman/2db39c62a5b7a73d28f2657d6af2e00d/raw/af6cba2efc3044befc3fc6232f217b65cc56a35b/flattener.jscad uncheck "label triangles" and change model to "heart", click Update, wait a few seconds/minutes depending on how fast your CPU is, then click "Generate DXF". Wait many minutes. End result is:
Uncaught Error: Area is not closed!
Line: 9103,col: 9
(https://openjscad.org/dist/index.js)

The input geometries are from https://github.com/gilboonet/manual_flattener/blob/master/aplat_manuel_base.jscad
so it may be that there is duplication there and it may be that my flattening logic introduces unintentional duplication.

But AFAICT the union of two closed CAGs can never not be a closed CAG, so the specifics of the geometries seems irrelevant, no? Either one of |c| or |d| in the original report should report as not being a closed CAG, or their union should not report as not being a closed CAG.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

So, it seems that the floating point math inside the booleans trees has a limitiation. Through the splitting of polygons, there are slight differences in the vertices created. Such as:

[-49.3186188, -15.8015509, -1.0000000] vs [-49.3186150, -15.8015509, -1.0000000]

This is expected because we are working with geometry represented by imprecised numbers. Sigh.

And I now know that by changing the EPS value, these values can be 'snapped' back together again. The appropriate value for this issue is 1e-4.

There has been a lot of discussion about having a different value for EPS (currently 1e-5). And some folks have suggested that the EPS should be calculated based on the geometry, as designs use different scales. #93

I'm not sure this solves anything but I just wanted to keep this information somewhere.

from csg.js.

z3dev avatar z3dev commented on June 16, 2024

I'm back. There was a recent change to the logic for 2D union/intersect/subtract, which basically snaps the points to a dynamically calculated EPS; jscad/OpenJSCAD.org#535. As a result, this issue can now be closed.

Here are the initial 2D geometries.
issue15-01

Here is the result of the union.
issue15-02

from csg.js.

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.