remove largely unused debug class
This commit is contained in:
parent
52b19ff04f
commit
6337cae736
15 changed files with 30 additions and 281 deletions
5
app.js
5
app.js
|
|
@ -230,7 +230,6 @@ const script = {
|
|||
"add/array",
|
||||
"add/three",
|
||||
"geo/base",
|
||||
"geo/debug",
|
||||
"geo/render",
|
||||
"geo/point",
|
||||
"geo/points",
|
||||
|
|
@ -289,7 +288,6 @@ const script = {
|
|||
"add/class",
|
||||
"geo/base",
|
||||
// "geo/wasm",
|
||||
"geo/debug",
|
||||
"geo/point",
|
||||
"geo/points",
|
||||
"geo/slope",
|
||||
|
|
@ -333,7 +331,6 @@ const script = {
|
|||
"add/array",
|
||||
"add/class",
|
||||
"geo/base",
|
||||
"geo/debug",
|
||||
"geo/point",
|
||||
"geo/points",
|
||||
"geo/slope",
|
||||
|
|
@ -358,7 +355,6 @@ const script = {
|
|||
"add/array",
|
||||
"add/three",
|
||||
"geo/base",
|
||||
"geo/debug",
|
||||
"geo/render",
|
||||
"geo/point",
|
||||
"geo/points",
|
||||
|
|
@ -389,7 +385,6 @@ const script = {
|
|||
"add/array",
|
||||
"add/three",
|
||||
"geo/base",
|
||||
"geo/debug",
|
||||
"geo/render",
|
||||
"geo/point",
|
||||
"geo/slope",
|
||||
|
|
|
|||
219
src/geo/debug.js
219
src/geo/debug.js
|
|
@ -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
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
@ -13,20 +13,14 @@
|
|||
ROUND = UTIL.round;
|
||||
|
||||
class Point {
|
||||
constructor(x,y,z,key,CP) {
|
||||
if (CP) {
|
||||
console.trace({x,y,z,key,CP});
|
||||
throw "deprecated point constructor"
|
||||
} else {
|
||||
constructor(x,y,z,key) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z || 0;
|
||||
if (key) {
|
||||
this._key = key;
|
||||
}
|
||||
}
|
||||
this.poly = null; // parent polygon
|
||||
this.pos = 0; // position in group
|
||||
}
|
||||
|
||||
get key() {
|
||||
|
|
@ -710,11 +704,10 @@
|
|||
* @param {number} y
|
||||
* @param {number} z
|
||||
* @param {String} [key]
|
||||
* @param {Object} [CP] clipper point
|
||||
* @returns {Point}
|
||||
*/
|
||||
function newPoint(x, y, z, key, CP) {
|
||||
return new Point(x, y, z, key, CP);
|
||||
function newPoint(x, y, z, key) {
|
||||
return new Point(x, y, z, key);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
(function() {
|
||||
|
||||
const BASE = self.base,
|
||||
DBUG = BASE.debug,
|
||||
CONF = BASE.config;
|
||||
const BASE = self.base;
|
||||
const CONF = BASE.config;
|
||||
|
||||
BASE.verticesToPoints = verticesToPoints;
|
||||
BASE.pointsToVertices = pointsToVertices;
|
||||
|
|
@ -104,7 +103,7 @@
|
|||
|
||||
// if (passes) console.trace({passes, threshold, precision, maxpass});
|
||||
|
||||
if (passes) DBUG.log({
|
||||
if (passes) console.log({
|
||||
before: array.length / 3,
|
||||
after: parr.length,
|
||||
unique: unique,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
const BASE = self.base,
|
||||
CONF = BASE.config,
|
||||
UTIL = BASE.util,
|
||||
DBUG = BASE.debug,
|
||||
KEYS = BASE.key,
|
||||
SQRT = Math.sqrt,
|
||||
POLY = function() { return BASE.polygons },
|
||||
|
|
|
|||
|
|
@ -745,9 +745,7 @@
|
|||
while (i < polygons.length) {
|
||||
let polygon = polygons[i++],
|
||||
pp = polygon.points,
|
||||
pl = pp.length,
|
||||
dbug = BASE.debug,
|
||||
debug = false;
|
||||
pl = pp.length;;
|
||||
for (let j = 0; j < pl; j++) {
|
||||
let j2 = (j + 1) % pl,
|
||||
ip = UTIL.intersectRayLine(start, slope, pp[j], pp[j2]);
|
||||
|
|
@ -760,13 +758,9 @@
|
|||
if (ip.isNear(pp[j], merge_dist)) {
|
||||
ip.pos = j;
|
||||
ip.mod = pl;
|
||||
if (debug) dbug.points([ip], 0x0000ff, 0.5, 1.0);
|
||||
} else if (ip.isNear(pp[j2], merge_dist)) {
|
||||
ip.pos = j2;
|
||||
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.
|
||||
*/
|
||||
if (line.length < 2) {
|
||||
dbug.log("sliceInt: line common ep fail: "+line.length);
|
||||
console.log("sliceInt: line common ep fail: "+line.length);
|
||||
} else
|
||||
if (line.length > 2) {
|
||||
p1.del = true;
|
||||
|
|
@ -804,11 +798,9 @@
|
|||
del = true;
|
||||
p1.del = true;
|
||||
p2.del = true;
|
||||
if (debug) dbug.points([p1, p2], 0xffffff, 0.2, 1);
|
||||
} else {
|
||||
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
|
||||
|
|
@ -839,7 +831,6 @@
|
|||
// p1.del = true;
|
||||
// p2.del = true;
|
||||
// del = true;
|
||||
// if (debug) dbug.points([p1, p2], 0xfff000, 0.2, 2);
|
||||
//}
|
||||
// check cull co-linear with group edge
|
||||
if (same && p1.mod && p2.mod) {
|
||||
|
|
@ -848,7 +839,6 @@
|
|||
p1.del = true;
|
||||
p2.del = true;
|
||||
del = true;
|
||||
if (debug) dbug.points([p1, p2], 0xffffff, 0.2, 1.85);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
@ -203,7 +203,7 @@
|
|||
function gridhost_tracker(host,key) {
|
||||
ajax(host+"/api/check?key="+key, function(data) {
|
||||
data = js2o(data);
|
||||
DBUG.log(data);
|
||||
console.log(data);
|
||||
if (!(data.done || data.error)) {
|
||||
setTimeout(function() { gridhost_tracker(host,key) }, 1000);
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@
|
|||
gridhost_tracker(host,json.key);
|
||||
API.ajax(host+"/api/wait?key="+json.key, function(data) {
|
||||
data = js2o(data);
|
||||
DBUG.log(data);
|
||||
console.log(data);
|
||||
API.show.alert("print to "+target+": "+data.status, 600);
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
DBUG = BASE.debug,
|
||||
LANG = KIRI.lang.current,
|
||||
WIN = self.window,
|
||||
DOC = self.document,
|
||||
|
|
@ -56,8 +55,6 @@
|
|||
saveTimer = null,
|
||||
noop = () => {};
|
||||
|
||||
DBUG.enable();
|
||||
|
||||
// add show() to catalog for API
|
||||
CATALOG.show = showCatalog;
|
||||
|
||||
|
|
@ -1134,7 +1131,7 @@
|
|||
API.event.emit('slice.end', getMode());
|
||||
// print stats
|
||||
segtimes.total = Date.now() - now;
|
||||
DBUG.log(segtimes);
|
||||
console.log(segtimes);
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
|
|
@ -1231,7 +1228,7 @@
|
|||
|
||||
// print stats
|
||||
segtimes.total = Date.now() - now;
|
||||
DBUG.log(segtimes);
|
||||
console.log(segtimes);
|
||||
|
||||
API.event.emit('print', pMode);
|
||||
API.event.emit('preview.end', pMode);
|
||||
|
|
@ -2483,7 +2480,7 @@
|
|||
|
||||
function loadFile() {
|
||||
$('load-file').onchange = function(event) {
|
||||
DBUG.log(event);
|
||||
console.log(event);
|
||||
platformLoadFiles(event.target.files);
|
||||
};
|
||||
$('load-file').click();
|
||||
|
|
@ -2908,7 +2905,7 @@
|
|||
setWidgetVisibility(true);
|
||||
break;
|
||||
default:
|
||||
DBUG.log("invalid view mode: "+mode);
|
||||
console.log("invalid view mode: "+mode);
|
||||
return;
|
||||
}
|
||||
API.event.emit('view.set', mode);
|
||||
|
|
@ -2933,7 +2930,7 @@
|
|||
|
||||
function setMode(mode, lock, then) {
|
||||
if (!MODES[mode]) {
|
||||
DBUG.log("invalid mode: "+mode);
|
||||
console.log("invalid mode: "+mode);
|
||||
mode = 'FDM';
|
||||
}
|
||||
// change mode constants
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
FDM = DRIVERS.FDM,
|
||||
BASE = self.base,
|
||||
UTIL = BASE.util,
|
||||
DBUG = BASE.debug,
|
||||
POLY = BASE.polygons,
|
||||
SQRT = Math.sqrt,
|
||||
SQR = UTIL.sqr,
|
||||
|
|
|
|||
|
|
@ -516,8 +516,7 @@
|
|||
*/
|
||||
function connectLines(input, z, debug) {
|
||||
// map points to all other points they're connected to
|
||||
let DBUG = BASE.debug,
|
||||
CONF = BASE.config,
|
||||
let CONF = BASE.config,
|
||||
pmap = {},
|
||||
points = [],
|
||||
output = [],
|
||||
|
|
@ -532,6 +531,7 @@
|
|||
if (cp) return cp;
|
||||
points.push(p);
|
||||
pmap[p.key] = p;
|
||||
p.pos = 0;
|
||||
p.mod = nextMod++; // unique seq ID for points
|
||||
p.toString = function() { return this.mod }; // point array concat
|
||||
return p;
|
||||
|
|
@ -559,7 +559,7 @@
|
|||
function findPathsMinRecurse(point, path, paths, from) {
|
||||
let stack = [ ];
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
DRIVERS = KIRI.driver,
|
||||
BASE = self.base,
|
||||
CONF = BASE.config,
|
||||
DBUG = BASE.debug,
|
||||
UTIL = BASE.util,
|
||||
POLY = BASE.polygons,
|
||||
MATH = Math,
|
||||
|
|
@ -721,7 +720,7 @@
|
|||
if (driver) {
|
||||
driver.slice(settings, widget, catchupdate, catchdone);
|
||||
} else {
|
||||
DBUG.log('invalid mode: '+settings.mode);
|
||||
console.log('invalid mode: '+settings.mode);
|
||||
ondone('invalid mode: '+settings.mode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ KIRI.minions = {
|
|||
};
|
||||
|
||||
console.log(`kiri | init work | ${KIRI.version || "rogue"}`);
|
||||
BASE.debug.disable();
|
||||
|
||||
// code is running in the worker / server context
|
||||
const dispatch =
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
const KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
DBUG = BASE.debug,
|
||||
UTIL = BASE.util,
|
||||
POLY = BASE.polygons,
|
||||
FDM = KIRI.driver.FDM = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
const KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
DBUG = BASE.debug,
|
||||
POLY = BASE.polygons,
|
||||
UTIL = BASE.util,
|
||||
CONF = BASE.config,
|
||||
|
|
@ -173,8 +172,8 @@
|
|||
Math.min(process.sliceMinHeight, sliceHeight) : 0;
|
||||
|
||||
if (sliceHeightBase < sliceHeight) {
|
||||
DBUG.log("invalid first layer height < slice height");
|
||||
DBUG.log("reverting to min valid slice height");
|
||||
console.log("invalid first layer height < slice height");
|
||||
console.log("reverting to min valid slice height");
|
||||
sliceHeightBase = sliceMinHeight || sliceHeight;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ kiri.lang['en-us'] = {
|
|||
op_dang_s: "experimental",
|
||||
op_dang_l: "show experimental parameters",
|
||||
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_l: ["enable menu hover","to activate"],
|
||||
op_dark_s: "dark mode",
|
||||
|
|
|
|||
Loading…
Reference in a new issue