@eturnity/eturnity_maths 8.34.0 → 8.46.0

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": "8.34.0",
3
+ "version": "8.46.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/geometry.js CHANGED
@@ -493,12 +493,16 @@ export function isInsideEdge2D(M, A, B) {
493
493
  return result
494
494
  }
495
495
 
496
- export function polygonsHaveSame2DOutline(outline1, outline2) {
496
+ export function polygonsHaveSame2DOutline(outline1, outline2, tolerance = 0) {
497
497
  let sameLength = outline1.length == outline2.length
498
498
  return (
499
499
  sameLength &&
500
- outline1.every((p) => outline2.find((v) => v.x == p.x && v.y == p.y)) &&
501
- outline2.every((p) => outline1.find((v) => v.x == p.x && v.y == p.y))
500
+ outline1.every((p) =>
501
+ outline2.find((v) => isAlmostSamePoint2D(v, p, tolerance))
502
+ ) &&
503
+ outline2.every((p) =>
504
+ outline1.find((v) => isAlmostSamePoint2D(v, p, tolerance))
505
+ )
502
506
  )
503
507
  }
504
508
 
@@ -36,6 +36,7 @@ export class Polygon {
36
36
  this.isLoading = false
37
37
  this.positionOffset = { x: 0, y: 0, z: 0 }
38
38
  this.angleOffset = 0
39
+ this.dataSource = null
39
40
  if (this.layer == 'obstacle') {
40
41
  this.isParallel = true
41
42
  } else if (this.layer == 'roof') {
@@ -235,6 +236,7 @@ export class Polygon {
235
236
  sameMargin: this.margins.sameMargin,
236
237
  distances: JSON.parse(JSON.stringify(this.margins.distances)),
237
238
  },
239
+ dataSource: this.dataSource,
238
240
  }
239
241
  const extraSerialization = {}
240
242
  if (this.layer == 'roof') {
@@ -291,6 +293,7 @@ export class Polygon {
291
293
  roof_orientation_degrees: this.direction,
292
294
  roof_name: this.name,
293
295
  shading_data: this.shadingData ? this.shadingData : undefined,
296
+ data_source: this.dataSource ? this.dataSource : null,
294
297
  }
295
298
  } else if (this.layer == 'obstacle') {
296
299
  const margins_obstacle_mm = this.margins.isSameMargin
@@ -6,6 +6,7 @@ export function hydratePolygon(serializedPolygon) {
6
6
  polygon.version = serializedPolygon.version
7
7
  polygon.name = serializedPolygon.name
8
8
  polygon.margins = serializedPolygon.margins
9
+ polygon.dataSource = serializedPolygon.dataSource
9
10
  if (layer == 'obstacle') {
10
11
  polygon.isParallel = serializedPolygon.isParallel
11
12
  polygon.height = serializedPolygon.height
@@ -111,6 +111,7 @@ export function splitPolygonsV2(polygons) {
111
111
  const outlines = getOutlineList(nodeList, edgeList, polygons)
112
112
  const newPolygons = []
113
113
  outlines.forEach(({ outline, hitPoint }) => {
114
+ let dataSource = null
114
115
  // check if outline has points that are intersections to determine if it is split/untouched
115
116
  const outlineIntersections = []
116
117
  let numberOfIntersectionPoints = 0
@@ -225,6 +226,8 @@ export function splitPolygonsV2(polygons) {
225
226
 
226
227
  // Preference for highest polygon average height as original polygon
227
228
  originalPolygon = originalPolygonCanditates[0]
229
+ // Persist polygon datasource of original polygon
230
+ dataSource = originalPolygon ? originalPolygon.dataSource : null
228
231
  }
229
232
 
230
233
  const normalVector = originalPolygon
@@ -247,12 +250,13 @@ export function splitPolygonsV2(polygons) {
247
250
 
248
251
  // check if there is an existing polygon with the same outline
249
252
  const polygon = polygons.find((polygon) =>
250
- polygonsHaveSame2DOutline(outline, polygon.outline)
253
+ polygonsHaveSame2DOutline(outline, polygon.outline, mmTolerance)
251
254
  )
252
255
  if (polygon && !constructionPolygons.includes(polygon)) {
253
256
  newPolygons.push(polygon)
254
257
  } else {
255
258
  const newPolygon = new Polygon(outline, 'roof')
259
+ newPolygon.dataSource = dataSource
256
260
  newPolygons.push(newPolygon)
257
261
  }
258
262
  })