remove largely unused debug class

This commit is contained in:
Stewart Allen 2021-07-04 21:05:46 -04:00
commit 6337cae736
15 changed files with 30 additions and 281 deletions

5
app.js
View file

@ -230,7 +230,6 @@ const script = {
"add/array", "add/array",
"add/three", "add/three",
"geo/base", "geo/base",
"geo/debug",
"geo/render", "geo/render",
"geo/point", "geo/point",
"geo/points", "geo/points",
@ -289,7 +288,6 @@ const script = {
"add/class", "add/class",
"geo/base", "geo/base",
// "geo/wasm", // "geo/wasm",
"geo/debug",
"geo/point", "geo/point",
"geo/points", "geo/points",
"geo/slope", "geo/slope",
@ -333,7 +331,6 @@ const script = {
"add/array", "add/array",
"add/class", "add/class",
"geo/base", "geo/base",
"geo/debug",
"geo/point", "geo/point",
"geo/points", "geo/points",
"geo/slope", "geo/slope",
@ -358,7 +355,6 @@ const script = {
"add/array", "add/array",
"add/three", "add/three",
"geo/base", "geo/base",
"geo/debug",
"geo/render", "geo/render",
"geo/point", "geo/point",
"geo/points", "geo/points",
@ -389,7 +385,6 @@ const script = {
"add/array", "add/array",
"add/three", "add/three",
"geo/base", "geo/base",
"geo/debug",
"geo/render", "geo/render",
"geo/point", "geo/point",
"geo/slope", "geo/slope",

View file

@ -1,219 +0,0 @@
/** Copyright 2014-2019 Stewart Allen -- All Rights Reserved */
"use strict";
(function() {
if (self.base.debug) return;
const base = self.base,
flags = {},
stash = [],
debug_colors = [0xff0000, 0x00ff00, 0x0000ff, 0x00ffff, 0xff00ff, 0xffff00];
let size = 20,
enabled = false,
next_debug_color = 0;
/** ******************************************************************
* Debug Functions
******************************************************************* */
function log(o) {
console.log(o);
if (enabled) {
stash.push(o);
while (stash.length > size) stash.shift();
}
}
function enable(history) {
enabled = true;
if (history) size = Math.abs(history);
}
function disable() {
enabled = false;
}
function on() {
return enabled;
}
function history() {
return stash;
}
function last() {
return stash[stash.length-1];
}
function trace(msg) {
if (msg && typeof msg != 'string') msg = JSON.stringify(msg);
log(new Error(msg).stack);
}
function view() {
return base.debug.view;
}
function setView(view) {
base.debug.view = view;
}
function get(f) {
return flags[f];
}
function set(f, value) {
if (Array.isArray(f)) {
for (let i=0; i<f.length; i++) flags[f[i]] = (value || 1);
} else {
flags[f] = (value || 1);
}
}
function clear(f) {
if (Array.isArray(f)) {
for (let i = 0; i < f.length; i++) delete flags[f[i]];
} else {
delete flags[f];
}
}
function test(isSet, isNotSet) {
let i;
if (isNotSet) {
if (Array.isArray(isNotSet)) {
for (i=0; i<isNotSet.length; i++) {
if (flags[isNotSet[i]]) return null;
}
} else {
if (flags[isNotSet]) return null;
}
}
if (isSet) {
if (Array.isArray(isSet)) {
for (i=0; i<isSet.length; i++) {
if (!flags[isSet[i]]) return null;
}
} else {
if (!flags[isSet]) return null;
}
}
return view() || true;
}
function nextDebugColor() {
return debug_colors[next_debug_color++ % debug_colors.length];
}
/**
* render point array as discrete points
*
* @param {Point[]} points
* @param {number} [color]
* @param {number} [opacity]
* @param {number} [size]
* @returns {THREE.PointCloud}
*/
function points(points, color, opacity, size) {
view().points(points, color, size);
}
/**
*
* @param {Point[]} points
* @param {number} color
* @returns {THREE.Line}
*/
function lines(points, color) {
view().lines(points, color);
}
/**
*
* @param {Polygon} poly
* @param {number} color
* @param {boolean} [recurse]
* @returns {THREE.Object}
*/
function polygon(poly, color, recurse) {
return poly.render(view(), color, recurse);
}
/**
* debug polygon
*
* @param {Polygon} poly
* @param {number} [z]
* @param {Layer} [v]
* @param {boolean} [deep]
* @param {boolean} [creep]
*/
function xray(poly, z, v, deep, creep) {
let colors = [
0xaa0000,
0x0,
0xaaaa00,
0x444444,
0x00ff00,
0x888888,
0x00aaaa,
0x0,
0x0000aa,
0x444444,
0xaa00aa,
0x888888
],
cidx = 0,
point,
next,
layer = v || view();
if (typeof(z) === 'number') poly.setZ(z);
poly.forEachPoint(function(next) {
if (!point) return next = point;
if (creep) next.z = (z = z + 0.1);
layer.lines([point.clone(), next.clone()], colors[cidx++ % colors.length]);
point = next;
});
layer.lines([poly.last().clone(), poly.first().clone()], 0xffffff);
layer.points(poly.points, 0x000000, 0.1);
layer.points([poly.first()], 0xffffff, 0.4);
layer.points([poly.last()], 0x555555, 0.45);
if (deep && poly.inner) {
poly.inner.forEach(function(p) { xray(p, z, v, false, creep) });
}
}
/** ******************************************************************
* Connect to base
******************************************************************* */
base.debug = {
on : on,
enable : enable,
disable : disable,
history : history,
last : last,
get : get,
set : set,
clear : clear,
log : log,
trace : trace,
test : test,
view : null,
setView : setView,
color : nextDebugColor,
xray : xray,
points : points,
lines : lines,
polygon : polygon,
slice : null, // todo temp
};
})();

View file

@ -13,20 +13,14 @@
ROUND = UTIL.round; ROUND = UTIL.round;
class Point { class Point {
constructor(x,y,z,key,CP) { constructor(x,y,z,key) {
if (CP) {
console.trace({x,y,z,key,CP});
throw "deprecated point constructor"
} else {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z || 0; this.z = z || 0;
if (key) { if (key) {
this._key = key; this._key = key;
} }
}
this.poly = null; // parent polygon this.poly = null; // parent polygon
this.pos = 0; // position in group
} }
get key() { get key() {
@ -710,11 +704,10 @@
* @param {number} y * @param {number} y
* @param {number} z * @param {number} z
* @param {String} [key] * @param {String} [key]
* @param {Object} [CP] clipper point
* @returns {Point} * @returns {Point}
*/ */
function newPoint(x, y, z, key, CP) { function newPoint(x, y, z, key) {
return new Point(x, y, z, key, CP); return new Point(x, y, z, key);
} }
})(); })();

View file

@ -4,9 +4,8 @@
(function() { (function() {
const BASE = self.base, const BASE = self.base;
DBUG = BASE.debug, const CONF = BASE.config;
CONF = BASE.config;
BASE.verticesToPoints = verticesToPoints; BASE.verticesToPoints = verticesToPoints;
BASE.pointsToVertices = pointsToVertices; BASE.pointsToVertices = pointsToVertices;
@ -104,7 +103,7 @@
// if (passes) console.trace({passes, threshold, precision, maxpass}); // if (passes) console.trace({passes, threshold, precision, maxpass});
if (passes) DBUG.log({ if (passes) console.log({
before: array.length / 3, before: array.length / 3,
after: parr.length, after: parr.length,
unique: unique, unique: unique,

View file

@ -9,7 +9,6 @@
const BASE = self.base, const BASE = self.base,
CONF = BASE.config, CONF = BASE.config,
UTIL = BASE.util, UTIL = BASE.util,
DBUG = BASE.debug,
KEYS = BASE.key, KEYS = BASE.key,
SQRT = Math.sqrt, SQRT = Math.sqrt,
POLY = function() { return BASE.polygons }, POLY = function() { return BASE.polygons },

View file

@ -745,9 +745,7 @@
while (i < polygons.length) { while (i < polygons.length) {
let polygon = polygons[i++], let polygon = polygons[i++],
pp = polygon.points, pp = polygon.points,
pl = pp.length, pl = pp.length;;
dbug = BASE.debug,
debug = false;
for (let j = 0; j < pl; j++) { for (let j = 0; j < pl; j++) {
let j2 = (j + 1) % pl, let j2 = (j + 1) % pl,
ip = UTIL.intersectRayLine(start, slope, pp[j], pp[j2]); ip = UTIL.intersectRayLine(start, slope, pp[j], pp[j2]);
@ -760,13 +758,9 @@
if (ip.isNear(pp[j], merge_dist)) { if (ip.isNear(pp[j], merge_dist)) {
ip.pos = j; ip.pos = j;
ip.mod = pl; ip.mod = pl;
if (debug) dbug.points([ip], 0x0000ff, 0.5, 1.0);
} else if (ip.isNear(pp[j2], merge_dist)) { } else if (ip.isNear(pp[j2], merge_dist)) {
ip.pos = j2; ip.pos = j2;
ip.mod = pl; ip.mod = pl;
if (debug) dbug.points([ip], 0x00ffff, 0.5, 0.85);
} else {
if (debug) dbug.points([ip], 0xff00ff, 0.5, 0.5);
} }
} }
} }
@ -788,7 +782,7 @@
* was added later. see below for what else can happen. * was added later. see below for what else can happen.
*/ */
if (line.length < 2) { if (line.length < 2) {
dbug.log("sliceInt: line common ep fail: "+line.length); console.log("sliceInt: line common ep fail: "+line.length);
} else } else
if (line.length > 2) { if (line.length > 2) {
p1.del = true; p1.del = true;
@ -804,11 +798,9 @@
del = true; del = true;
p1.del = true; p1.del = true;
p2.del = true; p2.del = true;
if (debug) dbug.points([p1, p2], 0xffffff, 0.2, 1);
} else { } else {
del = true; del = true;
p1.del = true; p1.del = true;
if (debug) dbug.points([p1], 0xffff00, 0.2, 0.85);
} }
} }
return p1.dist - p2.dist; // sort on 'a' dist from ray origin return p1.dist - p2.dist; // sort on 'a' dist from ray origin
@ -839,7 +831,6 @@
// p1.del = true; // p1.del = true;
// p2.del = true; // p2.del = true;
// del = true; // del = true;
// if (debug) dbug.points([p1, p2], 0xfff000, 0.2, 2);
//} //}
// check cull co-linear with group edge // check cull co-linear with group edge
if (same && p1.mod && p2.mod) { if (same && p1.mod && p2.mod) {
@ -848,7 +839,6 @@
p1.del = true; p1.del = true;
p2.del = true; p2.del = true;
del = true; del = true;
if (debug) dbug.points([p1, p2], 0xffffff, 0.2, 1.85);
} }
} }
} }

View file

@ -1,4 +1,4 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
"use strict"; "use strict";
@ -203,7 +203,7 @@
function gridhost_tracker(host,key) { function gridhost_tracker(host,key) {
ajax(host+"/api/check?key="+key, function(data) { ajax(host+"/api/check?key="+key, function(data) {
data = js2o(data); data = js2o(data);
DBUG.log(data); console.log(data);
if (!(data.done || data.error)) { if (!(data.done || data.error)) {
setTimeout(function() { gridhost_tracker(host,key) }, 1000); setTimeout(function() { gridhost_tracker(host,key) }, 1000);
} }
@ -373,7 +373,7 @@
gridhost_tracker(host,json.key); gridhost_tracker(host,json.key);
API.ajax(host+"/api/wait?key="+json.key, function(data) { API.ajax(host+"/api/wait?key="+json.key, function(data) {
data = js2o(data); data = js2o(data);
DBUG.log(data); console.log(data);
API.show.alert("print to "+target+": "+data.status, 600); API.show.alert("print to "+target+": "+data.status, 600);
}); });
} else { } else {

View file

@ -1,4 +1,4 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
"use strict"; "use strict";
@ -8,7 +8,6 @@
KIRI = self.kiri, KIRI = self.kiri,
BASE = self.base, BASE = self.base,
UTIL = BASE.util, UTIL = BASE.util,
DBUG = BASE.debug,
LANG = KIRI.lang.current, LANG = KIRI.lang.current,
WIN = self.window, WIN = self.window,
DOC = self.document, DOC = self.document,
@ -56,8 +55,6 @@
saveTimer = null, saveTimer = null,
noop = () => {}; noop = () => {};
DBUG.enable();
// add show() to catalog for API // add show() to catalog for API
CATALOG.show = showCatalog; CATALOG.show = showCatalog;
@ -1134,7 +1131,7 @@
API.event.emit('slice.end', getMode()); API.event.emit('slice.end', getMode());
// print stats // print stats
segtimes.total = Date.now() - now; segtimes.total = Date.now() - now;
DBUG.log(segtimes); console.log(segtimes);
if (callback && typeof callback === 'function') { if (callback && typeof callback === 'function') {
callback(); callback();
} }
@ -1231,7 +1228,7 @@
// print stats // print stats
segtimes.total = Date.now() - now; segtimes.total = Date.now() - now;
DBUG.log(segtimes); console.log(segtimes);
API.event.emit('print', pMode); API.event.emit('print', pMode);
API.event.emit('preview.end', pMode); API.event.emit('preview.end', pMode);
@ -2483,7 +2480,7 @@
function loadFile() { function loadFile() {
$('load-file').onchange = function(event) { $('load-file').onchange = function(event) {
DBUG.log(event); console.log(event);
platformLoadFiles(event.target.files); platformLoadFiles(event.target.files);
}; };
$('load-file').click(); $('load-file').click();
@ -2908,7 +2905,7 @@
setWidgetVisibility(true); setWidgetVisibility(true);
break; break;
default: default:
DBUG.log("invalid view mode: "+mode); console.log("invalid view mode: "+mode);
return; return;
} }
API.event.emit('view.set', mode); API.event.emit('view.set', mode);
@ -2933,7 +2930,7 @@
function setMode(mode, lock, then) { function setMode(mode, lock, then) {
if (!MODES[mode]) { if (!MODES[mode]) {
DBUG.log("invalid mode: "+mode); console.log("invalid mode: "+mode);
mode = 'FDM'; mode = 'FDM';
} }
// change mode constants // change mode constants

View file

@ -13,7 +13,6 @@
FDM = DRIVERS.FDM, FDM = DRIVERS.FDM,
BASE = self.base, BASE = self.base,
UTIL = BASE.util, UTIL = BASE.util,
DBUG = BASE.debug,
POLY = BASE.polygons, POLY = BASE.polygons,
SQRT = Math.sqrt, SQRT = Math.sqrt,
SQR = UTIL.sqr, SQR = UTIL.sqr,

View file

@ -516,8 +516,7 @@
*/ */
function connectLines(input, z, debug) { function connectLines(input, z, debug) {
// map points to all other points they're connected to // map points to all other points they're connected to
let DBUG = BASE.debug, let CONF = BASE.config,
CONF = BASE.config,
pmap = {}, pmap = {},
points = [], points = [],
output = [], output = [],
@ -532,6 +531,7 @@
if (cp) return cp; if (cp) return cp;
points.push(p); points.push(p);
pmap[p.key] = p; pmap[p.key] = p;
p.pos = 0;
p.mod = nextMod++; // unique seq ID for points p.mod = nextMod++; // unique seq ID for points
p.toString = function() { return this.mod }; // point array concat p.toString = function() { return this.mod }; // point array concat
return p; return p;
@ -559,7 +559,7 @@
function findPathsMinRecurse(point, path, paths, from) { function findPathsMinRecurse(point, path, paths, from) {
let stack = [ ]; let stack = [ ];
if (paths.length > 10000) { if (paths.length > 10000) {
DBUG.log(`indeterminate path @ ${z} from paths=${paths.length} input=${input.length}`); console.log(`indeterminate path @ ${z} from paths=${paths.length} input=${input.length}`);
input.excessive = paths.length; input.excessive = paths.length;
return; return;
} }

View file

@ -1,4 +1,4 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
"use strict"; "use strict";
@ -10,7 +10,6 @@
DRIVERS = KIRI.driver, DRIVERS = KIRI.driver,
BASE = self.base, BASE = self.base,
CONF = BASE.config, CONF = BASE.config,
DBUG = BASE.debug,
UTIL = BASE.util, UTIL = BASE.util,
POLY = BASE.polygons, POLY = BASE.polygons,
MATH = Math, MATH = Math,
@ -721,7 +720,7 @@
if (driver) { if (driver) {
driver.slice(settings, widget, catchupdate, catchdone); driver.slice(settings, widget, catchupdate, catchdone);
} else { } else {
DBUG.log('invalid mode: '+settings.mode); console.log('invalid mode: '+settings.mode);
ondone('invalid mode: '+settings.mode); ondone('invalid mode: '+settings.mode);
} }
} }

View file

@ -177,7 +177,6 @@ KIRI.minions = {
}; };
console.log(`kiri | init work | ${KIRI.version || "rogue"}`); console.log(`kiri | init work | ${KIRI.version || "rogue"}`);
BASE.debug.disable();
// code is running in the worker / server context // code is running in the worker / server context
const dispatch = const dispatch =

View file

@ -6,7 +6,6 @@
const KIRI = self.kiri, const KIRI = self.kiri,
BASE = self.base, BASE = self.base,
DBUG = BASE.debug,
UTIL = BASE.util, UTIL = BASE.util,
POLY = BASE.polygons, POLY = BASE.polygons,
FDM = KIRI.driver.FDM = { FDM = KIRI.driver.FDM = {

View file

@ -6,7 +6,6 @@
const KIRI = self.kiri, const KIRI = self.kiri,
BASE = self.base, BASE = self.base,
DBUG = BASE.debug,
POLY = BASE.polygons, POLY = BASE.polygons,
UTIL = BASE.util, UTIL = BASE.util,
CONF = BASE.config, CONF = BASE.config,
@ -173,8 +172,8 @@
Math.min(process.sliceMinHeight, sliceHeight) : 0; Math.min(process.sliceMinHeight, sliceHeight) : 0;
if (sliceHeightBase < sliceHeight) { if (sliceHeightBase < sliceHeight) {
DBUG.log("invalid first layer height < slice height"); console.log("invalid first layer height < slice height");
DBUG.log("reverting to min valid slice height"); console.log("reverting to min valid slice height");
sliceHeightBase = sliceMinHeight || sliceHeight; sliceHeightBase = sliceMinHeight || sliceHeight;
} }

View file

@ -203,7 +203,7 @@ kiri.lang['en-us'] = {
op_dang_s: "experimental", op_dang_s: "experimental",
op_dang_l: "show experimental parameters", op_dang_l: "show experimental parameters",
op_devl_s: "developer", op_devl_s: "developer",
op_devl_l: "show developer options", op_devl_l: ["show developer options","enable developer debugging"],
op_hopo_s: "hover pop", op_hopo_s: "hover pop",
op_hopo_l: ["enable menu hover","to activate"], op_hopo_l: ["enable menu hover","to activate"],
op_dark_s: "dark mode", op_dark_s: "dark mode",