topo4 fixups

This commit is contained in:
Stewart Allen 2025-07-12 15:43:51 -04:00
commit 4496f1dc78
3 changed files with 18 additions and 10 deletions

View file

@ -2,6 +2,7 @@
import { CamOp } from './op.js';
import { Tool } from './tool.js';
import { Topo4 } from './topo4.js';
import { newPoint } from '../../../geo/point.js';
function createFilter(op) {

View file

@ -4,6 +4,7 @@ import { codec } from '../../core/codec.js';
import { newPoint } from '../../../geo/point.js';
import { newPolygon } from '../../../geo/polygon.js';
import { sliceConnect } from '../../../geo/slicer.js';
import { newSlice } from '../../core/slice.js';
import { Tool } from './tool.js';
import { Slicer as topo_slicer } from './slicer_topo.js';
@ -16,7 +17,7 @@ function scale(fn, factor = 1, base = 0) {
}
}
class Topo4 {
class Topo {
constructor() { }
async generate(opt = {}) {
@ -132,7 +133,8 @@ class Topo4 {
slices.push(slice);
// console.log({ shards, range, step, slices });
if (kiri.minions.running > 1) {
const { minions } = self.kiri_worker;
if (minions?.running > 1) {
return await this.sliceMinions(onupdate);
} else {
return await this.sliceWorker(onupdate);
@ -202,7 +204,8 @@ class Topo4 {
}
async lathe(onupdate) {
if (kiri.minions.running > 1) {
const { minions } = self.kiri_worker;
if (minions?.running > 1) {
return await this.latheMinions(onupdate);
} else {
return await this.latheWorker(onupdate);
@ -444,24 +447,27 @@ class Topo4 {
}
putCache(key, data) {
kiri.worker.putCache({ key, data }, { done: data => { } });
const { dispatch } = self.kiri_worker;
dispatch.putCache({ key, data }, { done: data => { } });
}
clearCache() {
kiri.worker.clearCache({}, { done: data => { } });
const { dispatch } = self.kiri_worker;
dispatch.clearCache({}, { done: data => { } });
}
queue(cmd, params) {
const { minions } = self.kiri_worker;
return new Promise(resolve => {
kiri.minions.queue({ cmd, ...params }, resolve);
minions.queue({ cmd, ...params }, resolve);
});
}
}
function rotatePoints(lines, rot) {
export function rotatePoints(lines, rot) {
new THREE.BufferAttribute(lines, 3).applyMatrix4(rot);
}
export function Topo4(opt) {
return new Topo4().generate(opt);
return new Topo().generate(opt);
};

View file

@ -11,10 +11,11 @@ import { codec, encode, encodePointArray } from '../core/codec.js';
import { doTopShells } from '../mode/fdm/post.js';
import { newPoint } from '../../geo/point.js';
import { polygons as POLY } from '../../geo/polygons.js';
import { sliceZ } from '../../geo/slicer.js';
import { sliceZ, sliceConnect } from '../../geo/slicer.js';
import { Slicer as cam_slicer } from '../mode/cam/slicer.js';
import { Slicer as topo_slicer } from '../mode/cam/slicer_topo.js';
import { Probe, Trace, raster_slice } from '../mode/cam/topo3.js';
import { Topo4, rotatePoints } from '../mode/cam/topo4.js';
import { wasm_ctrl } from '../../geo/wasm.js';
const clib = self.ClipperLib;
@ -271,7 +272,7 @@ const funcs = self.minion = {
topo4_slice(data, seq) {
const { slice, resolution } = data;
const vertices = cache.vertices;
const recs = new kiri.topo_slicer(slice.index)
const recs = new topo_slicer(slice.index)
.setFromArray(vertices, slice)
.slice(resolution)
.map(rec => {