Compare commits
3 Commits
273f62bd0c
...
ebfc7da6a3
| Author | SHA1 | Date | |
|---|---|---|---|
| ebfc7da6a3 | |||
| c6c5fabbf2 | |||
| 4d2b872183 |
@ -183,7 +183,7 @@ const movingLineFromSkeleton = (roofId, canvas) => {
|
|||||||
let newEndPoint = {...originalEndPoint};
|
let newEndPoint = {...originalEndPoint};
|
||||||
|
|
||||||
// 위치와 방향에 따라 좌표 조정
|
// 위치와 방향에 따라 좌표 조정
|
||||||
/*
|
/*
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 'left':
|
case 'left':
|
||||||
if (moveDirection === 'up') {
|
if (moveDirection === 'up') {
|
||||||
@ -222,7 +222,7 @@ const movingLineFromSkeleton = (roofId, canvas) => {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// 원본 라인 업데이트
|
// 원본 라인 업데이트
|
||||||
// newPoints 배열에서 일치하는 포인트들을 찾아서 업데이트
|
// newPoints 배열에서 일치하는 포인트들을 찾아서 업데이트
|
||||||
console.log('absMove::', absMove);
|
console.log('absMove::', absMove);
|
||||||
@ -522,7 +522,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
//2. 연결이 끊어진 스켈레톤 선을 찾아 연장합니다.
|
//2. 연결이 끊어진 스켈레톤 선을 찾아 연장합니다.
|
||||||
const { disconnectedLines } = findDisconnectedSkeletonLines(skeletonLines, roof.lines);
|
const { disconnectedLines } = findDisconnectedSkeletonLines(skeletonLines, roof.lines);
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
|||||||
trimIntersectingExtendedLines(skeletonLines, disconnectedLines);
|
trimIntersectingExtendedLines(skeletonLines, disconnectedLines);
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//2. 연결이 끊어진 라인이 있을경우 찾아서 추가한다(동 이동일때)
|
//2. 연결이 끊어진 라인이 있을경우 찾아서 추가한다(동 이동일때)
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
|||||||
canvas.renderAll();
|
canvas.renderAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
if((roof.moveUpDown??0 > 0) ) {
|
if((roof.moveUpDown??0 > 0) ) {
|
||||||
|
|
||||||
// 같은 라인이 없으므로 새 다각형 라인 생성
|
// 같은 라인이 없으므로 새 다각형 라인 생성
|
||||||
//라인 편집
|
//라인 편집
|
||||||
@ -780,7 +780,7 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
|
|
||||||
// Check if wallBaseLine is inside the polygon formed by sortedWallLines
|
// Check if wallBaseLine is inside the polygon formed by sortedWallLines
|
||||||
|
|
||||||
/*
|
/*
|
||||||
console.log('=== Line Coordinates ===');
|
console.log('=== Line Coordinates ===');
|
||||||
console.table({
|
console.table({
|
||||||
'Point' : ['X', 'Y'],
|
'Point' : ['X', 'Y'],
|
||||||
@ -797,7 +797,7 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
'moveLine' : [moveLine.x2, moveLine.y2],
|
'moveLine' : [moveLine.x2, moveLine.y2],
|
||||||
'wallBaseLine' : [wallBaseLine.x2, wallBaseLine.y2]
|
'wallBaseLine' : [wallBaseLine.x2, wallBaseLine.y2]
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
const origin = moveLine.attributes?.originPoint
|
const origin = moveLine.attributes?.originPoint
|
||||||
if (!origin) return
|
if (!origin) return
|
||||||
|
|
||||||
@ -875,10 +875,9 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
(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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
}
|
}
|
||||||
//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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
? '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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
//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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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,24 +1330,45 @@ if((roof.moveUpDown??0 > 0) ) {
|
|||||||
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')
|
||||||
}
|
}
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findPoints.length > 0) {
|
if (findPoints.length > 0) {
|
||||||
// 모든 점에 대해 라인 업데이트를 누적
|
// 모든 점에 대해 라인 업데이트를 누적
|
||||||
@ -2017,6 +2096,7 @@ export {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the opposite line in a polygon based on the given line
|
* Finds the opposite line in a polygon based on the given line
|
||||||
* @param {Array} edges - The polygon edges from canvas.skeleton.Edges
|
* @param {Array} edges - The polygon edges from canvas.skeleton.Edges
|
||||||
@ -2267,7 +2347,6 @@ function clipLineToRoofBoundary(p1, p2, roofLines, selectLine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function isPointInsidePolygon(point, roofLines) {
|
function isPointInsidePolygon(point, roofLines) {
|
||||||
// 1. 먼저 경계선 위에 있는지 확인 (방향 무관)
|
// 1. 먼저 경계선 위에 있는지 확인 (방향 무관)
|
||||||
if (isOnBoundaryDirectionIndependent(point, roofLines)) {
|
if (isOnBoundaryDirectionIndependent(point, roofLines)) {
|
||||||
@ -2388,6 +2467,39 @@ function getLineDirection(p1, p2) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// selectLine과 baseLines 비교하여 방향 찾기
|
||||||
|
function findLineDirection(selectLine, baseLines) {
|
||||||
|
for (const baseLine of baseLines) {
|
||||||
|
// baseLine의 시작점과 끝점
|
||||||
|
const baseStart = baseLine.startPoint;
|
||||||
|
const baseEnd = baseLine.endPoint;
|
||||||
|
|
||||||
|
// selectLine의 시작점과 끝점
|
||||||
|
const selectStart = selectLine.startPoint;
|
||||||
|
const selectEnd = selectLine.endPoint;
|
||||||
|
|
||||||
|
// 정방향 또는 역방향으로 일치하는지 확인
|
||||||
|
if ((isSamePoint(baseStart, selectStart) && isSamePoint(baseEnd, selectEnd)) ||
|
||||||
|
(isSamePoint(baseStart, selectEnd) && isSamePoint(baseEnd, selectStart))) {
|
||||||
|
|
||||||
|
// baseLine의 방향 계산
|
||||||
|
const dx = baseEnd.x - baseStart.x;
|
||||||
|
const dy = baseEnd.y - baseStart.y;
|
||||||
|
|
||||||
|
// 기울기를 바탕으로 방향 판단
|
||||||
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
|
return dx > 0 ? 'right' : 'left';
|
||||||
|
} else {
|
||||||
|
return dy > 0 ? 'down' : 'up';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // 일치하는 라인이 없는 경우
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* baseLines를 연결하여 다각형 순서로 정렬된 점들 반환
|
* baseLines를 연결하여 다각형 순서로 정렬된 점들 반환
|
||||||
* @param {Array} baseLines - 라인 배열
|
* @param {Array} baseLines - 라인 배열
|
||||||
@ -2709,89 +2821,54 @@ const analyzeLineOrientation = (x1, y1, x2, y2, epsilon = 0.5) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function extendLineToBoundary(p1, p2, roofLines) {
|
|
||||||
// 1. Calculate line direction and length
|
|
||||||
const dx = p2.x - p1.x;
|
|
||||||
const dy = p2.y - p1.y;
|
|
||||||
const length = Math.sqrt(dx * dx + dy * dy);
|
|
||||||
if (length === 0) return { p1: { ...p1 }, p2: { ...p2 } };
|
|
||||||
|
|
||||||
// 2. Get all polygon points
|
// 점에서 선분까지의 최단 거리를 계산하는 도우미 함수
|
||||||
const points = [];
|
function pointToLineDistance(point, lineP1, lineP2) {
|
||||||
const seen = new Set();
|
const A = point.x - lineP1.x;
|
||||||
|
const B = point.y - lineP1.y;
|
||||||
|
const C = lineP2.x - lineP1.x;
|
||||||
|
const D = lineP2.y - lineP1.y;
|
||||||
|
|
||||||
for (const line of roofLines) {
|
const dot = A * C + B * D;
|
||||||
const p1 = { x: line.x1, y: line.y1 };
|
const lenSq = C * C + D * D;
|
||||||
const p2 = { x: line.x2, y: line.y2 };
|
let param = -1;
|
||||||
|
|
||||||
const key1 = `${p1.x},${p1.y}`;
|
if (lenSq !== 0) {
|
||||||
const key2 = `${p2.x},${p2.y}`;
|
param = dot / lenSq;
|
||||||
|
|
||||||
if (!seen.has(key1)) {
|
|
||||||
points.push(p1);
|
|
||||||
seen.add(key1);
|
|
||||||
}
|
|
||||||
if (!seen.has(key2)) {
|
|
||||||
points.push(p2);
|
|
||||||
seen.add(key2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Find the bounding box
|
let xx, yy;
|
||||||
let minX = Infinity, minY = Infinity;
|
|
||||||
let maxX = -Infinity, maxY = -Infinity;
|
|
||||||
|
|
||||||
for (const p of points) {
|
if (param < 0) {
|
||||||
minX = Math.min(minX, p.x);
|
xx = lineP1.x;
|
||||||
minY = Math.min(minY, p.y);
|
yy = lineP1.y;
|
||||||
maxX = Math.max(maxX, p.x);
|
} else if (param > 1) {
|
||||||
maxY = Math.max(maxY, p.y);
|
xx = lineP2.x;
|
||||||
|
yy = lineP2.y;
|
||||||
|
} else {
|
||||||
|
xx = lineP1.x + param * C;
|
||||||
|
yy = lineP1.y + param * D;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Extend line to bounding box
|
const dx = point.x - xx;
|
||||||
const bboxLines = [
|
const dy = point.y - yy;
|
||||||
{ x1: minX, y1: minY, x2: maxX, y2: minY }, // top
|
return Math.sqrt(dx * dx + dy * dy);
|
||||||
{ x1: maxX, y1: minY, x2: maxX, y2: maxY }, // right
|
|
||||||
{ x1: maxX, y1: maxY, x2: minX, y2: maxY }, // bottom
|
|
||||||
{ x1: minX, y1: maxY, x2: minX, y2: minY } // left
|
|
||||||
];
|
|
||||||
|
|
||||||
const intersections = [];
|
|
||||||
|
|
||||||
// 5. Find intersections with bounding box
|
|
||||||
for (const line of bboxLines) {
|
|
||||||
const intersect = getLineIntersection(
|
|
||||||
p1, p2,
|
|
||||||
{ x: line.x1, y: line.y1 },
|
|
||||||
{ x: line.x2, y: line.y2 }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (intersect) {
|
|
||||||
const t = ((intersect.x - p1.x) * dx + (intersect.y - p1.y) * dy) / (length * length);
|
|
||||||
if (t >= 0 && t <= 1) {
|
|
||||||
intersections.push({ x: intersect.x, y: intersect.y, t });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. If we have two intersections, use them
|
|
||||||
if (intersections.length >= 2) {
|
|
||||||
// Sort by t value
|
|
||||||
intersections.sort((a, b) => a.t - b.t);
|
|
||||||
return {
|
|
||||||
p1: { x: intersections[0].x, y: intersections[0].y },
|
|
||||||
p2: {
|
|
||||||
x: intersections[intersections.length - 1].x,
|
|
||||||
y: intersections[intersections.length - 1].y
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. Fallback to original points
|
|
||||||
return { p1: { ...p1 }, p2: { ...p2 } };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const getOrientation = (line, eps = 0.1) => {
|
||||||
|
const x1 = line.get('x1')
|
||||||
|
const y1 = line.get('y1')
|
||||||
|
const x2 = line.get('x2')
|
||||||
|
const y2 = line.get('y2')
|
||||||
|
const dx = Math.abs(x2 - x1)
|
||||||
|
const dy = Math.abs(y2 - y1)
|
||||||
|
|
||||||
|
if (dx < eps && dy >= eps) return 'vertical'
|
||||||
|
if (dy < eps && dx >= eps) return 'horizontal'
|
||||||
|
if (dx < eps && dy < eps) return 'point'
|
||||||
|
return 'diagonal'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2975,9 +3052,35 @@ function updateAndAddLine(innerLines, targetPoint) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 점이 선분 위에 있는지 확인
|
||||||
|
* @param {Object} point - 확인할 점 {x, y}
|
||||||
|
* @param {Object} lineStart - 선분의 시작점 {x, y}
|
||||||
|
* @param {Object} lineEnd - 선분의 끝점 {x, y}
|
||||||
|
* @param {number} tolerance - 오차 허용 범위
|
||||||
|
* @returns {boolean} - 점이 선분 위에 있으면 true, 아니면 false
|
||||||
|
*/
|
||||||
|
function isPointOnLineSegment2(point, lineStart, lineEnd, tolerance = 0.1) {
|
||||||
|
const { x: px, y: py } = point;
|
||||||
|
const { x: x1, y: y1 } = lineStart;
|
||||||
|
const { x: x2, y: y2 } = lineEnd;
|
||||||
|
|
||||||
|
// 선분의 길이
|
||||||
|
const lineLength = Math.hypot(x2 - x1, y2 - y1);
|
||||||
|
|
||||||
|
// 점에서 선분의 양 끝점까지의 거리
|
||||||
|
const dist1 = Math.hypot(px - x1, py - y1);
|
||||||
|
const dist2 = Math.hypot(px - x2, py - y2);
|
||||||
|
|
||||||
|
// 점이 선분 위에 있는지 확인 (오차 허용 범위 내에서)
|
||||||
|
const isOnSegment = Math.abs((dist1 + dist2) - lineLength) <= tolerance;
|
||||||
|
|
||||||
|
if (isOnSegment) {
|
||||||
|
console.log(`점 (${px}, ${py})은 선분 [(${x1}, ${y1}), (${x2}, ${y2})] 위에 있습니다.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOnSegment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 세 점(p1 -> p2 -> p3)의 방향성을 계산합니다. (2D 외적)
|
* 세 점(p1 -> p2 -> p3)의 방향성을 계산합니다. (2D 외적)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user