X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Flibclo%2FbreakLines.ts;h=7ab8c0d70bf0c68cd951a3feb89b3536722b345b;hb=9548c51651d010ec8fd8fbf0213a2d7c60e051ce;hp=fba0282440de92c54b19b57fc5b5c5b0dd083158;hpb=ea033498d79b3a84b16e15ff2a218ac5ef5f70b5;p=clo diff --git a/src/libclo/breakLines.ts b/src/libclo/breakLines.ts index fba0282..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; } @@ -150,7 +152,6 @@ export class BreakLineAlgorithm { } - return returnCost; } @@ -164,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]; }