Compare commits

..

No commits in common. "67ebf0b514f4f4cf4e4a8b911934d8738293d845" and "618604b52c2f9f5219967aae677da08cb30f21c9" have entirely different histories.

6 changed files with 746 additions and 5235 deletions

View File

@ -57,7 +57,6 @@ export default function Qna() {
endRow : endRow, endRow : endRow,
schMainYn : 'N', schMainYn : 'N',
siteTpCd : 'QC', siteTpCd : 'QC',
langCd : 'JA',
}) })
const apiUrl = `${url}?${params.toString()}` const apiUrl = `${url}?${params.toString()}`

View File

@ -2,7 +2,7 @@ import { fabric } from 'fabric'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { QLine } from '@/components/fabric/QLine' import { QLine } from '@/components/fabric/QLine'
import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util' import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util'
import { calculateAngle, drawGableRoof, drawRoofByAttribute, drawShedRoof, toGeoJSON } from '@/util/qpolygon-utils' import { calculateAngle, drawGableRoof, drawRidgeRoof, drawShedRoof, toGeoJSON } from '@/util/qpolygon-utils'
import * as turf from '@turf/turf' import * as turf from '@turf/turf'
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common' import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
import Big from 'big.js' import Big from 'big.js'
@ -314,18 +314,14 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
} }
const getParallelEavesLines = function (shedLines, lines) { const getParallelEavesLines = function (shedLines, lines) {
const referenceAngle = calculateAngle(shedLines[0].startPoint, shedLines[0].endPoint) const eavesLines = lines.filter((line) => line.attributes?.type === LINE_TYPE.WALLLINE.EAVES)
const otherSideLines = lines.filter((line) => {
const lineAngle = calculateAngle(line.startPoint, line.endPoint)
return Math.abs(referenceAngle - lineAngle) === 180
})
const containNotEaves = otherSideLines.filter((line) => line.attributes?.type !== LINE_TYPE.WALLLINE.EAVES)
if (containNotEaves.length === 0) { const referenceAngle = calculateAngle(shedLines[0].startPoint, shedLines[0].endPoint)
return otherSideLines
} else { return eavesLines.filter((line) => {
return [] const eavesAngle = calculateAngle(line.startPoint, line.endPoint)
} return Math.abs(referenceAngle - eavesAngle) === 180
})
} }
const parallelEaves = getParallelEavesLines(shedLines, lines) const parallelEaves = getParallelEavesLines(shedLines, lines)
@ -341,7 +337,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
// 용마루 -- straight-skeleton // 용마루 -- straight-skeleton
console.log('용마루 지붕') console.log('용마루 지붕')
///drawRidgeRoof(this.id, this.canvas, textMode) ///drawRidgeRoof(this.id, this.canvas, textMode)
drawSkeletonRidgeRoof(this.id, this.canvas, textMode) drawSkeletonRidgeRoof(this.id, this.canvas, textMode);
} else if (isGableRoof(types)) { } else if (isGableRoof(types)) {
// A형, B형 박공 지붕 // A형, B형 박공 지붕
console.log('패턴 지붕') console.log('패턴 지붕')
@ -351,7 +347,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
drawShedRoof(this.id, this.canvas, textMode) drawShedRoof(this.id, this.canvas, textMode)
} else { } else {
console.log('변별로 설정') console.log('변별로 설정')
drawRoofByAttribute(this.id, this.canvas, textMode) drawRidgeRoof(this.id, this.canvas, textMode)
} }
}, },

View File

@ -116,7 +116,6 @@ export function useEavesGableEdit(id) {
useEffect(() => { useEffect(() => {
typeRef.current = type typeRef.current = type
radioTypeRef.current = '1'
}, [type]) }, [type])
const mouseOverEvent = (e) => { const mouseOverEvent = (e) => {

View File

@ -851,15 +851,12 @@ export const usePolygon = () => {
// innerLines와 polygonLines의 겹침을 확인하고 type 변경 // innerLines와 polygonLines의 겹침을 확인하고 type 변경
innerLines.forEach((innerLine) => { innerLines.forEach((innerLine) => {
polygonLines.forEach((polygonLine) => { polygonLines.forEach((polygonLine) => {
if (polygonLine.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
return
}
if (checkLineOverlap(innerLine, polygonLine)) { if (checkLineOverlap(innerLine, polygonLine)) {
// innerLine의 type을 polygonLine의 type으로 변경 // innerLine의 type을 polygonLine의 type으로 변경
if (innerLine.attributes && polygonLine.attributes.type) { if (innerLine.attributes && polygonLine.attributes.type) {
// innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경 // innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경
if (polygonLine.length < innerLine.length) { if (polygonLine.length < innerLine.length) {
if (polygonLine.lineName !== 'eaveHelpLine' || polygonLine.lineName !== 'eaveHelpLine') { if (polygonLine.lineName !== 'eaveHelpLine') {
polygonLine.need = false polygonLine.need = false
} }
} }
@ -1017,7 +1014,6 @@ export const usePolygon = () => {
canvas.add(line) canvas.add(line)
}) })
canvas.renderAll()*/ canvas.renderAll()*/
polygonLines = polygonLines.filter((line) => line.need) polygonLines = polygonLines.filter((line) => line.need)
polygonLines.forEach((line) => { polygonLines.forEach((line) => {
@ -1381,6 +1377,7 @@ export const usePolygon = () => {
let newRoofs = getSplitRoofsPoints(allLines) let newRoofs = getSplitRoofsPoints(allLines)
newRoofs = newRoofs.filter((roof) => roof.length !== 0) newRoofs = newRoofs.filter((roof) => roof.length !== 0)
newRoofs.forEach((roofPoint, index) => { newRoofs.forEach((roofPoint, index) => {
let defense, pitch let defense, pitch
@ -1414,124 +1411,6 @@ export const usePolygon = () => {
} }
}) })
// representLines가 없다면 A,B타입중 하나임
if (representLines.length === 0) {
// 1. roofPoint로 폴리곤의 라인들을 생성
const roofPolygonLines = []
for (let i = 0; i < roofPoint.length; i++) {
const nextIndex = (i + 1) % roofPoint.length
const startPt = roofPoint[i]
const endPt = roofPoint[nextIndex]
roofPolygonLines.push({
x1: startPt.x,
y1: startPt.y,
x2: endPt.x,
y2: endPt.y,
startPoint: startPt,
endPoint: endPt,
})
}
// 3. 평행 여부 확인 함수
const checkParallel = (line1, line2) => {
const v1x = line1.x2 - line1.x1
const v1y = line1.y2 - line1.y1
const v2x = line2.x2 - line2.x1
const v2y = line2.y2 - line2.y1
const length1 = Math.sqrt(v1x ** 2 + v1y ** 2)
const length2 = Math.sqrt(v2x ** 2 + v2y ** 2)
if (length1 === 0 || length2 === 0) return false
const norm1x = v1x / length1
const norm1y = v1y / length1
const norm2x = v2x / length2
const norm2y = v2y / length2
const EPSILON = 0.01
const crossProduct = Math.abs(norm1x * norm2y - norm1y * norm2x)
const dotProduct = norm1x * norm2x + norm1y * norm2y
return crossProduct < EPSILON || Math.abs(Math.abs(dotProduct) - 1) < EPSILON
}
// 4. 점에서 라인까지의 거리 계산 함수
const getDistanceFromPointToLine = (point, lineP1, lineP2) => {
const A = point.x - lineP1.x
const B = point.y - lineP1.y
const C = lineP2.x - lineP1.x
const D = lineP2.y - lineP1.y
const dot = A * C + B * D
const lenSq = C * C + D * D
let param = -1
if (lenSq !== 0) {
param = dot / lenSq
}
let xx, yy
if (param < 0) {
xx = lineP1.x
yy = lineP1.y
} else if (param > 1) {
xx = lineP2.x
yy = lineP2.y
} else {
xx = lineP1.x + param * C
yy = lineP1.y + param * D
}
const dx = point.x - xx
const dy = point.y - yy
return Math.sqrt(dx * dx + dy * dy)
}
// 5. 두 평행한 라인 사이의 거리 계산 (한 라인의 중점에서 다른 라인까지의 거리)
const getDistanceBetweenParallelLines = (line1, line2) => {
const midPoint = {
x: (line1.x1 + line1.x2) / 2,
y: (line1.y1 + line1.y2) / 2,
}
return getDistanceFromPointToLine(midPoint, { x: line2.x1, y: line2.y1 }, { x: line2.x2, y: line2.y2 })
}
// 6. roofPolygonLines의 모든 라인에서 평행하면서 가장 가까운 EAVES 라인 찾기
let closestLine = null
let minDistance = Infinity
roofPolygonLines.forEach((roofLine) => {
;[...polygonLines, ...innerLines].forEach((line) => {
// EAVES 타입만 필터링
if (line.attributes?.type !== LINE_TYPE.WALLLINE.EAVES && line.attributes?.type !== LINE_TYPE.WALLLINE.EAVE_HELP_LINE) {
return
}
const lineObj = {
x1: line.startPoint.x,
y1: line.startPoint.y,
x2: line.endPoint.x,
y2: line.endPoint.y,
}
if (checkParallel(roofLine, lineObj)) {
const distance = getDistanceBetweenParallelLines(roofLine, lineObj)
if (distance < minDistance && distance > 0) {
minDistance = distance
closestLine = line
}
}
})
})
if (closestLine) {
representLines.push(closestLine)
}
}
// representLines중 가장 긴 line을 찾는다. // representLines중 가장 긴 line을 찾는다.
representLines.forEach((line) => { representLines.forEach((line) => {
if (!representLine) { if (!representLine) {

File diff suppressed because it is too large Load Diff

View File

@ -596,6 +596,9 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
}else{ }else{
@ -605,7 +608,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
canvas.renderAll(); canvas.renderAll();
}); });
if (Math.abs(roof.moveUpDown ?? 0) > 0 || Math.abs(roof.moveFlowLine ?? 0) > 0) { if((roof.moveUpDown??0 > 0) || (roof.moveFlowLine??0 > 0) ) {
const getMoveUpDownLine = () => { const getMoveUpDownLine = () => {
// 같은 라인이 없으므로 새 다각형 라인 생성 // 같은 라인이 없으므로 새 다각형 라인 생성
//라인 편집 //라인 편집
@ -653,7 +657,6 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
} }
// 각 라인 집합 정렬 // 각 라인 집합 정렬
// roofLines의 방향에 맞춰 currentRoofLines의 방향을 조정 // roofLines의 방향에 맞춰 currentRoofLines의 방향을 조정
@ -708,13 +711,12 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
}; };
console.log("wallBaseLines", wall.baseLines)
// const sortedWallLines = sortCurrentRoofLines(wall.lines); // const sortedWallLines = sortCurrentRoofLines(wall.lines);
// roofLines의 방향에 맞춰 currentRoofLines 조정 후 정렬 // roofLines의 방향에 맞춰 currentRoofLines 조정 후 정렬
const alignedCurrentRoofLines = alignLineDirection(currentRoofLines, roofLines); const alignedCurrentRoofLines = alignLineDirection(currentRoofLines, roofLines);
const sortedCurrentRoofLines = sortCurrentRoofLines(alignedCurrentRoofLines) const sortedCurrentRoofLines = sortCurrentRoofLines(alignedCurrentRoofLines);
// const sortedRoofLines = sortCurrentRoofLines(roofLines); // const sortedRoofLines = sortCurrentRoofLines(roofLines);
const sortedWallBaseLines = sortCurrentRoofLines(wall.baseLines) const sortedWallBaseLines = sortCurrentRoofLines(wall.baseLines);
// const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines); // const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines);
const sortRoofLines = sortBaseLinesByWallLines(roofLines, wallLines); const sortRoofLines = sortBaseLinesByWallLines(roofLines, wallLines);
@ -728,27 +730,27 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const movedLines = [] const movedLines = []
// 조건에 맞는 라인들만 필터링 // 조건에 맞는 라인들만 필터링
const validWallLines = [...wallLines] const validWallLines = wallLines.filter((wallLine, index) => wallLine.idx - 1 === index);
.sort((a, b) => a.idx - b.idx)
.filter((wallLine, index) => wallLine.idx - 1 === index);
wallLines.length > 3 && wallLines.forEach((wallLine, index) => {
const originalIndex = wallLines.indexOf(wallLine) validWallLines.forEach((wallLine, index) => {
const roofLine = sortRoofLines[originalIndex]
const currentRoofLine = currentRoofLines[originalIndex] const originalIndex = wallLines.indexOf(wallLine);
const moveLine = wall.baseLines[originalIndex] const roofLine = sortRoofLines[originalIndex];
const wallBaseLine = wall.baseLines[originalIndex] const currentRoofLine = currentRoofLines[originalIndex];
const moveLine = wall.baseLines[originalIndex];
const wallBaseLine = wall.baseLines[originalIndex];
// const roofLine = sortRoofLines[index]; // const roofLine = sortRoofLines[index];
// if (roofLine.attributes.wallLine !== wallLine.id || (roofLine.idx - 1) !== index) { if (roofLine.attributes.wallLine !== wallLine.id || (roofLine.idx - 1) !== index) {
// console.log("wallLine2::::", wallLine.id) console.log("wallLine2::::", wallLine.id)
// console.log('roofLine:::', roofLine.attributes.wallLine) console.log('roofLine:::', roofLine.attributes.wallLine)
// console.log("w:::", wallLine.startPoint, wallLine.endPoint) console.log("w:::", wallLine.startPoint, wallLine.endPoint)
// console.log("R:::", roofLine.startPoint, roofLine.endPoint) console.log("R:::", roofLine.startPoint, roofLine.endPoint)
// console.log("not matching roofLine", roofLine); console.log("not matching roofLine", roofLine);
// return false return false
// }//roofLines.find(line => line.attributes.wallLineId === wallLine.attributes.wallId); }//roofLines.find(line => line.attributes.wallLineId === wallLine.attributes.wallId);
// const currentRoofLine = currentRoofLines[index]; // const currentRoofLine = currentRoofLines[index];
// const moveLine = wall.baseLines[index] // const moveLine = wall.baseLines[index]
@ -756,61 +758,61 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
//console.log("wallBaseLine", wallBaseLine); //console.log("wallBaseLine", wallBaseLine);
//roofline 외곽선 설정 //roofline 외곽선 설정
console.log('index::::', index) console.log("index::::", index)
console.log('roofLine:::', roofLine) console.log('roofLine:::', roofLine)
console.log('wallLine', wallLine) console.log('wallLine', wallLine)
console.log('wallBaseLine', wallBaseLine) console.log('wallBaseLine', wallBaseLine)
const origin = moveLine.attributes?.originPoint const origin = moveLine.attributes?.originPoint
if (!origin) return if (!origin) return
console.log('moveLine:', moveLine.x1, moveLine.y1, moveLine.x2, moveLine.y2) if (isSamePoint(moveLine, wallLine)) {
console.log('wallLine:', wallLine.x1, wallLine.y1, wallLine.x2, wallLine.y2)
console.log('isSamePoint result:', isSameLine2(moveLine, wallLine))
if (isSameLine2(moveLine, wallLine)) { return false
return
} }
const movedStart = Math.abs(moveLine.x1 - wallLine.x1) > EPSILON || Math.abs(moveLine.y1 - origin.y1) > EPSILON const movedStart = Math.abs(moveLine.x1 - wallLine.x1) > EPSILON || Math.abs(moveLine.y1 - origin.y1) > EPSILON
const movedEnd = Math.abs(moveLine.x2 - wallLine.x2) > EPSILON || Math.abs(moveLine.y2 - origin.y2) > EPSILON const movedEnd = Math.abs(moveLine.x2 - wallLine.x2) > EPSILON || Math.abs(moveLine.y2 - origin.y2) > EPSILON
const fullyMoved = movedStart && movedEnd const fullyMoved = movedStart && movedEnd
//반시계 방향
//반시계 방향
let newPStart //= {x:roofLine.x1, y:roofLine.y1} let newPStart //= {x:roofLine.x1, y:roofLine.y1}
let newPEnd //= {x:movedLines.x2, y:movedLines.y2} let newPEnd //= {x:movedLines.x2, y:movedLines.y2}
//현재 roof는 무조건 시계방향 //현재 roof는 무조건 시계방향
const getAddLine = (p1, p2, stroke = '') => { const getAddLine = (p1, p2, stroke = '') => {
movedLines.push({ index, p1, p2 }) movedLines.push({ index, p1, p2 })
// Usage: // Usage:
// let mergeLines = mergeMovedLines(movedLines); // let mergeLines = mergeMovedLines(movedLines);
//console.log("mergeLines:::::::", mergeLines); //console.log("mergeLines:::::::", mergeLines);
const line = new QLine([p1.x, p1.y, p2.x, p2.y], { const line = new QLine([p1.x, p1.y, p2.x, p2.y], {
parentId: roof.id, parentId : roof.id,
fontSize: roof.fontSize, fontSize : roof.fontSize,
stroke: 'black', stroke : '#3FBAE6',
strokeWidth: 4, strokeWidth: 4,
name: 'eaveHelpLine', name : 'eaveHelpLine',
lineName: 'eaveHelpLine', lineName : 'eaveHelpLine',
visible: true, visible : true,
roofId: roofId, roofId : roofId,
selectable: true, selectable: true,
hoverCursor: 'pointer', hoverCursor: 'pointer',
attributes: { attributes : {
type: 'eaveHelpLine', type : 'eaveHelpLine',
isStart: true, isStart: true,
pitch: wallLine.attributes.pitch, pitch : wallLine.attributes.pitch,
}, }
}) });
coordinateText(line) //coordinateText(line)
canvas.add(line) canvas.add(line)
line.bringToFront() line.bringToFront()
canvas.renderAll() canvas.renderAll();
return line return line
} }
@ -819,50 +821,47 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
newPStart = { x: roofLine.x1, y: roofLine.y1 } newPStart = { x: roofLine.x1, y: roofLine.y1 }
newPEnd = { x: roofLine.x2, y: roofLine.y2 } newPEnd = { x: roofLine.x2, y: roofLine.y2 }
const getInnerLines = (lines, point) => {} const getInnerLines = (lines, point) => {
}
let isIn = false let isIn = false
let isOut = false let isOut = false
//두 포인트가 변경된 라인인 //두 포인트가 변경된 라인인
if (fullyMoved) { if (fullyMoved) {
//반시계방향향 //반시계방향향
const mLine = getSelectLinePosition(wall, wallBaseLine) const mLine = getSelectLinePosition(wall, wallBaseLine)
if (getOrientation(roofLine) === 'vertical') { if (getOrientation(roofLine) === 'vertical') {
if (['left', 'right'].includes(mLine.position)) { if (['left', 'right'].includes(mLine.position)) {
if (Math.abs(wallLine.x1 - wallBaseLine.x1) < 0.1 || Math.abs(wallLine.x2 - wallBaseLine.x2) < 0.1) { if (Math.abs(wallLine.x1 - wallBaseLine.x1) < 0.1 || Math.abs(wallLine.x2 - wallBaseLine.x2) < 0.1) {
return false return false
} }
const isLeftPosition = mLine.position === 'left' const positionType =
const isRightPosition = mLine.position === 'right' (mLine.position === 'left' && wallLine.x1 < wallBaseLine.x1) ||
const isInPosition = (mLine.position === 'right' && wallLine.x1 > wallBaseLine.x1)
(isLeftPosition && wallLine.x1 < wallBaseLine.x1) || ? 'in' : 'out';
(isRightPosition && wallLine.x1 > wallBaseLine.x1) || const condition = `${mLine.position}_${positionType}`;
(isLeftPosition && wallLine.x2 < wallBaseLine.x2) ||
(isRightPosition && wallLine.x2 > wallBaseLine.x2)
const positionType = isInPosition ? 'in' : 'out'
const condition = `${mLine.position}_${positionType}`
let isStartEnd = findInteriorPoint(wallBaseLine, sortedBaseLines) let isStartEnd = findInteriorPoint(wallBaseLine, sortedBaseLines)
let sPoint, ePoint let sPoint, ePoint;
if (condition === 'left_in') { if (condition === 'left_in') {
isIn = true isIn = true
if (isStartEnd.start) { if (isStartEnd.start) {
newPEnd.y = roofLine.y2 newPEnd.y = roofLine.y2;
newPEnd.x = roofLine.x2 newPEnd.x = roofLine.x2;
const moveDist = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() const moveDist = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber()
ePoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 } ePoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 };
newPStart.y = wallBaseLine.y1 newPStart.y = wallBaseLine.y1
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'left_in_start' }) findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'left_in_start' });
const newPointX = Big(roofLine.x1).plus(moveDist).abs().toNumber() const newPointX = Big(roofLine.x1).plus(moveDist).abs().toNumber()
const pDist = Big(wallLine.x1).minus(roofLine.x1).toNumber() const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber()
const pLineY = Big(roofLine.y1).minus(0).abs().toNumber() const pLineY = Big(roofLine.y1).minus(0).abs().toNumber()
let idx = 0 > index - 1 ? roofLines.length : index let idx = (0 > index - 1) ? roofLines.length : index
const pLineX = roofLines[idx - 1].x1 const pLineX = roofLines[idx - 1].x1
getAddLine({ x: newPStart.x, y: newPStart.y }, { x: ePoint.x, y: ePoint.y }, 'blue') getAddLine({ x: newPStart.x, y: newPStart.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
@ -875,18 +874,18 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
if (isStartEnd.end) { if (isStartEnd.end) {
newPStart.y = roofLine.y1 newPStart.y = roofLine.y1;
newPStart.x = roofLine.x1 newPStart.x = roofLine.x1;
const moveDist = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() const moveDist = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber()
ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 } ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 };
newPEnd.y = wallBaseLine.y2 newPEnd.y = wallBaseLine.y2
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'left_in_end' }) findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'left_in_end' });
const newPointX = Big(roofLine.x1).plus(moveDist).toNumber() const newPointX = Big(roofLine.x1).plus(moveDist).toNumber()
const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber() const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber()
const pLineY = Big(roofLine.y2).minus(0).toNumber() const pLineY = Big(roofLine.y2).minus(0).abs().toNumber()
let idx = roofLines.length < index + 1 ? 0 : index let idx = (roofLines.length < index + 1) ? 0 : index
const pLineX = roofLines[idx + 1].x2 const pLineX = roofLines[idx + 1].x2
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue') getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
@ -898,9 +897,11 @@ 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 === 'left_out') { } else if (condition === 'left_out') {
console.log('left_out::::isStartEnd:::::', isStartEnd) 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()
@ -909,8 +910,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber()
newPStart.y = aStartY newPStart.y = aStartY
newPEnd.y = roofLine.y2 //Big(roofLine.y2).minus(eLineY).toNumber() newPEnd.y = roofLine.y2 //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 (Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
if (inLine) { if (inLine) {
@ -919,13 +920,14 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: bStartY, x: wallLine.x2 }, 'pink') getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: bStartY, x: wallLine.x2 }, 'pink')
} }
} }
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: newPStart.x, position: 'left_out_start' }) findPoints.push({ y: aStartY, x: newPStart.x, position: 'left_out_start' });
} else { } else {
const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber()
newPStart.y = Big(newPStart.y).minus(cLineY).toNumber() newPStart.y = Big(newPStart.y).minus(cLineY).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.x1 < inLine.x2) { if (inLine.x1 < inLine.x2) {
@ -936,8 +938,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
//newPStart.y = wallLine.y1; //newPStart.y = wallLine.y1;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber();
newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber() newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.x2 > inLine.x1) { if (inLine.x2 > inLine.x1) {
@ -947,20 +949,22 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
} }
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()
const aStartY = Big(roofLine.y2).plus(moveDist).toNumber() const aStartY = Big(roofLine.y2).plus(moveDist).toNumber()
const bStartY = Big(wallLine.y2).plus(moveDist).toNumber() const bStartY = Big(wallLine.y2).plus(moveDist).toNumber()
const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 }) const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber() const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber()
newPEnd.y = aStartY newPEnd.y = aStartY
newPStart.y = roofLine.y1 //Big(roofLine.y1).plus(eLineY).toNumber() newPStart.y = roofLine.y1//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 (Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) {
if (inLine) { if (inLine) {
@ -972,10 +976,10 @@ 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, position: 'left_out_end' }) findPoints.push({ y: aStartY, x: newPEnd.x, position: 'left_out_end' });
} else { } else {
const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber()
newPEnd.y = Big(newPEnd.y).plus(cLineY).toNumber() newPEnd.y = Big(newPEnd.y).plus(cLineY).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.x1 < inLine.x2) { if (inLine.x1 < inLine.x2) {
@ -984,11 +988,12 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x }, 'purple') getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x }, 'purple')
} }
} else { } else {
// newPEnd.y = wallLine.y2 // newPEnd.y = wallLine.y2
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber();
newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber() newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.x2 > inLine.x1) { if (inLine.x2 > inLine.x1) {
@ -998,23 +1003,25 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
findPoints.push({ y: newPStart.y, x: newPEnd.x, position: 'left_out_end' }) findPoints.push({ y: newPStart.y, x: newPEnd.x, position: 'left_out_end' });
} }
} else if (condition === 'right_in') { } else if (condition === 'right_in') {
if (isStartEnd.start) { if (isStartEnd.start) {
newPEnd.y = roofLine.y2
newPEnd.x = roofLine.x2 newPEnd.y = roofLine.y2;
newPEnd.x = roofLine.x2;
const moveDist = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() const moveDist = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber()
ePoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 } ePoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 };
newPStart.y = wallBaseLine.y1 newPStart.y = wallBaseLine.y1
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'right_in_start' }) findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'right_in_start' });
const newPointX = Big(roofLine.x1).minus(moveDist).abs().toNumber() const newPointX = Big(roofLine.x1).minus(moveDist).abs().toNumber()
const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber() const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber()
const pLineY = Big(roofLine.y1).minus(0).abs().toNumber() const pLineY = Big(roofLine.y1).minus(0).abs().toNumber()
let idx = 0 >= index - 1 ? roofLines.length : index let idx = (0 >= index - 1) ? roofLines.length : index
const pLineX = roofLines[idx - 1].x1 const pLineX = roofLines[idx - 1].x1
getAddLine({ x: newPStart.x, y: newPStart.y }, { x: ePoint.x, y: ePoint.y }, 'blue') getAddLine({ x: newPStart.x, y: newPStart.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
@ -1027,18 +1034,18 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
if (isStartEnd.end) { if (isStartEnd.end) {
newPStart.y = roofLine.y1 newPStart.y = roofLine.y1;
newPStart.x = roofLine.x1 newPStart.x = roofLine.x1;
const moveDist = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() const moveDist = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber()
ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 } ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 };
newPEnd.y = wallBaseLine.y2 newPEnd.y = wallBaseLine.y2
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'right_in_end' }) findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'right_in_end' });
const newPointX = Big(roofLine.x1).minus(moveDist).toNumber() const newPointX = Big(roofLine.x1).minus(moveDist).toNumber()
const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber() const pDist = Big(wallLine.x1).minus(roofLine.x1).abs().toNumber()
const pLineY = Big(roofLine.y2).minus(0).abs().toNumber() const pLineY = Big(roofLine.y2).minus(0).abs().toNumber()
let idx = roofLines.length < index + 1 ? 0 : index let idx = (roofLines.length < index + 1) ? 0 : index
const pLineX = roofLines[idx + 1].x2 const pLineX = roofLines[idx + 1].x2
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue') getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
@ -1050,20 +1057,20 @@ 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') { } else if (condition === 'right_out') {
console.log('right_out::::isStartEnd:::::', isStartEnd) console.log("right_out::::isStartEnd:::::", isStartEnd);
if (isStartEnd.start) { if (isStartEnd.start) { //x1 inside
//x1 inside
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).abs().toNumber() const aStartY = Big(roofLine.y1).plus(moveDist).abs().toNumber()
const bStartY = Big(wallLine.y1).plus(moveDist).abs().toNumber() const bStartY = Big(wallLine.y1).plus(moveDist).abs().toNumber()
const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 }) const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber() const eLineY = Big(bStartY).minus(wallLine.y1).abs().toNumber()
newPStart.y = aStartY newPStart.y = aStartY
newPEnd.y = roofLine.y2 //Big(roofLine.y2).plus(eLineY).toNumber() newPEnd.y = roofLine.y2//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 (Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
if (inLine) { if (inLine) {
@ -1075,10 +1082,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
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, position: 'right_out_start' }) findPoints.push({ y: aStartY, x: newPEnd.x, position: 'right_out_start' });
} else { } else {
const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber() const cLineY = Big(wallBaseLine.x1).minus(wallLine.x1).abs().toNumber()
newPStart.y = Big(newPStart.y).plus(cLineY).toNumber() newPStart.y = Big(newPStart.y).plus(cLineY).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.x2 < inLine.x1) { if (inLine.x2 < inLine.x1) {
@ -1089,8 +1096,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
//newPStart.y = wallLine.y1; //newPStart.y = wallLine.y1;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.x1).minus(roofLine.x1).abs().toNumber() const rLineM = Big(wallBaseLine.x1).minus(roofLine.x1).abs().toNumber();
newPStart.y = Big(wallBaseLine.y1).plus(rLineM).abs().toNumber() newPStart.y = Big(wallBaseLine.y1).plus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.x2 > inLine.x1) { if (inLine.x2 > inLine.x1) {
@ -1099,8 +1106,11 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPStart.y, x: newPStart.x }, 'purple') getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPStart.y, x: newPStart.x }, 'purple')
} }
} }
} }
} }
} }
if (isStartEnd.end) { if (isStartEnd.end) {
@ -1108,12 +1118,12 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const aStartY = Big(roofLine.y2).minus(moveDist).abs().toNumber() const aStartY = Big(roofLine.y2).minus(moveDist).abs().toNumber()
const bStartY = Big(wallLine.y2).minus(moveDist).abs().toNumber() const bStartY = Big(wallLine.y2).minus(moveDist).abs().toNumber()
const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 }) const inLine = findLineContainingPoint(innerLines, { y: aStartY, x: roofLine.x1 })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber() const eLineY = Big(bStartY).minus(wallLine.y2).abs().toNumber()
newPEnd.y = aStartY newPEnd.y = aStartY
newPStart.y = roofLine.y1 //Big(roofLine.y1).minus(eLineY).toNumber() newPStart.y = roofLine.y1//Big(roofLine.y1).minus(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 (inLine) { if (inLine) {
if (inLine.x2 < inLine.x1) { if (inLine.x2 < inLine.x1) {
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')
@ -1124,10 +1134,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
if (Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) { 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, position: 'right_out_end' }) findPoints.push({ y: aStartY, x: newPEnd.x, position: 'right_out_end' });
} else { } else {
const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber() const cLineY = Big(wallBaseLine.x2).minus(wallLine.x2).abs().toNumber()
newPEnd.y = Big(newPEnd.y).minus(cLineY).toNumber() newPEnd.y = Big(newPEnd.y).minus(cLineY).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.x2 < inLine.x1) { if (inLine.x2 < inLine.x1) {
@ -1139,8 +1149,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
//newPEnd.y = wallLine.y2; //newPEnd.y = wallLine.y2;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber();
newPEnd.y = Big(wallBaseLine.y2).minus(rLineM).abs().toNumber() newPEnd.y = Big(wallBaseLine.y2).minus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.x2 > inLine.x1) { if (inLine.x2 > inLine.x1) {
@ -1149,52 +1159,51 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPEnd.y, x: newPEnd.x }, 'purple') getAddLine({ y: inLine.y2, x: inLine.x2 }, { y: newPEnd.y, x: newPEnd.x }, 'purple')
} }
} }
}
} }
} }
} }
} }
} } else if (getOrientation(roofLine) === 'horizontal') { //red
} else if (getOrientation(roofLine) === 'horizontal') {
//red
if (['top', 'bottom'].includes(mLine.position)) { if (['top', 'bottom'].includes(mLine.position)) {
if (Math.abs(wallLine.y1 - wallBaseLine.y1) < 0.1 || Math.abs(wallLine.y2 - wallBaseLine.y2) < 0.1) { if (Math.abs(wallLine.y1 - wallBaseLine.y1) < 0.1 || Math.abs(wallLine.y2 - wallBaseLine.y2) < 0.1) {
return false return false
} }
const isTopPosition = mLine.position === 'top' const positionType =
const isBottomPosition = mLine.position === 'bottom' (mLine.position === 'top' && wallLine.y1 < wallBaseLine.y1) ||
const isInPosition = (mLine.position === 'bottom' && wallLine.y1 > wallBaseLine.y1)
(isTopPosition && wallLine.y1 < wallBaseLine.y1) || ? 'in' : 'out';
(isBottomPosition && wallLine.y1 > wallBaseLine.y1) ||
(isTopPosition && wallLine.y2 < wallBaseLine.y2) ||
(isBottomPosition && wallLine.y2 > wallBaseLine.y2)
const positionType = isInPosition ? 'in' : 'out' const condition = `${mLine.position}_${positionType}`;
const condition = `${mLine.position}_${positionType}`
let isStartEnd = findInteriorPoint(wallBaseLine, sortedBaseLines) let isStartEnd = findInteriorPoint(wallBaseLine, sortedBaseLines)
let sPoint, ePoint let sPoint, ePoint;
if (condition === 'top_in') { if (condition === 'top_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 };
newPStart.x = wallBaseLine.x1 newPStart.x = wallBaseLine.x1;
const newPointY = Big(roofLine.y2).plus(moveDist).toNumber() const newPointY = Big(roofLine.y2).plus(moveDist).toNumber()
const pDist = Big(wallLine.y2).minus(roofLine.y2).abs().toNumber() const pDist = Big(wallLine.y2).minus(roofLine.y2).abs().toNumber()
const pLineX = Big(roofLine.x1).minus(0).toNumber() const pLineX = Big(roofLine.x1).minus(0).abs().toNumber()
let idx = 0 >= index - 1 ? roofLines.length : index let idx = (0 >= index - 1) ? roofLines.length : index
const pLineY = roofLines[idx - 1].y1 const pLineY = roofLines[idx - 1].y1
getAddLine({ x: newPStart.x, y: newPStart.y }, { x: sPoint.x, y: sPoint.y }, 'blue') getAddLine({ x: newPStart.x, y: newPStart.y }, { x: sPoint.x, y: sPoint.y }, 'blue')
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'top_in_start' }) findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'top_in_start' });
if (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) { if (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green') getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green')
getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink') getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink')
} }
//getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2, y: newPointY }, 'orange') //getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2, y: newPointY }, 'orange')
} }
if (isStartEnd.end) { if (isStartEnd.end) {
@ -1209,17 +1218,19 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
let idx = roofLines.length < index + 1 ? 0 : index let idx = roofLines.length < index + 1 ? 0 : index
const pLineY = roofLines[idx + 1].y2 const pLineY = roofLines[idx + 1].y2
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: sPoint.x, y: sPoint.y }, 'blue') getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: sPoint.x, y: sPoint.y }, 'blue')
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'top_in_end' }) findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'top_in_end' });
if (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) { if (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green') getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green')
getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink') getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink')
} }
//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 === 'top_out') { } else if (condition === 'top_out') {
console.log('top_out isStartEnd:::::::', isStartEnd) console.log("top_out isStartEnd:::::::", 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()
@ -1230,8 +1241,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber() const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber()
newPEnd.x = roofLine.x2 //Big(newPEnd.x).plus(eLineX).toNumber() newPEnd.x = roofLine.x2 //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 (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
if (inLine) { if (inLine) {
@ -1243,10 +1254,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
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, position: 'top_out_start' }) findPoints.push({ x: aStartX, y: newPEnd.y, position: 'top_out_start' });
} else { } else {
const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber()
newPStart.x = Big(newPStart.x).plus(cLineX).toNumber() newPStart.x = Big(newPStart.x).plus(cLineX).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.y2 > inLine.y1) { if (inLine.y2 > inLine.y1) {
@ -1254,10 +1265,11 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPStart.y, x: newPStart.x }, 'purple') getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPStart.y, x: newPStart.x }, 'purple')
} }
} else { } else {
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber() const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber();
newPStart.x = Big(wallBaseLine.x1).plus(rLineM).abs().toNumber() newPStart.x = Big(wallBaseLine.x1).plus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.y2 > inLine.y1) { if (inLine.y2 > inLine.y1) {
@ -1267,6 +1279,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
} }
if (isStartEnd.end) { if (isStartEnd.end) {
@ -1274,12 +1287,12 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const aStartX = Big(roofLine.x2).minus(moveDist).abs().toNumber() const aStartX = Big(roofLine.x2).minus(moveDist).abs().toNumber()
const bStartX = Big(wallLine.x2).minus(moveDist).abs().toNumber() const bStartX = Big(wallLine.x2).minus(moveDist).abs().toNumber()
const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y }) const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: newPEnd.y })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber() const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber()
newPStart.x = roofLine.x1 //Big(newPStart.x).minus(eLineX).abs().toNumber() newPStart.x = roofLine.x1;//Big(newPStart.x).minus(eLineX).abs().toNumber()
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 (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
if (inLine) { if (inLine) {
@ -1288,13 +1301,14 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
getAddLine({ x: inLine.x1, y: inLine.y1 }, { x: bStartX, y: wallLine.y1 }, 'pink') getAddLine({ x: inLine.x1, y: inLine.y1 }, { x: bStartX, y: wallLine.y1 }, 'pink')
} }
} }
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, position: 'top_out_end' }) findPoints.push({ x: aStartX, y: newPEnd.y, position: 'top_out_end' });
} else { } else {
const cLineX = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber() const cLineX = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber()
newPEnd.x = Big(newPEnd.x).minus(cLineX).toNumber() newPEnd.x = Big(newPEnd.x).minus(cLineX).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.y2 > inLine.y1) { if (inLine.y2 > inLine.y1) {
@ -1305,8 +1319,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
//newPEnd.x = wallLine.x2; //newPEnd.x = wallLine.x2;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber() const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber();
newPEnd.x = Big(wallBaseLine.x2).minus(rLineM).abs().toNumber() newPEnd.x = Big(wallBaseLine.x2).minus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.y1 > inLine.y2) { if (inLine.y1 > inLine.y2) {
@ -1316,22 +1330,24 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
} }
} else if (condition === '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 };
newPStart.x = wallBaseLine.x1 newPStart.x = wallBaseLine.x1;
const newPointY = Big(roofLine.y2).minus(moveDist).toNumber() const newPointY = Big(roofLine.y2).minus(moveDist).toNumber()
const pDist = Big(wallLine.y2).minus(roofLine.y2).abs().toNumber() const pDist = Big(wallLine.y2).minus(roofLine.y2).abs().toNumber()
const pLineX = Big(roofLine.x1).minus(0).abs().toNumber() const pLineX = Big(roofLine.x1).minus(0).abs().toNumber()
let idx = 0 > index - 1 ? roofLines.length : index let idx = (0 > index - 1) ? roofLines.length : index
const pLineY = roofLines[idx - 1].y1 const pLineY = roofLines[idx - 1].y1
getAddLine({ x: newPStart.x, y: newPStart.y }, { x: sPoint.x, y: sPoint.y }, 'blue') getAddLine({ x: newPStart.x, y: newPStart.y }, { x: sPoint.x, y: sPoint.y }, 'blue')
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'bottom_in_start' }) findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'bottom_in_start' });
if (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) { if (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green') getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green')
@ -1342,37 +1358,40 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
if (isStartEnd.end) { if (isStartEnd.end) {
const moveDist = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber() const moveDist = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber()
sPoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 } sPoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 };
newPEnd.x = wallBaseLine.x2 newPEnd.x = wallBaseLine.x2;
const newPointY = Big(roofLine.y1).minus(moveDist).toNumber() const newPointY = Big(roofLine.y1).minus(moveDist).toNumber()
const pDist = Big(wallLine.y1).minus(roofLine.y1).abs().toNumber() const pDist = Big(wallLine.y1).minus(roofLine.y1).abs().toNumber()
const pLineX = Big(roofLine.x2).minus(0).abs().toNumber() const pLineX = Big(roofLine.x2).minus(0).abs().toNumber()
let idx = roofLines.length < index + 1 ? 0 : index let idx = (roofLines.length < index + 1) ? 0 : index
const pLineY = roofLines[idx + 1].y2 const pLineY = roofLines[idx + 1].y2
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: sPoint.x, y: sPoint.y }, 'blue') getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: sPoint.x, y: sPoint.y }, 'blue')
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'bottom_in_end' }) findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'bottom_in_end' });
if (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) { if (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green') getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green')
getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink') getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink')
} }
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') { } else if (condition === 'bottom_out') {
console.log('bottom_out isStartEnd:::::::', isStartEnd) console.log("bottom_out isStartEnd:::::::", 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).minus(moveDist).abs().toNumber() const aStartX = Big(roofLine.x1).minus(moveDist).abs().toNumber()
const bStartX = Big(wallLine.x1).minus(moveDist).abs().toNumber() const bStartX = Big(wallLine.x1).minus(moveDist).abs().toNumber()
const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: roofLine.y1 }) const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: roofLine.y1 })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber() const eLineX = Big(bStartX).minus(wallLine.x1).abs().toNumber()
newPEnd.x = roofLine.x2 //Big(roofLine.x2).minus(eLineX).toNumber() newPEnd.x = roofLine.x2//Big(roofLine.x2).minus(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 (Math.abs(wallBaseLine.x1 - wallLine.x1) < 0.1) {
if (inLine) { if (inLine) {
@ -1384,10 +1403,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
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, position: 'bottom_out_start' }) findPoints.push({ x: aStartX, y: newPEnd.y, position: 'bottom_out_start' });
} else { } else {
const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber() const cLineX = Big(wallBaseLine.y1).minus(wallLine.y1).abs().toNumber()
newPStart.x = Big(newPStart.x).minus(cLineX).toNumber() newPStart.x = Big(newPStart.x).minus(cLineX).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.y2 < inLine.y1) { if (inLine.y2 < inLine.y1) {
@ -1398,8 +1417,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
//newPStart.x = wallLine.x1; //newPStart.x = wallLine.x1;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber() const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber();
newPStart.x = Big(wallBaseLine.x1).minus(rLineM).abs().toNumber() newPStart.x = Big(wallBaseLine.x1).minus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if (inLine) { if (inLine) {
if (inLine.y2 > inLine.y1) { if (inLine.y2 > inLine.y1) {
@ -1409,6 +1428,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
} }
@ -1417,12 +1437,12 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const aStartX = Big(roofLine.x2).plus(moveDist).toNumber() const aStartX = Big(roofLine.x2).plus(moveDist).toNumber()
const bStartX = Big(wallLine.x2).plus(moveDist).toNumber() const bStartX = Big(wallLine.x2).plus(moveDist).toNumber()
const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: roofLine.y1 }) const inLine = findLineContainingPoint(innerLines, { x: aStartX, y: roofLine.y1 })
console.log('startLines:::::::', inLine) console.log("startLines:::::::", inLine);
const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber() const eLineX = Big(bStartX).minus(wallLine.x2).abs().toNumber()
newPEnd.x = aStartX newPEnd.x = aStartX
newPStart.x = roofLine.x1 //Big(roofLine.x1).plus(eLineX).toNumber() newPStart.x = roofLine.x1;//Big(roofLine.x1).plus(eLineX).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.x2 - wallLine.x2) < 0.1) { if (Math.abs(wallBaseLine.x2 - wallLine.x2) < 0.1) {
if (inLine) { if (inLine) {
@ -1434,10 +1454,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
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, position: 'bottom_out_end' }) findPoints.push({ x: aStartX, y: newPEnd.y, position: 'bottom_out_end' });
} else { } else {
const cLineX = Big(wallBaseLine.y2).minus(wallLine.y2).abs().toNumber() const cLineX = Big(wallBaseLine.y2).minus(wallLine.y2).abs().toNumber()
newPEnd.x = Big(newPEnd.x).plus(cLineX).toNumber() newPEnd.x = Big(newPEnd.x).plus(cLineX).toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.y2 < inLine.y1) { if (inLine.y2 < inLine.y1) {
@ -1448,8 +1468,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} else { } else {
//newPEnd.x = wallLine.x2; //newPEnd.x = wallLine.x2;
//외곽 라인 그리기 //외곽 라인 그리기
const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber() const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber();
newPEnd.x = Big(wallBaseLine.x2).plus(rLineM).abs().toNumber() newPEnd.x = Big(wallBaseLine.x2).plus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if (inLine) { if (inLine) {
if (inLine.y1 > inLine.y2) { if (inLine.y1 > inLine.y2) {
@ -1459,6 +1479,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
} }
} }
} }
} }
} }
@ -1468,9 +1489,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
getAddLine(newPStart, newPEnd, 'red') getAddLine(newPStart, newPEnd, 'red')
//canvas.remove(roofLine) //canvas.remove(roofLine)
} else { } else {
getAddLine(roofLine.startPoint, roofLine.endPoint) getAddLine(roofLine.startPoint, roofLine.endPoint,)
} }
canvas.renderAll() canvas.renderAll()
}); });
} }
@ -2338,14 +2360,6 @@ function isSamePoint(p1, p2, tolerance = 0.1) {
return Math.abs(p1.x - p2.x) < tolerance && Math.abs(p1.y - p2.y) < tolerance; return Math.abs(p1.x - p2.x) < tolerance && Math.abs(p1.y - p2.y) < tolerance;
} }
function isSameLine2(line1, line2, tolerance = 0.1) {
return (
Math.abs(line1.x1 - line2.x1) < tolerance &&
Math.abs(line1.y1 - line2.y1) < tolerance &&
Math.abs(line1.x2 - line2.x2) < tolerance &&
Math.abs(line1.y2 - line2.y2) < tolerance
);
}
// 두 점을 지나는 직선의 기울기 계산 // 두 점을 지나는 직선의 기울기 계산
function calculateSlope(p1, p2) { function calculateSlope(p1, p2) {
// 수직선인 경우 (기울기 무한대) // 수직선인 경우 (기울기 무한대)