This commit is contained in:
yscha 2025-12-07 01:24:54 +09:00
parent c6c5fabbf2
commit ebfc7da6a3

View File

@ -875,10 +875,9 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
(mLine.position === 'right' && wallLine.x1 > wallBaseLine.x1) (mLine.position === 'right' && wallLine.x1 > wallBaseLine.x1)
? 'in' : 'out'; ? 'in' : 'out';
const condition = `${mLine.position}_${positionType}`; const condition = `${mLine.position}_${positionType}`;
let isStartEnd = findInteriorPoint(wallBaseLine, sortedWallBaseLines) let isStartEnd = findInteriorPoint(wallBaseLine, wall.baseLines)
let sPoint, ePoint; let sPoint, ePoint;
switch (condition) { if(condition === 'left_in') {
case 'left_in':
isIn = true isIn = true
if (isStartEnd.start ) { if (isStartEnd.start ) {
@ -929,29 +928,42 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
//getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange') //getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange')
} }
break;
case 'left_out': }else if(condition === 'left_out') {
console.log("left_out::::isStartEnd:::::", isStartEnd);
if(isStartEnd.start){ if(isStartEnd.start){
const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber() const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber()
const aStartY = Big(roofLine.y1).minus(moveDist).abs().toNumber() const aStartY = Big(roofLine.y1).minus(moveDist).abs().toNumber()
const bStartY = Big(wallLine.y1).minus(moveDist).abs().toNumber() const bStartY = Big(wallLine.y1).minus(moveDist).abs().toNumber()
const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x2 }) const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x2 })
console.log("startLines:::::::", inLine);
const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber()
newPEnd.y = aStartY newPEnd.y = aStartY
newPStart.y = Big(roofLine.y2).minus(eLineY).toNumber() newPStart.y = Big(roofLine.y2).minus(eLineY).toNumber()
let idx = (0 >= index - 1)?roofLines.length:index let idx = (0 >= index - 1)?roofLines.length:index
const newLine = roofLines[idx-1]; const newLine = roofLines[idx-1];
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ y: bStartY, x: wallLine.x2 }, { y: inLine.y2, x: inLine.x2 }, 'pink') getAddLine({ y: bStartY, x: wallLine.x2 }, { y: inLine.y2, x: inLine.x2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ y: bStartY, x: wallLine.x2 }, { y: roofLine.y1, x: wallLine.x1 }, 'magenta') 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') 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: newPEnd.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 })
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;
} }
} }
}
if(isStartEnd.end){ if(isStartEnd.end){
const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber() const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber()
@ -964,19 +976,25 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
newPStart.y = Big(roofLine.y1).plus(eLineY).toNumber() newPStart.y = Big(roofLine.y1).plus(eLineY).toNumber()
let idx = (roofLines.length < index + 1)?0:index let idx = (roofLines.length < index + 1)?0:index
const newLine = roofLines[idx+1]; const newLine = roofLines[idx+1];
if(Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ y: bStartY, x: wallLine.x1 }, { y: inLine.y2, x: inLine.x2 }, 'pink') getAddLine({ y: bStartY, x: wallLine.x1 }, { y: inLine.y2, x: inLine.x2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) {
getAddLine({ y: bStartY, x: wallLine.x1 }, { y: roofLine.y2, x: wallLine.x2 }, 'magenta') getAddLine({ y: bStartY, x: wallLine.x1 }, { y: roofLine.y2, x: wallLine.x2 }, 'magenta')
getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray') getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray')
findPoints.push({ y: aStartY, x: newPEnd.x }); findPoints.push({ y: aStartY, x: newPEnd.x });
}else{
const cLineY = Big(wallBaseLine.y2).minus(wallLine.y2).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')
} }
} }
break; }
case 'right_in': }else if(condition === 'right_in') {
if (isStartEnd.start ) { if (isStartEnd.start ) {
newPEnd.y = roofLine.y2; newPEnd.y = roofLine.y2;
@ -1027,13 +1045,9 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange') getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange')
} }
}else if(condition === 'right_out') {
console.log("right_out::::isStartEnd:::::", isStartEnd);
break; if (isStartEnd.start ) { //x1 inside
case 'right_out':
if (isStartEnd.start ) {
const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber() const moveDist = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber()
const aStartY = Big(roofLine.y1).plus(moveDist).toNumber() const aStartY = Big(roofLine.y1).plus(moveDist).toNumber()
const bStartY = Big(wallLine.y1).plus(moveDist).toNumber() const bStartY = Big(wallLine.y1).plus(moveDist).toNumber()
@ -1044,13 +1058,22 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
newPStart.y = Big(roofLine.y2).plus(eLineY).toNumber() newPStart.y = Big(roofLine.y2).plus(eLineY).toNumber()
let idx = (0 >= index - 1)?roofLines.length:index let idx = (0 >= index - 1)?roofLines.length:index
const newLine = roofLines[idx-1]; const newLine = roofLines[idx-1];
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ y: bStartY, x: wallLine.x2 }, { y: inLine.y2, x: inLine.x2 }, 'pink') getAddLine({ y: bStartY, x: wallLine.x2 }, { y: inLine.y2, x: inLine.x2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ y: bStartY, x: wallLine.x2 }, { y: roofLine.y1, x: wallLine.x1 }, 'magenta') 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') 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: 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 })
if(inLine){
getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'pink')
}
} }
} }
@ -1073,10 +1096,28 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ y: bStartY, x: wallLine.x1 }, { y: roofLine.y2, x: wallLine.x2 }, 'magenta') getAddLine({ y: bStartY, x: wallLine.x1 }, { y: roofLine.y2, x: wallLine.x2 }, 'magenta')
getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray') getAddLine({ y: newLine.y2, x: newLine.x2 }, { y: newLine.y1, x: wallLine.x1 }, 'Gray')
findPoints.push({ y: aStartY, x: newPEnd.x }); findPoints.push({ y: aStartY, x: newPEnd.x });
}else{
const cLineY = Big(wallBaseLine.y2).minus(wallLine.y2).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')
}
} }
} }
break;
} }
// switch (condition) {
// case 'left_in':
// break;
// case 'left_out':
// break;
// case 'right_in':
// break;
// case 'right_out':
// break;
// }
} }
@ -1092,16 +1133,11 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
? 'in' : 'out'; ? 'in' : 'out';
const condition = `${mLine.position}_${positionType}`; const condition = `${mLine.position}_${positionType}`;
let isStartEnd = findInteriorPoint(wallBaseLine, sortedWallBaseLines) let isStartEnd = findInteriorPoint(wallBaseLine, wall.baseLines)
let sPoint, ePoint; let sPoint, ePoint;
switch (condition) { if(condition === 'top_in') {
case 'top_in':
console.log("findInteriorPoint result:::::::", isStartEnd);
if (isStartEnd.start ) { if (isStartEnd.start ) {
const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber() const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
sPoint = {x: wallBaseLine.x1, y: wallBaseLine.y1}; sPoint = {x: wallBaseLine.x1, y: wallBaseLine.y1};
@ -1145,27 +1181,35 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
//getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange') //getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange')
} }
break; }else if(condition === 'top_out') {
case 'top_out': console.log("top_out isStartEnd:::::::", isStartEnd);
//console.log("findInteriorPoint result:::::::", isStartEnd);
if (isStartEnd.start ) { if (isStartEnd.start ) {
const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber() const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
const aStartX = Big(roofLine.x1).plus(moveDist).toNumber() const aStartX = Big(roofLine.x1).plus(moveDist).toNumber()
const bStartX = Big(wallLine.x1).plus(moveDist).toNumber() const bStartX = Big(wallLine.x1).plus(moveDist).toNumber()
const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y }) const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y })
console.log("startLines:::::::", inLine);
const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber() const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber()
newPEnd.x = Big(newPEnd.x).plus(eLineX).toNumber() newPEnd.x = Big(newPEnd.x).plus(eLineX).toNumber()
newPStart.x = aStartX newPStart.x = aStartX
let idx = (0 > index - 1)?roofLines.length:index let idx = (0 > index - 1)?roofLines.length:index
const newLine = roofLines[idx-1]; const newLine = roofLines[idx-1];
if(Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x1, y: wallLine.y1 }, 'magenta') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x1, y: wallLine.y1 }, 'magenta')
getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray')
findPoints.push({ x: aStartX, y: newPEnd.y }); findPoints.push({ x: aStartX, y: newPEnd.y });
}else{
const cLineX = Big(wallBaseLine.x1).minus(wallLine.x1).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')
}
} }
} }
if(isStartEnd.end){ if(isStartEnd.end){
@ -1179,18 +1223,25 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
newPEnd.x = aStartX newPEnd.x = aStartX
let idx = (roofLines.length < index + 1)?0:index let idx = (roofLines.length < index + 1)?0:index
const newLine = roofLines[idx+1]; const newLine = roofLines[idx+1];
if(Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x2, y: wallLine.y2 }, 'magenta') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x2, y: wallLine.y2 }, 'magenta')
getAddLine({ x: newLine.x2, y: newLine.y2 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') getAddLine({ x: newLine.x2, y: newLine.y2 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray')
findPoints.push({ x: aStartX, y: newPEnd.y }); findPoints.push({ x: aStartX, y: newPEnd.y });
}else{
const cLineX = Big(wallLine.x2).minus(wallBaseLine.x2).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')
} }
}
break;
case 'bottom_in':
}
}
}else if(condition === 'bottom_in') {
if (isStartEnd.start ) { if (isStartEnd.start ) {
const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber() const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
sPoint = {x: wallBaseLine.x1, y: wallBaseLine.y1}; sPoint = {x: wallBaseLine.x1, y: wallBaseLine.y1};
@ -1235,10 +1286,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange') getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange')
} }
}else if(condition === 'bottom_out') {
break; console.log("bottom_out isStartEnd:::::::", isStartEnd);
case 'bottom_out':
if (isStartEnd.start ) { if (isStartEnd.start ) {
const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber() const moveDist = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
const aStartX = Big(roofLine.x1).minus(moveDist).abs().toNumber() const aStartX = Big(roofLine.x1).minus(moveDist).abs().toNumber()
@ -1251,13 +1300,22 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
let idx = (0 > index - 1)?roofLines.length:index let idx = (0 > index - 1)?roofLines.length:index
const newLine = roofLines[idx-1]; const newLine = roofLines[idx-1];
if(Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x1, y: wallLine.y1 }, 'magenta') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x1, y: wallLine.y1 }, 'magenta')
getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') getAddLine({ x: newLine.x1, y: newLine.y1 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray')
findPoints.push({ x: aStartX, y: newPEnd.y }); findPoints.push({ x: aStartX, y: newPEnd.y });
}else{
const cLineX = Big(wallBaseLine.x1).minus(wallLine.x1).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')
}
} }
} }
@ -1272,17 +1330,38 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
newPStart.x = Big(roofLine.x1).plus(eLineX).toNumber() newPStart.x = Big(roofLine.x1).plus(eLineX).toNumber()
let idx = (0 > index - 1)?roofLines.length:index let idx = (0 > index - 1)?roofLines.length:index
const newLine = roofLines[idx-1]; const newLine = roofLines[idx-1];
if(Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
if(inLine){ if(inLine){
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: inLine.x2, y: inLine.y2 }, 'pink')
} }
if(Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x2, y: wallLine.y2 }, 'magenta') getAddLine({ x: bStartX, y: wallLine.y1 }, { x: roofLine.x2, y: wallLine.y2 }, 'magenta')
getAddLine({ x: newLine.x2, y: newLine.y2 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray') getAddLine({ x: newLine.x2, y: newLine.y2 }, { x: newLine.x1, y: wallLine.y1 }, 'Gray')
findPoints.push({ x: aStartX, y: newPEnd.y }); findPoints.push({ x: aStartX, y: newPEnd.y });
}else{
const cLineX = Big(wallBaseLine.y2).minus(wallLine.y2).abs().toNumber()
newPEnd.x = Big(newPEnd.x).plus(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')
}
} }
} }
break;
} }
// 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;
// }
} }
} }
getAddLine(newPStart, newPEnd, 'red') getAddLine(newPStart, newPEnd, 'red')