지붕 형상 로직 변경 및 시계방향 외벽선 작도에 대한 대응
This commit is contained in:
parent
213b020a3d
commit
6397de0e76
@ -68,6 +68,8 @@ export function useRoofShapeSetting(id) {
|
|||||||
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
||||||
const { post } = useAxios(globalLocaleState)
|
const { post } = useAxios(globalLocaleState)
|
||||||
|
|
||||||
|
const { addLine, removeLine } = useLine()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pitchRef.current = currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch)
|
pitchRef.current = currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch)
|
||||||
}, [pitch])
|
}, [pitch])
|
||||||
@ -182,6 +184,41 @@ export function useRoofShapeSetting(id) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 외벽선이 시계방향인지 시계반대 방향인지 확인
|
||||||
|
*/
|
||||||
|
const outerLinePoints = outerLines.map((line) => ({ x: line.x1, y: line.y1 }))
|
||||||
|
let counterClockwise = true
|
||||||
|
let signedArea = 0
|
||||||
|
|
||||||
|
outerLinePoints.forEach((point, index) => {
|
||||||
|
const nextPoint = outerLinePoints[(index + 1) % outerLinePoints.length]
|
||||||
|
signedArea += point.x * nextPoint.y - point.y * nextPoint.x
|
||||||
|
})
|
||||||
|
|
||||||
|
if (signedArea > 0) {
|
||||||
|
counterClockwise = false
|
||||||
|
}
|
||||||
|
/** 시계 방향일 경우 외벽선 reverse*/
|
||||||
|
if (!counterClockwise) {
|
||||||
|
outerLines.reverse().forEach((line, index) => {
|
||||||
|
addLine([line.x2, line.y2, line.x1, line.y1], {
|
||||||
|
stroke: line.stroke,
|
||||||
|
strokeWidth: line.strokeWidth,
|
||||||
|
idx: index,
|
||||||
|
selectable: line.selectable,
|
||||||
|
name: 'outerLine',
|
||||||
|
x1: line.x2,
|
||||||
|
y1: line.y2,
|
||||||
|
x2: line.x1,
|
||||||
|
y2: line.y1,
|
||||||
|
visible: line.visible,
|
||||||
|
})
|
||||||
|
canvas.remove(line)
|
||||||
|
})
|
||||||
|
canvas.renderAll()
|
||||||
|
}
|
||||||
|
|
||||||
if ([1, 2, 3, 5, 6, 7, 8].includes(shapeNum)) {
|
if ([1, 2, 3, 5, 6, 7, 8].includes(shapeNum)) {
|
||||||
// 변별로 설정이 아닌 경우 경사를 지붕재에 적용해주어야함
|
// 변별로 설정이 아닌 경우 경사를 지붕재에 적용해주어야함
|
||||||
setRoofPitch()
|
setRoofPitch()
|
||||||
|
|||||||
@ -2555,7 +2555,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
{ x: currentRoof.x2, y: currentRoof.y2 },
|
{ x: currentRoof.x2, y: currentRoof.y2 },
|
||||||
]
|
]
|
||||||
const prevHipLines = []
|
const prevHipLines = []
|
||||||
const nextHipLine = []
|
const nextHipLines = []
|
||||||
let prevLineRidge, nextLineRidge
|
let prevLineRidge, nextLineRidge
|
||||||
|
|
||||||
baseHipLines.forEach((current) => {
|
baseHipLines.forEach((current) => {
|
||||||
@ -2584,7 +2584,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
y: line.y1,
|
y: line.y1,
|
||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
nextHipLine.push(current)
|
nextHipLines.push(current)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
prevHipLines.forEach((current) => {
|
prevHipLines.forEach((current) => {
|
||||||
@ -2633,7 +2633,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
nextHipLine.forEach((current) => {
|
nextHipLines.forEach((current) => {
|
||||||
if (nextLine.attributes.type === LINE_TYPE.WALLLINE.JERKINHEAD) {
|
if (nextLine.attributes.type === LINE_TYPE.WALLLINE.JERKINHEAD) {
|
||||||
let findPoint
|
let findPoint
|
||||||
if (Math.abs(current.x1 - currentRoof.x2) <= 1 && Math.abs(current.y1 - currentRoof.y2) <= 1) {
|
if (Math.abs(current.x1 - currentRoof.x2) <= 1 && Math.abs(current.y1 - currentRoof.y2) <= 1) {
|
||||||
@ -2740,7 +2740,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
/** 4각*/
|
/** 4각*/
|
||||||
if (prevLineRidge === nextLineRidge) {
|
if (prevLineRidge === nextLineRidge) {
|
||||||
polygonPoints.push({ x: ridgeLine.x1, y: ridgeLine.y1 }, { x: ridgeLine.x2, y: ridgeLine.y2 })
|
polygonPoints.push({ x: ridgeLine.x1, y: ridgeLine.y1 }, { x: ridgeLine.x2, y: ridgeLine.y2 })
|
||||||
}
|
} else {
|
||||||
/** 6각이상*/
|
/** 6각이상*/
|
||||||
let isOverLap =
|
let isOverLap =
|
||||||
currentVectorX === 0
|
currentVectorX === 0
|
||||||
@ -2974,6 +2974,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/** 중복되는 포인트 제거 */
|
/** 중복되는 포인트 제거 */
|
||||||
const uniquePoints = []
|
const uniquePoints = []
|
||||||
polygonPoints.forEach((point) => {
|
polygonPoints.forEach((point) => {
|
||||||
@ -3043,14 +3044,12 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
const intersection = edgesIntersection(checkEdge, lineEdge)
|
const intersection = edgesIntersection(checkEdge, lineEdge)
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
if (isPointOnLine(line, intersection)) {
|
|
||||||
intersectionRoofs.push({
|
intersectionRoofs.push({
|
||||||
line,
|
line,
|
||||||
intersection,
|
intersection,
|
||||||
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(),
|
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const checkEdge = {
|
const checkEdge = {
|
||||||
@ -3063,14 +3062,12 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
const intersection = edgesIntersection(checkEdge, lineEdge)
|
const intersection = edgesIntersection(checkEdge, lineEdge)
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
if (isPointOnLine(line, intersection)) {
|
|
||||||
intersectionRoofs.push({
|
intersectionRoofs.push({
|
||||||
line,
|
line,
|
||||||
intersection,
|
intersection,
|
||||||
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(),
|
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let currentRoof, prevRoof, nextRoof
|
let currentRoof, prevRoof, nextRoof
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user