From e96da190579f4fed9e3eeb434053a22162119201 Mon Sep 17 00:00:00 2001 From: hsnaadia <122881269+hsnaadia@users.noreply.github.com> Date: Sat, 11 Jan 2025 02:50:47 +0800 Subject: [PATCH] Cleaned up code for groomative maintenance --- main/deepnest.js | 136 ++++------------------------------------------- 1 file changed, 9 insertions(+), 127 deletions(-) diff --git a/main/deepnest.js b/main/deepnest.js index c16e546..f86defb 100755 --- a/main/deepnest.js +++ b/main/deepnest.js @@ -5,7 +5,7 @@ (function (root) { "use strict"; - + // Initialize DeepNest with Electron IPC Renderer root.DeepNest = new DeepNest(require("electron").ipcRenderer); function DeepNest(eventEmitter) { @@ -26,15 +26,13 @@ simplify: false, }; - // list of imported files - // import: {filename: 'blah.svg', svg: svgroot} + // Imported SVG files this.imports = []; - // list of all extracted parts - // part: {name: 'part name', quantity: ...} + // Extracted parts from SVGs this.parts = []; - // a pure polygonal representation of parts that lives only during the nesting step + // Polygonal representation used during nesting this.partsTree = []; this.working = false; @@ -49,6 +47,7 @@ // a running list of placements this.nests = []; + //Import and parse an SVG file this.importsvg = function ( filename, dirpath, @@ -56,9 +55,7 @@ scalingFactor, dxfFlag ) { - // parse svg - // config.scale is the default scale, and may not be applied - // scalingFactor is an absolute scaling that must be applied regardless of input svg contents + //Parse and clean SVG with default (config.scale) and absolute (scalingFactor) scaling svg = SvgParser.load(dirpath, svgstring, config.scale, scalingFactor); svg = SvgParser.clean(dxfFlag); @@ -76,23 +73,9 @@ return parts; - // test simplification - /*for(i=0; i 0; }; - /*this.simplifyPolygon = function(polygon, concavehull){ - function clone(p){ - var newp = []; - for(var i=0; i -1){ - cindex = concave.indexOf(p); - simple.push(p); - } - else{ - - var test = clone(concave); - test.splice(cindex < 0 ? 0 : cindex+1,0,p); - - var outside = false; - for(var j=0; j