Skip to content

Commit 74ed9e5

Browse files
committed
Merge branch 'develop'
2 parents 246522e + 6be1291 commit 74ed9e5

40 files changed

+2409
-1509
lines changed

DOCS.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Doodle3D Slicer
2+
This document explains how the slice process works.
3+
4+
In this slicer Z is the "up" vector.
5+
6+
Requisites
7+
- 2D Vector math
8+
- 3D Vector math
9+
- 2D Boolean operations (union, difference)
10+
- 2D Path offsetting
11+
12+
### Step 0: Preparation
13+
The first step is to prepare the data for slicing. Most of the model data is mapped into `typed arrays`. This way they can be send to the worker very efficiently (due to the transferable nature of typed arrays).
14+
```
15+
Vertices: Float32Array
16+
Faces: Uint32Array
17+
ObjectIndexes: UInt8Array
18+
OpenObjectIndexes: [...Int]
19+
Settings:
20+
startCode: String
21+
endcode: String
22+
dimensions:
23+
x: Number
24+
y: Number
25+
z: Number
26+
heatedBed: Bool
27+
nozzleDiameter: Number
28+
filamentThickness: Number
29+
temperature: Number
30+
bedTemperature: Number
31+
layerHeight: Number
32+
combing: Bool
33+
thickness:
34+
top: Number
35+
bottom: Number
36+
shell: Number
37+
retraction:
38+
enabled: Bool
39+
amount: Number
40+
speed: Number
41+
minDistance: Number
42+
travel:
43+
speed: Number
44+
support:
45+
enabled: Bool
46+
minArea: Number
47+
distanceY: Number
48+
density: Number
49+
margin: Number
50+
flowRate: Number
51+
speed: Number
52+
innerShell:
53+
flowRate: Number
54+
speed: Number
55+
outerShell:
56+
flowRate: Number
57+
speed: Number
58+
innerInfill:
59+
flowRate: Number
60+
speed: Number
61+
density: Number
62+
outerInfill:
63+
flowRate: Number
64+
speed: Number
65+
brim:
66+
size: Number
67+
flowRate: Number
68+
speed: Number
69+
firstLayer:
70+
flowRate: Number
71+
speed: Number
72+
```
73+
- Vertices: List of points in 3d
74+
- Faces: Indexes refering to points in the vertices list that make a triangular surface
75+
- ObjectIndexes: Describes of what object each face is part of (important for the generating of 2d shapes)
76+
- OpenObjectIndexes: Determines weather a object is open or closed (important for the generating of 2d shapes)
77+
- Settings: object containing all the settings for slicing. We go in depth in this object when it's needed
78+
79+
### Step 1: Creating lines
80+
In this we take the 3d model and look at each surface to extract all individual lines. Note some lines are part of multiple surfaces. In addition we also add some additional data to each line, like the surfaces it is part of we'll also store the 2d normal.
81+
82+
```
83+
function calculateNormal(vertices, a, b, c) {
84+
a = getVertex(vertices, a);
85+
b = getVertex(vertices, b);
86+
c = getVertex(vertices, c);
87+
88+
const cb = vector3.subtract(c, b);
89+
const ab = vector3.subtract(a, b);
90+
const normal = vector3.normalize(vector3.cross(cb, ab));
91+
92+
return normal;
93+
}
94+
```
95+
96+
In order to extract all unique lines from the model we'll loop through each face of the model.
97+
98+
### Step 2: Calculate Layers Intersections
99+
This is a fairly straight forward step. We take the lines and calculate on what layers that line will be intersecting. Additinally we calculate the coordinates where the line intersects each layer.
100+
101+
### Step 3: Intersections To Shapes
102+
### Step 4: Shapes To Slices
103+
### Step 5: Generate Inner Lines
104+
### Step 6: Generate Outlines
105+
### Step 7: Generate Infills
106+
### Step 8: Generate Support
107+
### Step 9: AddBrim
108+
109+
```
110+
let {
111+
brim: { size: brimSize },
112+
nozzleDiameter
113+
} = settings;
114+
115+
nozzleDiameter /= PRECISION;
116+
brimSize /= PRECISION;
117+
const nozzleRadius = nozzleDiameter / 2;
118+
119+
const [firstLayer] = slices;
120+
121+
const brim = firstLayer.parts.reduce((brim, { shape }) => (
122+
brim.join(shape.offset(nozzleRadius, {
123+
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
124+
}))
125+
), new Shape([], true)).simplify('pftNonZero');
126+
127+
firstLayer.brim = new Shape([], true);
128+
129+
for (let offset = 0; offset < brimSize; offset += nozzleDiameter) {
130+
const brimPart = brim.offset(offset, OFFSET_OPTIONS);
131+
firstLayer.brim = firstLayer.brim.join(brimPart);
132+
}
133+
```
134+
135+
### Step 10: Optimize Paths
136+
### Step 11: Slices To GCode

favicon.ico

4.19 KB
Binary file not shown.

img/logo.png

45.7 KB
Loading

index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import 'babel-polyfill'
22
import React from 'react';
33
import { Interface } from 'doodle3d-slicer';
4-
import doodleURL from '!url-loader!./models/Doodle_2.d3sketch';
54
import { render } from 'react-dom';
65
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
76
import injectTapEventPlugin from 'react-tap-event-plugin';
87
import jss from 'jss';
98
import preset from 'jss-preset-default';
109
import normalize from 'normalize-jss';
11-
import JSONToSketchData from 'doodle3d-core/shape/JSONToSketchData';
12-
import createSceneData from 'doodle3d-core/d3/createSceneData.js';
13-
import { generateExportMesh } from 'doodle3d-core/utils/exportUtils.js';
14-
import { Matrix4 } from 'three/src/math/Matrix4.js';
10+
import queryString from 'query-string';
11+
import getMuiTheme from 'material-ui/styles/getMuiTheme';
12+
import { grey400, blue500, blue700 } from 'material-ui/styles/colors';
13+
14+
const muiTheme = getMuiTheme({
15+
palette: {
16+
primary1Color: blue500,
17+
primary2Color: blue700,
18+
accent1Color: blue500,
19+
}
20+
});
1521

1622
injectTapEventPlugin();
1723

@@ -26,17 +32,11 @@ jss.createStyleSheet({
2632
}
2733
}).attach();
2834

29-
function init(mesh) {
30-
render((
31-
<MuiThemeProvider>
32-
<Interface mesh={mesh} name="doodle"/>
33-
</MuiThemeProvider>
34-
), document.getElementById('app'));
35-
}
35+
let { file, selectedPrinter, actions } = queryString.parse(location.search);
36+
if (actions) actions = JSON.parse(actions);
3637

37-
fetch(doodleURL)
38-
.then(resonse => resonse.json())
39-
.then(json => JSONToSketchData(json))
40-
.then(file => createSceneData(file))
41-
.then(sketch => generateExportMesh(sketch, { offsetSingleWalls: false, matrix: new Matrix4() }))
42-
.then(init);
38+
render((
39+
<MuiThemeProvider muiTheme={muiTheme}>
40+
<Interface actions={actions} fileUrl={file} selectedPrinter={selectedPrinter} name="doodle"/>
41+
</MuiThemeProvider>
42+
), document.getElementById('app'));

0 commit comments

Comments
 (0)