@eturnity/eturnity_maths 1.0.2 → 1.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/geometry.js CHANGED
@@ -292,7 +292,7 @@ export function getDistanceBetweenPoints(firstPoint, secondPoint) {
292
292
  }
293
293
  }
294
294
 
295
- export function polygonsHasSame2DOutline(outline1, outline2) {
295
+ export function polygonsHaveSame2DOutline(outline1, outline2) {
296
296
  let sameLength = outline1.length == outline2.length
297
297
  return (
298
298
  sameLength &&
@@ -13,7 +13,7 @@ import {
13
13
  isPointBetweenSegment,
14
14
  isInsidePolygon,
15
15
  verticalProjectionOnPlane,
16
- polygonsHasSame2DOutline
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
- polygonList.push(new Polygon(outlineList[k], 'roof'))
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
- polygonsHasSame2DOutline(outline, roof.outline)
436
+ polygonsHaveSame2DOutline(outline, roof.outline)
429
437
  )
430
438
  if (roof) {
431
439
  outline = JSON.parse(JSON.stringify(roof.outline))