From e43cc7c97abb03d6f9fe4a5ae0c666ce0c107d75 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 10 Nov 2020 10:24:26 -0500 Subject: [PATCH] fix cam step over unit conversion bug. fix slicing floating point precision bug. bump rev 2.3.D5 --- notes.md | 3 +++ package.json | 2 +- src/kiri/init.js | 4 ++-- src/kiri/main.js | 6 +++++- src/kiri/slicer.js | 32 +++++++++++++++++++++++++------- src/kiri/slicer2.js | 6 ++---- src/license.js | 2 +- src/mode/fdm/slice.js | 36 +++++++++++++++++++++++++----------- src/moto/space.js | 15 +++++++++++++++ 9 files changed, 79 insertions(+), 27 deletions(-) diff --git a/notes.md b/notes.md index 278cd928..e383544b 100644 --- a/notes.md +++ b/notes.md @@ -16,11 +16,14 @@ # FDM +* `B` miter acute angles (benchy + square render) * `B` fix adaptive slicing with multi-extruder * `B` fix supports with grouped parts +* `B` fix preview/gcode layer size (first layer) * `F` speculative background preview generation * `F` control for size of purge block (with 0=disabled) * `F` add separate fill speed control +* `F` show retract/engage in preview * `F` manual support addition / control * `F` polishing and other non-planar work * `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo diff --git a/package.json b/package.json index 83655506..c4f13f6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grid-apps", - "version": "2.3.D4", + "version": "2.3.D5", "description": "grid.space 3d slice & modeling tools", "author": "Stewart Allen ", "license": "MIT", diff --git a/src/kiri/init.js b/src/kiri/init.js index 2d1ed538..a513db47 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1426,7 +1426,7 @@ camRough: UC.newGroup(LANG.cr_menu, null, {modes:CAM, marker:true}), camRoughTool: UC.newSelect(LANG.cc_tool, {modes:CAM}), camRoughSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}), - camRoughOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.1,1.0), modes:CAM, units:true}), + camRoughOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.1,1.0), modes:CAM}), camRoughDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM, units:true}), camRoughSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}), camRoughPlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM, units:true}), @@ -1447,7 +1447,7 @@ camContour: UC.newGroup(LANG.cn_menu, null, {modes:CAM, marker:true}), camContourTool: UC.newSelect(LANG.cc_tool, {modes:CAM}), camContourSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}), - camContourOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.05,1.0), modes:CAM, units:true}), + camContourOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.05,1.0), modes:CAM}), camContourSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}), camContourAngle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90), modes:CAM}), camContourCurves: UC.newBoolean(LANG.cf_curv_s, onBooleanClick, {title:LANG.cf_curv_l, modes:CAM}), diff --git a/src/kiri/main.js b/src/kiri/main.js index 33318cc9..7867b53e 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -1529,10 +1529,14 @@ } } - function settingsExport() { + function settingsExport(options) { + const opts = options || {}; + const shot = opts.screen ? SPACE.screenshot() : undefined; return btoa(JSON.stringify({ settings: settings, version: KIRI.version, + screen: shot, + space: SPACE.info, moto: MOTO.id, init: SDB.getItem('kiri-init'), time: Date.now() diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index f7f6a0b8..9f8ef548 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -50,6 +50,8 @@ simpleMode = options.simple, swap = options.swapX || options.swapY, isCam = options.cam, + debug = options.debug, + xray = options.xray, ox = 0, oy = 0; @@ -513,8 +515,23 @@ // for topo slices, we just need the raw lines if (!topoMode && !simpleMode) { - slice.groups = connectLines(slice.lines, slices.length); - POLY.nest(slice.groups).forEach(function(top) { slice.addTop(top) }); + slice.groups = connectLines(slice.lines, slice.z); + if ((debug && slice.lines.excessive) || xray) { + const dash = xray || 3; + slice.lines.forEach((line, i) => { + const group = i % dash; + const color = [ 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff ][group]; + slice.output().setLayer(`xl-${group}`, color).addLine(line.p1, line.p2); + }); + } + POLY.nest(slice.groups).forEach((poly, i) => { + slice.addTop(poly); + if (xray) { + const group = i % (xray || 3); + const color = [ 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff ][group]; + slice.output().setLayer(`xg-${group}`, color).addPoly(poly); + } + }); } // fixup un-rotates polygons for CAM @@ -543,7 +560,7 @@ } } else if (simpleMode) { // fdm polishing mode - slice.groups = connectLines(slice.lines, slices.length); + slice.groups = connectLines(slice.lines, slice.z); slice.groups.forEach(poly => { poly.swap(options.swapX, options.swapY); poly.move(move); @@ -566,7 +583,7 @@ * @param {number} [index] * @returns {Array} */ - function connectLines(input) { + function connectLines(input, z) { // map points to all other points they're connected to let DBUG = BASE.debug, CONF = BASE.config, @@ -611,7 +628,8 @@ function findPathsMinRecurse(point, path, paths, from) { let stack = [ ]; if (paths.length > 10000) { - DBUG.log("excessive path options @ "+paths.length+" #"+input.length); + DBUG.log(`indeterminate path @ ${z} from paths=${paths.length} input=${input.length}`); + input.excessive = paths.length; return; } for (;;) { @@ -721,8 +739,8 @@ // create point map, unique point list and point group arrays input.forEach(function(line) { - p1 = cachedPoint(line.p1.round(7)); - p2 = cachedPoint(line.p2.round(7)); + p1 = cachedPoint(line.p1.round(4)); + p2 = cachedPoint(line.p2.round(4)); addConnected(p1,p2); addConnected(p2,p1); }); diff --git a/src/kiri/slicer2.js b/src/kiri/slicer2.js index 06ccd484..3a3cd4f4 100644 --- a/src/kiri/slicer2.js +++ b/src/kiri/slicer2.js @@ -4,8 +4,6 @@ (function() { - if (self.kiri.slicer2) return; - let KIRI = self.kiri, BASE = self.base, CONF = BASE.config, @@ -623,8 +621,8 @@ // create point map, unique point list and point group arrays input.forEach(function(line) { - p1 = cachedPoint(line.p1.round(7)); - p2 = cachedPoint(line.p2.round(7)); + p1 = cachedPoint(line.p1.round(4)); + p2 = cachedPoint(line.p2.round(4)); addConnected(p1,p2); addConnected(p2,p1); }); diff --git a/src/license.js b/src/license.js index d6371d52..f50162eb 100644 --- a/src/license.js +++ b/src/license.js @@ -3,7 +3,7 @@ let terms = { COPYRIGHT: "Copyright (C) Stewart Allen - All Rights Reserved", LICENSE: "See the license.md file included with the source distribution", - VERSION: "2.3.D4" + VERSION: "2.3.D5" }; if (typeof(module) === 'object') { diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index f0531c42..76643e51 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -91,11 +91,35 @@ spro.firstSliceHeight = sliceHeight; } + // const slicer = new KIRI.slicer2(widget.getPoints(), { }); + // const levels = slicer.interval(sliceHeight, { + // zlist: true, + // zline: true, + // boff: spro.firstSliceHeight || spro.sliceHeight + // }); + // const slices = []; + // let last; + // slicer.slice(levels, { genso: true, each: (data, idx, tot, time) => { + // const slice = data.slice; + // if (last) { + // slice.down = last; + // last.up = slice; + // } + // last = slice; + // slice.index = idx; + // slice.height = spro.firstSliceHeight || spro.sliceHeight; + // slices.push(slice); + // onupdate((idx / tot) * 0.5); + // } }); + // onSliceDone(slices); + SLICER.sliceWidget(widget, { height: sliceHeight, minHeight: sliceHeight > spro.sliceMinHeight ? spro.sliceMinHeight : 0, firstHeight: spro.firstSliceHeight, - view: view + // debug: true, + // xray: 3, + // view: view }, onSliceDone, onSliceUpdate); function onSliceUpdate(update) { @@ -121,14 +145,6 @@ return; } - // if (!isThin && slices.length > 100) { - // isFlat = true; - // } - - // if (slices.length > 150) { - // isThin = true; - // } - // calculate % complete and call onupdate() function doupdate(index, from, to, msg) { onupdate(0.5 + (from + ((index/slices.length) * (to-from))) * 0.5, msg); @@ -318,7 +334,6 @@ */ function doShells(slice, count, offset1, offsetN, fillOffset, options) { const opt = options || {}; - slice.tops.forEach(function(top) { let top_poly = [ top.poly ]; @@ -617,7 +632,6 @@ if (slice.index === 0 && !fakedown) { return; } - const top = slice, down = slice.down || (fakedown ? newSlice(-1) : null), topInner = sla ? top.topPolys() : top.topInners(), diff --git a/src/moto/space.js b/src/moto/space.js index e8315f1a..11738b22 100644 --- a/src/moto/space.js +++ b/src/moto/space.js @@ -785,6 +785,10 @@ return renderer.domElement.toDataURL(format || "image/png"); }, + internals: function() { + return { renderer, camera }; + }, + init: function(domelement, slider) { container = domelement; @@ -894,6 +898,17 @@ animate(); + const ctx = renderer.getContext(); + const ext = ctx.getExtension('WEBGL_debug_renderer_info'); + const nav = navigator; + Space.info = { + ver: ctx.getParameter(ctx.VERSION), + ven: ctx.getParameter(ctx.VENDOR), + glr: ctx.getParameter(ext.UNMASKED_RENDERER_WEBGL), + // glv: ctx.getParameter(ext.UNMASKED_VENDOR_WEBGL), + pla: nav.platform + }, + initialized = true; } };