diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index 4dadc578..aeac1117 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -794,6 +794,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { // const wallBaseLine = sortedWallBaseLines[index] const roofLine = sortRoofLines[index]; + if(roofLine.attributes.wallLine !== wallLine.id || (roofLine.idx - 1) !== index ){ console.log("wallLine2::::", wallLine.id) console.log('roofLine:::',roofLine.attributes.wallLine) @@ -804,33 +805,17 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { }//roofLines.find(line => line.attributes.wallLineId === wallLine.attributes.wallId); const currentRoofLine = currentRoofLines[index]; - const moveLine = sortedBaseLines[index] - const wallBaseLine = sortedBaseLines[index] + const moveLine = wall.baseLines[index] + const wallBaseLine = wall.baseLines[index] //console.log("wallBaseLine", wallBaseLine); //roofline 외곽선 설정 + console.log("index::::", index) + console.log('roofLine:::',roofLine) + console.log('wallLine', wallLine) + console.log('wallBaseLine', wallBaseLine) - // Check if wallBaseLine is inside the polygon formed by sortedWallLines - - /* - console.log('=== Line Coordinates ==='); - console.table({ - 'Point' : ['X', 'Y'], - 'roofLine' : [roofLine.x1, roofLine.y1], - 'currentRoofLine': [currentRoofLine.x1, currentRoofLine.y1], - 'moveLine' : [moveLine.x1, moveLine.y1], - 'wallBaseLine' : [wallBaseLine.x1, wallBaseLine.y1] - }); - console.log('End Points:'); - console.table({ - 'Point' : ['X', 'Y'], - 'roofLine' : [roofLine.x2, roofLine.y2], - 'currentRoofLine': [currentRoofLine.x2, currentRoofLine.y2], - 'moveLine' : [moveLine.x2, moveLine.y2], - 'wallBaseLine' : [wallBaseLine.x2, wallBaseLine.y2] - }); - */ const origin = moveLine.attributes?.originPoint if (!origin) return @@ -973,7 +958,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() newPStart.y = aStartY - newPEnd.y = Big(roofLine.y2).minus(eLineY).toNumber() + newPEnd.y = roofLine.y2 //Big(roofLine.y2).minus(eLineY).toNumber() let idx = (0 >= index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -1000,7 +985,16 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1},{ y: newPStart.y, x: newPStart.x }, 'purple') } }else { - newPStart.y = wallLine.y1; + //newPStart.y = wallLine.y1; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber(); + newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) + if(inLine.x2 > inLine.x1 ) { + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x } , 'purple') + } } } @@ -1015,7 +1009,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { console.log("startLines:::::::", inLine); const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber() newPEnd.y = aStartY - newPStart.y = Big(roofLine.y1).plus(eLineY).toNumber() + newPStart.y = roofLine.y1//Big(roofLine.y1).plus(eLineY).toNumber() let idx = (roofLines.length < index + 1)?0:index const newLine = roofLines[idx+1]; @@ -1042,7 +1036,17 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { } }else { - newPEnd.y = wallLine.y2 + // newPEnd.y = wallLine.y2 + + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber(); + newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + if(inLine.x2 > inLine.x1 ) { + getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x } , 'purple') + } } } @@ -1109,7 +1113,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { console.log("startLines:::::::", inLine); const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() newPStart.y = aStartY - newPEnd.y = Big(roofLine.y2).plus(eLineY).toNumber() + newPEnd.y = roofLine.y2//Big(roofLine.y2).plus(eLineY).toNumber() let idx = (0 >= index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -1135,7 +1139,19 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1 },{ y: newPStart.y, x: newPStart.x }, 'purple') } }else { - newPStart.y = wallLine.y1; + //newPStart.y = wallLine.y1; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.x1).minus(roofLine.x1).abs().toNumber(); + newPStart.y = Big(wallBaseLine.y1).plus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) + if(inLine){ + if(inLine.x2 > inLine.x1 ) { + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y1, x: inLine.x1 }, 'purple') + }else{ + getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPStart.y, x: newPStart.x } , 'purple') + } + } + } } @@ -1150,7 +1166,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { console.log("startLines:::::::", inLine); const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber() newPEnd.y = aStartY - newPStart.y = Big(roofLine.y1).minus(eLineY).toNumber() + newPStart.y = roofLine.y1//Big(roofLine.y1).minus(eLineY).toNumber() let idx = (roofLines.length < index + 1)?0:index const newLine = roofLines[idx+1]; if(inLine){ @@ -1175,26 +1191,26 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x }, 'purple') } }else { - newPEnd.y = wallLine.y2; + //newPEnd.y = wallLine.y2; + + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber(); + newPEnd.y = Big(wallBaseLine.y2).minus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + if(inLine){ + if(inLine.x2 > inLine.x1 ) { + getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y1, x: inLine.x1 }, 'purple') + }else{ + getAddLine({ y: inLine.y2, x: inLine.x2}, { y: newPEnd.y, x: newPEnd.x } , 'purple') + } + } + } } } } - - // switch (condition) { - // case 'left_in': - // break; - // case 'left_out': - // break; - // case 'right_in': - // break; - // case 'right_out': - // break; - // } } - - } else if (getOrientation(roofLine) === 'horizontal') { //red if (['top', 'bottom'].includes(mLine.position)) { @@ -1260,6 +1276,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { }else if(condition === 'top_out') { console.log("top_out isStartEnd:::::::", isStartEnd); + if (isStartEnd.start ) { const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber() const aStartX = Big(roofLine.x1).plus(moveDist).toNumber() @@ -1267,7 +1284,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y }) const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber() - newPEnd.x = Big(newPEnd.x).plus(eLineX).toNumber() + newPEnd.x = roofLine.x2 //Big(newPEnd.x).plus(eLineX).toNumber() newPStart.x = aStartX let idx = (0 > index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -1295,7 +1312,17 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { } }else { - newPStart.x = wallLine.x1; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber(); + newPStart.x = Big(wallBaseLine.x1).plus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) + if(inLine){ + if(inLine.y2 > inLine.y1 ) { + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPStart.y, x: newPStart.x } , 'purple') + } + } } } @@ -1307,7 +1334,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y }) console.log("startLines:::::::", inLine); const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber() - newPStart.x = Big(newPStart.x).minus(eLineX).abs().toNumber() + newPStart.x = roofLine.x1;//Big(newPStart.x).minus(eLineX).abs().toNumber() newPEnd.x = aStartX let idx = (roofLines.length < index + 1)?0:index const newLine = roofLines[idx+1]; @@ -1335,7 +1362,18 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1 },{ y: newPEnd.y, x: newPEnd.x }, 'purple') } }else { - newPEnd.x = wallLine.x2; + //newPEnd.x = wallLine.x2; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber(); + newPEnd.x = Big(wallBaseLine.x2).minus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + if(inLine){ + if(inLine.y1 > inLine.y2 ) { + getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y1, x: inLine.x1 }, 'purple') + }else{ + getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPEnd.y, x: newPEnd.x } , 'purple') + } + } } } @@ -1394,7 +1432,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: roofLine.y1 }) console.log("startLines:::::::", inLine); const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber() - newPEnd.x = Big(roofLine.x2).minus(eLineX).toNumber() + newPEnd.x = roofLine.x2//Big(roofLine.x2).minus(eLineX).toNumber() newPStart.x = aStartX let idx = (0 > index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -1422,7 +1460,18 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPStart.y, x: newPStart.x }, 'purple') } }else{ - newPStart.x = wallLine.x1; + //newPStart.x = wallLine.x1; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber(); + newPStart.x = Big(wallBaseLine.x1).minus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) + if(inLine){ + if(inLine.y2 > inLine.y1 ) { + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y1, x: inLine.x1 }, 'purple') + }else{ + getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPStart.y, x: newPStart.x } , 'purple') + } + } } } @@ -1436,7 +1485,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { console.log("startLines:::::::", inLine); const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber() newPEnd.x = aStartX - newPStart.x = Big(roofLine.x1).plus(eLineX).toNumber() + newPStart.x = roofLine.x1;//Big(roofLine.x1).plus(eLineX).toNumber() let idx = (roofLines.length < index + 1)?0:index const newLine = roofLines[idx + 1]; @@ -1462,25 +1511,23 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: inLine.y1, x: inLine.x1 },{ y: newPEnd.y, x: newPEnd.x }, 'purple') } }else{ - newPEnd.x = wallLine.x2; + //newPEnd.x = wallLine.x2; + //외곽 라인 그리기 + const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber(); + newPEnd.x = Big(wallBaseLine.x2).plus(rLineM).abs().toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + if(inLine){ + if(inLine.y1 > inLine.y2 ) { + getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x } , 'purple') + } + } } } } } - - // switch (condition) { - // case 'top_in': - // //console.log("findInteriorPoint result:::::::", isStartEnd); - // break; - // case 'top_out': - // //console.log("findInteriorPoint result:::::::", isStartEnd); - // break; - // case 'bottom_in': - // break; - // case 'bottom_out': - // break; - // } } }