@eturnity/eturnity_maths 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/splitMergePolygons.js +12 -4
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
isPointBetweenSegment,
|
|
14
14
|
isInsidePolygon,
|
|
15
15
|
verticalProjectionOnPlane,
|
|
16
|
-
|
|
16
|
+
polygonsHaveSame2DOutline
|
|
17
17
|
} from './geometry'
|
|
18
18
|
import { groupBy } from 'lodash'
|
|
19
19
|
import { Polygon } from './objects/Polygon'
|
|
@@ -94,7 +94,15 @@ export function splitPolygons(
|
|
|
94
94
|
const outlineList = getOutlineList(nodeList, edgeList, roofs)
|
|
95
95
|
const polygonList = []
|
|
96
96
|
for (let k = 0; k < outlineList.length; k++) {
|
|
97
|
-
|
|
97
|
+
//check if roof with same outline already exist:
|
|
98
|
+
let roof = roofs.find((roof) =>
|
|
99
|
+
polygonsHaveSame2DOutline(outlineList[k], roof.outline)
|
|
100
|
+
)
|
|
101
|
+
let newRoof=new Polygon(outlineList[k], 'roof')
|
|
102
|
+
if (roof) {
|
|
103
|
+
newRoof.id=roof.id
|
|
104
|
+
}
|
|
105
|
+
polygonList.push(newRoof)
|
|
98
106
|
}
|
|
99
107
|
return polygonList
|
|
100
108
|
}
|
|
@@ -422,10 +430,10 @@ export function getOutlineList(nodeList, edgeList, roofs = []) {
|
|
|
422
430
|
.filter((outline) => outline.length > 0)
|
|
423
431
|
outlines.forEach((outline) => outline.pop())
|
|
424
432
|
|
|
425
|
-
//check for existing roofs
|
|
433
|
+
//check for existing roofs(for z value)
|
|
426
434
|
outlines = outlines.map((outline) => {
|
|
427
435
|
let roof = roofs.find((roof) =>
|
|
428
|
-
|
|
436
|
+
polygonsHaveSame2DOutline(outline, roof.outline)
|
|
429
437
|
)
|
|
430
438
|
if (roof) {
|
|
431
439
|
outline = JSON.parse(JSON.stringify(roof.outline))
|