Comments (12)
@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.
From @fischman on October 26, 2016 15:14
FWIW I get the same failure on openjscad.org and locally on e16c68a141437321d75b7401d48a851de2b48929
from csg.js.
@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.
@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.
This issue was moved to z3dev/hello-world#3
from csg.js.
Ooops! The tools automatically closed this. Reopening.
from csg.js.
@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.
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.
@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.
@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.
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.
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.
Here is the result of the union.
from csg.js.
Related Issues (20)
- V2 : Paths Discussion HOT 10
- V2: Split into Specialized Functions / Modules HOT 2
- swept volume of a solid following a path HOT 3
- Feature Request: Polygon is self intersecting! error message should show details HOT 2
- Feature Request:Retain the UV information of the geometry. HOT 1
- Use typescript to refactor the project? HOT 15
- Code optimization HOT 4
- Evaluate csg optimization HOT 7
- The subtraction sometimes falls in the infinite loop HOT 6
- V2 : Cleanup : Decompose OrthoNormalBasis into functional API HOT 1
- Did there used to be a layFlat() method? HOT 3
- V2 : Cleanup : Review API to color functions
- 2d translate doesn't operate in Z plane HOT 11
- V2 : API Suggestions HOT 4
- V2 : `reTesselateCoplanarPolygons` seems to have a problem HOT 13
- Difference result is not ideal HOT 4
- api.md useless without context HOT 3
- Simplify the use of csj.js in the browser HOT 8
- Color information lost after boolean operations HOT 12
- V1 : Cuboid not exported HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csg.js.