Compare commits
No commits in common. "67ebf0b514f4f4cf4e4a8b911934d8738293d845" and "618604b52c2f9f5219967aae677da08cb30f21c9" have entirely different histories.
67ebf0b514
...
618604b52c
@ -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()}`
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -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) => {
|
||||||
|
|||||||
@ -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
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user