mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
don't combine layerpoints and layer face indexes into objects
This commit is contained in:
parent
4b17325c3f
commit
4352293e95
@ -8,10 +8,8 @@ export default function calculateLayersIntersections(lines, settings) {
|
|||||||
|
|
||||||
const numLayers = Math.floor((dimensionsZ - Z_OFFSET) / layerHeight);
|
const numLayers = Math.floor((dimensionsZ - Z_OFFSET) / layerHeight);
|
||||||
|
|
||||||
const layers = Array.from(Array(numLayers)).map(() => ({
|
const layerPoints = Array.from(Array(numLayers)).map(() => []);
|
||||||
points: {},
|
const layerFaceIndexes = Array.from(Array(numLayers)).map(() => []);
|
||||||
faceIndexes: []
|
|
||||||
}));
|
|
||||||
|
|
||||||
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
|
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
|
||||||
const { line, faces } = lines[lineIndex];
|
const { line, faces } = lines[lineIndex];
|
||||||
@ -34,20 +32,18 @@ export default function calculateLayersIntersections(lines, settings) {
|
|||||||
z = line.end.z * alpha + line.start.z * alpha1;
|
z = line.end.z * alpha + line.start.z * alpha1;
|
||||||
}
|
}
|
||||||
|
|
||||||
layers[layerIndex].points[lineIndex] = { x: z, y: x };
|
layerPoints[layerIndex][lineIndex] = { x: z, y: x };
|
||||||
layers[layerIndex].faceIndexes.push(...faces);
|
layerFaceIndexes[layerIndex].push(...faces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < layers.length; i ++) {
|
for (let i = 0; i < layerFaceIndexes.length; i ++) {
|
||||||
const layer = layers[i];
|
layerFaceIndexes[i] = layerFaceIndexes[i].reduce((result, faceIndex) => {
|
||||||
|
|
||||||
layer.faceIndexes = layer.faceIndexes.reduce((result, faceIndex) => {
|
|
||||||
if (!result.includes(faceIndex)) result.push(faceIndex);
|
if (!result.includes(faceIndex)) result.push(faceIndex);
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
return layers;
|
return { layerPoints, layerFaceIndexes };
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import { subtract, normal, normalize, dot, almostEquals } from './helpers/vector2D.js';
|
import { subtract, normal, normalize, dot, almostEquals } from './helpers/vector2D.js';
|
||||||
|
|
||||||
export default function intersectionsToShapes(intersectionLayers, faces, openObjectIndexes, settings) {
|
export default function intersectionsToShapes(layerPoints, layerFaceIndexes, faces, openObjectIndexes, settings) {
|
||||||
const layers = [];
|
const layers = [];
|
||||||
|
|
||||||
for (let layer = 0; layer < intersectionLayers.length; layer ++) {
|
for (let layer = 0; layer < layerPoints.length; layer ++) {
|
||||||
const fillShapes = [];
|
const fillShapes = [];
|
||||||
const lineShapesOpen = [];
|
const lineShapesOpen = [];
|
||||||
const lineShapesClosed = [];
|
const lineShapesClosed = [];
|
||||||
|
|
||||||
const { points, faceIndexes } = intersectionLayers[layer];
|
const points = layerPoints[layer];
|
||||||
|
const faceIndexes = layerFaceIndexes[layer];
|
||||||
|
|
||||||
if (faceIndexes.length === 0) continue;
|
if (faceIndexes.length === 0) continue;
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev
|
|||||||
const { lines, faces } = createLines(geometry, settings);
|
const { lines, faces } = createLines(geometry, settings);
|
||||||
|
|
||||||
updateProgress('Calculating layer intersections');
|
updateProgress('Calculating layer intersections');
|
||||||
const layers = calculateLayersIntersections(lines, settings);
|
const { layerPoints, layerFaceIndexes } = calculateLayersIntersections(lines, settings);
|
||||||
|
|
||||||
updateProgress('Constructing shapes from intersections');
|
updateProgress('Constructing shapes from intersections');
|
||||||
const shapes = intersectionsToShapes(layers, faces, openObjectIndexes, settings);
|
const shapes = intersectionsToShapes(layerPoints, layerFaceIndexes, faces, openObjectIndexes, settings);
|
||||||
|
|
||||||
applyPrecision(shapes);
|
applyPrecision(shapes);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user