From dafbaacd426dfd38b9fd756489a1e511259cbfbe Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Fri, 6 May 2016 19:47:42 +0200 Subject: [PATCH] comment optimize path code --- src/slice.js | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/slice.js b/src/slice.js index 0e46f8b..99e0870 100644 --- a/src/slice.js +++ b/src/slice.js @@ -6,74 +6,74 @@ export default class { } optimizePaths(start) { - if (this.brim !== undefined && this.brim.length > 0) { - this.brim = this.brim.optimizePath(start); - start = this.brim.lastPoint(); - } - - var parts = []; - - while (this.parts.length > 0) { - var closestDistance = Infinity; - var closestPart; - - for (var i = 0; i < this.parts.length; i ++) { - var part = this.parts[i]; - if (part.shape.closed) { - var bounds = part.outerLine.bounds(); - } - else { - var bounds = part.shape.bounds(); - } - - var top = bounds.top - start.y; - var bottom = start.y - bounds.bottom; - var left = bounds.left - start.x; - var right = start.x - bounds.right; - - var distance = Math.max(top, bottom, left, right); - - if (distance < closestDistance) { - closestDistance = distance; - closestPart = i; - } - } - - var part = this.parts.splice(closestPart, 1)[0]; - parts.push(part); - - if (part.shape.closed) { - if (part.outerLine.length > 0) { - part.outerLine = part.outerLine.optimizePath(start); - start = part.outerLine.lastPoint(); - } - - for (var j = 0; j < part.innerLines.length; j ++) { - var innerLine = part.innerLines[j]; - if (innerLine.length > 0) { - part.innerLines[j] = innerLine.optimizePath(start); - start = part.innerLines[j].lastPoint(); - } - } - - if (part.fill.length > 0) { - part.fill = part.fill.optimizePath(start); - start = part.fill.lastPoint(); - } - } - else { - part.shape.optimizePath(start); - start = part.shape.lastPoint(); - } - - } - - this.parts = parts; - - if (this.support !== undefined && this.support.length > 0) { - this.support = this.support.optimizePath(start); - start = this.support.lastPoint(); - } + // if (this.brim !== undefined && this.brim.length > 0) { + // this.brim = this.brim.optimizePath(start); + // start = this.brim.lastPoint(); + // } + // + // var parts = []; + // + // while (this.parts.length > 0) { + // var closestDistance = Infinity; + // var closestPart; + // + // for (var i = 0; i < this.parts.length; i ++) { + // var part = this.parts[i]; + // if (part.shape.closed) { + // var bounds = part.outerLine.bounds(); + // } + // else { + // var bounds = part.shape.bounds(); + // } + // + // var top = bounds.top - start.y; + // var bottom = start.y - bounds.bottom; + // var left = bounds.left - start.x; + // var right = start.x - bounds.right; + // + // var distance = Math.max(top, bottom, left, right); + // + // if (distance < closestDistance) { + // closestDistance = distance; + // closestPart = i; + // } + // } + // + // var part = this.parts.splice(closestPart, 1)[0]; + // parts.push(part); + // + // if (part.shape.closed) { + // if (part.outerLine.length > 0) { + // part.outerLine = part.outerLine.optimizePath(start); + // start = part.outerLine.lastPoint(); + // } + // + // for (var j = 0; j < part.innerLines.length; j ++) { + // var innerLine = part.innerLines[j]; + // if (innerLine.length > 0) { + // part.innerLines[j] = innerLine.optimizePath(start); + // start = part.innerLines[j].lastPoint(); + // } + // } + // + // if (part.fill.length > 0) { + // part.fill = part.fill.optimizePath(start); + // start = part.fill.lastPoint(); + // } + // } + // else { + // part.shape.optimizePath(start); + // start = part.shape.lastPoint(); + // } + // + // } + // + // this.parts = parts; + // + // if (this.support !== undefined && this.support.length > 0) { + // this.support = this.support.optimizePath(start); + // start = this.support.lastPoint(); + // } return start; }