jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
218 stars 56 forks source link

Reorganization of Extrusions #183

Closed z3dev closed 5 years ago

z3dev commented 5 years ago

WORK IN PROGRESS. DO NOT MERGE.

This pull request adds the extrusion functions as a seperate module. The goals are:

Extrusions:

extrudeFromSlices (renamed soldFromSlices)

Fixes #67

extrudeLinear

extrudeRectangular

Fixes OpenJSCAD.org #404

extrudeRotate

Fixes #118

z3dev commented 5 years ago

HUGE REWRITE OF EXTRUSIONS

@fischman @kaosat-dev please clone and checkout this branch. there are major changes which need to be discussed.

@fischman see extrudeWalls.js for those cool functions. :)

@kaosat-dev you will probably HATE 'slice' so review solidFromSlices.js for how slice is used. i'm flexible and would like a better solution as well.

FYI, the basic premise of extrusions is that the given points are ORDERED. The ordering of points allows the creation of the side polygons, by creating triangular polygons between points A and B.

fischman commented 5 years ago

@z3dev sorry I haven't done any CAD in a long time, and have no opinions on this PR. My #111 was about adding a feature, but this PR (and #172, which I guess this is split off of?) are just about reorganizing/refactoring scaffolding without adding the feature I needed (and sent #111 to implement). I don't see myself doing anything with jscad v2 in the foreseeable future.

z3dev commented 5 years ago

My main headscratch atm is with the 'slices' data structure, I understand what you where shooting for, but some of it seems very close to geom2, so much so that it makes me wonder if we should not be using 3d coordinates for our 2d stuff ( Z set to 0 by default), this way they could exist in 3d space with no transformation ?)

Yeah. I did some head scratching too. There's a huge red spot on the top of my head now.

I'm thinking of another possibility as well, based on poly3. poly3 implies ordered points, but how to represent 'holes'?

kaosat-dev commented 5 years ago

I'm thinking of another possibility as well, based on poly3. poly3 implies ordered points, but how to represent 'holes'?

Wait wait , does this mean that the 2d data is NOT currently ordered ??

z3dev commented 5 years ago

Performance comparisons.

node --expose_gc --always_compact ./performanceV1.js
extrudeLinear(10x10circle),10,1000,0.001651682999999999,32
extrudeLinear(100x100circle),100,1000,0.086001338,6662
extrudeRectangular(10arc),10,1000,0.007269305999999992,31
extrudeRectangular(100arc),100,1000,0.08777639199999995,2690
extrudeRectangular(200arc),200,1000,0.24901723800000006,6870
extrudeRotate(10x10circle),10,1000,0.004467113999999998,49
extrudeRotate(100x100circle),100,1000,0.7617194799999996,4694

node --expose_gc --always_compact ./performanceV2.js
extrudeLinear(10x10circle),10,1000,0.0003879930000000003,16
extrudeLinear(100x100circle),100,1000,0.03169874600000003,7308
extrudeRectangular(10arc),10,1000,0.0009789999999999998,19
extrudeRectangular(100arc),100,1000,0.04147691900000001,1244
extrudeRectangular(200arc),200,1000,0.1947529439999998,4894
extrudeRotate(10x10circle),10,1000,0.00010015300000000016,1
extrudeRotate(100x100circle),100,1000,0.021659216000000037,2867
kaosat-dev commented 5 years ago

super changes !! Thanks ! :) is 'lower the better' for the benchmarks ? if that is the case V2 perf is better ?

z3dev commented 5 years ago

super changes !! Thanks ! :) is 'lower the better' for the benchmarks ? if that is the case V2 perf is better ?

Yup. V2 is faster. But these numbers are with normal arrays, not Float32Array.

z3dev commented 5 years ago

The last change was completed, changing extrudeLinear() to use ‘height’.

@kaosat-dev please review and merge.