From 229929e4e86f3827876d5e2733706947c1677ef5 Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Tue, 6 Mar 2018 17:49:39 +0100 Subject: [PATCH] update docs --- DOCS.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/DOCS.md b/DOCS.md index 4d274a8..39ecb2b 100644 --- a/DOCS.md +++ b/DOCS.md @@ -10,7 +10,7 @@ Requisites - 2D Path offsetting ### Step 0: Preparation -The first step is to prepare the data for slicing. +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). ``` Vertices: Float32Array Faces: Uint32Array @@ -77,4 +77,60 @@ Settings: - Settings: object containing all the settings for slicing. We go in depth in this object when it's needed ### Step 1: Creating lines -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 +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. + +``` +function calculateNormal(vertices, a, b, c) { + a = getVertex(vertices, a); + b = getVertex(vertices, b); + c = getVertex(vertices, c); + + const cb = vector3.subtract(c, b); + const ab = vector3.subtract(a, b); + const normal = vector3.normalize(vector3.cross(cb, ab)); + + return normal; +} +``` + +In order to extract all unique lines from the model we'll loop through each face of the model. + +### Step 2: Calculate Layers Intersections +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. + +### Step 3: Intersections To Shapes +### Step 4: Shapes To Slices +### Step 5: Generate Inner Lines +### Step 6: Generate Outlines +### Step 7: Generate Infills +### Step 8: Generate Support +### Step 9: AddBrim + +``` +let { + brim: { size: brimSize }, + nozzleDiameter +} = settings; + +nozzleDiameter /= PRECISION; +brimSize /= PRECISION; +const nozzleRadius = nozzleDiameter / 2; + +const [firstLayer] = slices; + +const brim = firstLayer.parts.reduce((brim, { shape }) => ( + brim.join(shape.offset(nozzleRadius, { + endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound' + })) +), new Shape([], true)).simplify('pftNonZero'); + +firstLayer.brim = new Shape([], true); + +for (let offset = 0; offset < brimSize; offset += nozzleDiameter) { + const brimPart = brim.offset(offset, OFFSET_OPTIONS); + firstLayer.brim = firstLayer.brim.join(brimPart); +} +``` + +### Step 10: Optimize Paths +### Step 11: Slices To GCode