@eturnity/eturnity_maths 7.16.0-qa-dev03.2 → 7.16.0-qa-dev03.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "7.16.0-qa-dev03.2",
3
+ "version": "7.16.0-qa-dev03.3",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
@@ -13,11 +13,13 @@ import {
13
13
  isPointBetweenSegment,
14
14
  isInsidePolygon,
15
15
  verticalProjectionOnPlane,
16
- polygonsHaveSame2DOutline
16
+ polygonsHaveSame2DOutline,
17
+ calculateArea
17
18
  } from './geometry'
18
19
  import { groupBy } from 'lodash'
19
20
  import { Polygon } from './objects/Polygon'
20
21
  import { defaultBaseHeight, mmTolerance } from './config'
22
+ import { intersectOutlines } from './intersectionPolygon'
21
23
 
22
24
  export function mergePolygons(polygonIdsToMerge, edges, layer) {
23
25
  const outsideEdge = edges.filter((e) => e.belongsTo.length == 1)
@@ -457,7 +459,22 @@ export function getOutlineList(nodeList, edgeList, roofs = []) {
457
459
  )
458
460
  if (roof) {
459
461
  outline = JSON.parse(JSON.stringify(roof.outline))
460
- }
462
+ } else {
463
+ let underneathRoofsIntersectionsData = roofs.map(roof=>{
464
+ const intersections = intersectOutlines(roof.outline,outline)
465
+ let area=0
466
+ if(intersections.length){
467
+ area=calculateArea(intersections[0])
468
+ }
469
+ return {roof,intersectionLength:intersections.length,intersections,area}
470
+ })
471
+ underneathRoofsIntersectionsData = underneathRoofsIntersectionsData.filter(d=>d.intersectionLength > 0)
472
+ if(underneathRoofsIntersectionsData.length>0){
473
+ underneathRoofsIntersectionsData.sort((a,b)=> a.roof.area-b.roof.area)
474
+ let roofUnderneath=underneathRoofsIntersectionsData[0].roof
475
+ outline = outline.map(p=>verticalProjectionOnPlane(p,roofUnderneath.normalVector,roofUnderneath.flatOutline[0]))
476
+ }
477
+ }
461
478
  return outline
462
479
  })
463
480
  return outlines