From fc070692762675f3ef6a6c1a043d8b73241e996b Mon Sep 17 00:00:00 2001 From: yscha Date: Sun, 7 Dec 2025 02:44:10 +0900 Subject: [PATCH] v0.2 --- src/util/skeleton-utils.js | 64 +++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index cb0f2df0..80763cfa 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -939,8 +939,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x2 }) const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() - newPEnd.y = aStartY - newPStart.y = Big(roofLine.y2).minus(eLineY).toNumber() + newPStart.y = aStartY + newPEnd.y = Big(roofLine.y2).minus(eLineY).toNumber() let idx = (0 >= index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -950,17 +950,17 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { } getAddLine({ y: bStartY, x: wallLine.x2 }, { y: roofLine.y1, x: wallLine.x1 }, 'magenta') getAddLine({ y: newLine.y1, x: newLine.x1 }, { y: newLine.y2, x: wallLine.x2 }, 'Gray') - findPoints.push({ y: aStartY, x: newPEnd.x }); + findPoints.push({ y: aStartY, x: newPStart.x }); }else{ - const cLineY = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() - newPEnd.y = Big(newPEnd.y).minus(cLineY).toNumber(); - const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() + newPStart.y = Big(newPStart.y).minus(cLineY).toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if(inLine){ - getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') - } - if(Math.abs(newPEnd.y - roofLine.y1) > 0.1) { - //newPEnd.y = roofLine.y1; + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPStart.y = roofLine.y1; } + } } @@ -985,11 +985,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray') findPoints.push({ y: aStartY, x: newPEnd.x }); }else{ - const cLineY = Big(wallBaseLine.y2).minus(wallLine.y2).abs().toNumber() + const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() newPEnd.y = Big(newPEnd.y).plus(cLineY).toNumber(); const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if(inLine){ getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPEnd.y = roofLine.y2; } } @@ -1049,13 +1051,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { console.log("right_out::::isStartEnd:::::", isStartEnd); if (isStartEnd.start ) { //x1 inside const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber() - const aStartY = Big(roofLine.y1).plus(moveDist).toNumber() - const bStartY = Big(wallLine.y1).plus(moveDist).toNumber() - const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x2 }) + const aStartY = Big(roofLine.y1).plus(moveDist).abs().toNumber() + const bStartY = Big(wallLine.y1).plus(moveDist).abs().toNumber() + const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 }) console.log("startLines:::::::", inLine); const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() - newPEnd.y = aStartY - newPStart.y = Big(roofLine.y2).plus(eLineY).toNumber() + newPStart.y = aStartY + newPEnd.y = Big(roofLine.y2).plus(eLineY).toNumber() let idx = (0 >= index - 1)?roofLines.length:index const newLine = roofLines[idx-1]; @@ -1067,11 +1069,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: newLine.y1, x: newLine.x1 }, { y: newLine.y2, x: wallLine.x2 }, 'Gray') findPoints.push({ y: aStartY, x: newPEnd.x }); }else{ - const cLineY = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() - newPEnd.y = Big(newPEnd.y).plus(cLineY).toNumber(); - const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) + const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() + newPStart.y = Big(newPStart.y).plus(cLineY).toNumber(); + const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if(inLine){ - getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'pink') + getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPStart.y = roofLine.y2; } } @@ -1097,11 +1101,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray') findPoints.push({ y: aStartY, x: newPEnd.x }); }else{ - const cLineY = Big(wallBaseLine.y2).minus(wallLine.y2).abs().toNumber() + const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() newPEnd.y = Big(newPEnd.y).minus(cLineY).toNumber(); const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if(inLine){ - getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'pink') + getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPEnd.y = roofLine.y2; } } @@ -1203,11 +1209,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') findPoints.push({ x: aStartX, y: newPEnd.y }); }else{ - const cLineX = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() + const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() newPStart.x = Big(newPStart.x).plus(cLineX).toNumber(); const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if(inLine){ getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPStart.x = roofLine.x1; } } @@ -1232,11 +1240,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ x: newLine.x2, y: newLine.y2 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') findPoints.push({ x: aStartX, y: newPEnd.y }); }else{ - const cLineX = Big(wallLine.x2).minus(wallBaseLine.x2).abs().toNumber() + const cLineX = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber() newPEnd.x = Big(newPEnd.x).minus(cLineX).toNumber(); const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if(inLine){ getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else { + newPEnd.x = roofLine.x2; } } @@ -1309,11 +1319,13 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') findPoints.push({ x: aStartX, y: newPEnd.y }); }else{ - const cLineX = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() + const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() newPStart.x = Big(newPStart.x).minus(cLineX).toNumber(); const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if(inLine){ getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + newPStart.x = roofLine.x1; } } @@ -1344,6 +1356,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if(inLine){ getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') + }else{ + newPEnd.x = roofLine.x2; } }