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 layers = Array.from(Array(numLayers)).map(() => ({
|
||||
points: {},
|
||||
faceIndexes: []
|
||||
}));
|
||||
const layerPoints = Array.from(Array(numLayers)).map(() => []);
|
||||
const layerFaceIndexes = Array.from(Array(numLayers)).map(() => []);
|
||||
|
||||
for (let lineIndex = 0; lineIndex < lines.length; 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;
|
||||
}
|
||||
|
||||
layers[layerIndex].points[lineIndex] = { x: z, y: x };
|
||||
layers[layerIndex].faceIndexes.push(...faces);
|
||||
layerPoints[layerIndex][lineIndex] = { x: z, y: x };
|
||||
layerFaceIndexes[layerIndex].push(...faces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < layers.length; i ++) {
|
||||
const layer = layers[i];
|
||||
|
||||
layer.faceIndexes = layer.faceIndexes.reduce((result, faceIndex) => {
|
||||
for (let i = 0; i < layerFaceIndexes.length; i ++) {
|
||||
layerFaceIndexes[i] = layerFaceIndexes[i].reduce((result, faceIndex) => {
|
||||
if (!result.includes(faceIndex)) result.push(faceIndex);
|
||||
return result;
|
||||
}, []);
|
||||
}
|
||||
|
||||
return layers;
|
||||
return { layerPoints, layerFaceIndexes };
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
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 = [];
|
||||
|
||||
for (let layer = 0; layer < intersectionLayers.length; layer ++) {
|
||||
for (let layer = 0; layer < layerPoints.length; layer ++) {
|
||||
const fillShapes = [];
|
||||
const lineShapesOpen = [];
|
||||
const lineShapesClosed = [];
|
||||
|
||||
const { points, faceIndexes } = intersectionLayers[layer];
|
||||
const points = layerPoints[layer];
|
||||
const faceIndexes = layerFaceIndexes[layer];
|
||||
|
||||
if (faceIndexes.length === 0) continue;
|
||||
|
||||
|
@ -34,10 +34,10 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev
|
||||
const { lines, faces } = createLines(geometry, settings);
|
||||
|
||||
updateProgress('Calculating layer intersections');
|
||||
const layers = calculateLayersIntersections(lines, settings);
|
||||
const { layerPoints, layerFaceIndexes } = calculateLayersIntersections(lines, settings);
|
||||
|
||||
updateProgress('Constructing shapes from intersections');
|
||||
const shapes = intersectionsToShapes(layers, faces, openObjectIndexes, settings);
|
||||
const shapes = intersectionsToShapes(layerPoints, layerFaceIndexes, faces, openObjectIndexes, settings);
|
||||
|
||||
applyPrecision(shapes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user