X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Flibclo%2FbreakLines.ts;fp=src%2Flibclo%2FbreakLines.ts;h=7ab8c0d70bf0c68cd951a3feb89b3536722b345b;hb=9548c51651d010ec8fd8fbf0213a2d7c60e051ce;hp=f761b1868525b52e2e76b491110e1a2d98b82ac6;hpb=2b1a59e963a3610c8f664af3dd6b03afb8d89646;p=clo diff --git a/src/libclo/breakLines.ts b/src/libclo/breakLines.ts index f761b18..7ab8c0d 100644 --- a/src/libclo/breakLines.ts +++ b/src/libclo/breakLines.ts @@ -51,6 +51,7 @@ export class BreakLineAlgorithm { } segmentedNodes(items : BoxesItem[], lineWidth : number) : BoxesItem[][]{ + let lineWidthFixed = lineWidth; this.totalCost(items ,lineWidthFixed); let nodeList = this.generateBreakLineNodeList(); @@ -64,6 +65,8 @@ export class BreakLineAlgorithm { up = nodeList[i+1]; } + + return res; } @@ -105,16 +108,15 @@ export class BreakLineAlgorithm { let a = Infinity; for(var k=itemsLength-2; this.lineCost(items, k+1,itemsLength-1, lineWidthFixed) < Infinity; k--){ + let tmp = this.totalCostAux(items, k, lineWidthFixed); - + if (a > tmp){ this.prevNodes[itemsLength-1] = k a = tmp; } + } - - console.log("~~~", lineWidth); - console.log((items[itemsLength-2])); return a; } @@ -163,7 +165,8 @@ export class BreakLineAlgorithm { * @param lineWidth line width */ lineCost(items : BoxesItem[], i : number, j : number, lineWidth: number) : number{ - if (this.lineCostStorage[i] !== null && this.lineCostStorage[i][j] !== null){ + if (this.lineCostStorage[i][j] !== null){ + console.log("AA") return this.lineCostStorage[i][j]; }