@eturnity/eturnity_maths 7.48.2 → 7.51.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 +1 -1
- package/src/geometry.js +12 -12
- package/src/objects/Polygon.js +11 -7
- package/src/objects/hydrate.js +4 -2
package/package.json
CHANGED
package/src/geometry.js
CHANGED
|
@@ -848,19 +848,19 @@ export function groupAdjacentObjects(objects) {
|
|
|
848
848
|
if (visited.indexOf(currentObjectIndex) == -1) {
|
|
849
849
|
//if next queued index hasn't been visited, we mark it as visited and we collect all neighbourg to queue
|
|
850
850
|
visited.push(currentObjectIndex)
|
|
851
|
-
let x = objects[currentObjectIndex].
|
|
852
|
-
let y = objects[currentObjectIndex].
|
|
851
|
+
let x = objects[currentObjectIndex].row_index
|
|
852
|
+
let y = objects[currentObjectIndex].col_index
|
|
853
853
|
const left = objects.findIndex(
|
|
854
|
-
(o) => o.
|
|
854
|
+
(o) => o.row_index == x - 1 && o.col_index == y
|
|
855
855
|
)
|
|
856
856
|
const right = objects.findIndex(
|
|
857
|
-
(o) => o.
|
|
857
|
+
(o) => o.row_index == x + 1 && o.col_index == y
|
|
858
858
|
)
|
|
859
859
|
const top = objects.findIndex(
|
|
860
|
-
(o) => o.
|
|
860
|
+
(o) => o.row_index == x && o.col_index == y - 1
|
|
861
861
|
)
|
|
862
862
|
const bottom = objects.findIndex(
|
|
863
|
-
(o) => o.
|
|
863
|
+
(o) => o.row_index == x && o.col_index == y + 1
|
|
864
864
|
)
|
|
865
865
|
if (left != -1 && visited.indexOf(left) == -1) queue.push(left)
|
|
866
866
|
if (right != -1 && visited.indexOf(right) == -1) queue.push(right)
|
|
@@ -887,19 +887,19 @@ export function areAdjacent(objects) {
|
|
|
887
887
|
if (visited.indexOf(currentObjectIndex) == -1) {
|
|
888
888
|
//if next queued index hasn't been visited, we mark it as visited and we collect all neighbourg to queue
|
|
889
889
|
visited.push(currentObjectIndex)
|
|
890
|
-
let x = objects[currentObjectIndex].
|
|
891
|
-
let y = objects[currentObjectIndex].
|
|
890
|
+
let x = objects[currentObjectIndex].row_index
|
|
891
|
+
let y = objects[currentObjectIndex].col_index
|
|
892
892
|
const left = objects.findIndex(
|
|
893
|
-
(o) => o.
|
|
893
|
+
(o) => o.row_index == x - 1 && o.col_index == y
|
|
894
894
|
)
|
|
895
895
|
const right = objects.findIndex(
|
|
896
|
-
(o) => o.
|
|
896
|
+
(o) => o.row_index == x + 1 && o.col_index == y
|
|
897
897
|
)
|
|
898
898
|
const top = objects.findIndex(
|
|
899
|
-
(o) => o.
|
|
899
|
+
(o) => o.row_index == x && o.col_index == y - 1
|
|
900
900
|
)
|
|
901
901
|
const bottom = objects.findIndex(
|
|
902
|
-
(o) => o.
|
|
902
|
+
(o) => o.row_index == x && o.col_index == y + 1
|
|
903
903
|
)
|
|
904
904
|
if (left != -1 && visited.indexOf(left) == -1) queue.push(left)
|
|
905
905
|
if (right != -1 && visited.indexOf(right) == -1) queue.push(right)
|
package/src/objects/Polygon.js
CHANGED
|
@@ -38,8 +38,7 @@ export class Polygon {
|
|
|
38
38
|
this.angleOffset = 0
|
|
39
39
|
if (this.layer == 'obstacle') {
|
|
40
40
|
this.isParallel = true
|
|
41
|
-
}
|
|
42
|
-
if (this.layer == 'roof') {
|
|
41
|
+
} else if (this.layer == 'roof') {
|
|
43
42
|
this.moduleFields = []
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -244,7 +243,8 @@ export class Polygon {
|
|
|
244
243
|
this.panels.forEach((p) => {
|
|
245
244
|
modules.push({
|
|
246
245
|
id: p.id,
|
|
247
|
-
|
|
246
|
+
row_index: p.row_index,
|
|
247
|
+
col_index: p.col_index,
|
|
248
248
|
outline: p.outline,
|
|
249
249
|
status: p.status || 'active',
|
|
250
250
|
clipped: p.clipped || false,
|
|
@@ -255,7 +255,8 @@ export class Polygon {
|
|
|
255
255
|
this.userDeactivatedPanels.forEach((p) => {
|
|
256
256
|
modules.push({
|
|
257
257
|
id: p.id,
|
|
258
|
-
|
|
258
|
+
row_index: p.row_index,
|
|
259
|
+
col_index: p.col_index,
|
|
259
260
|
outline: p.outline,
|
|
260
261
|
status: p.status || 'user_deactivated',
|
|
261
262
|
clipped: p.clipped || false,
|
|
@@ -275,10 +276,12 @@ export class Polygon {
|
|
|
275
276
|
extraSerialization.needsOptimisation = this.needsOptimisation
|
|
276
277
|
extraSerialization.priority = this.priority
|
|
277
278
|
} else if (this.layer == 'panel') {
|
|
278
|
-
extraSerialization.
|
|
279
|
+
extraSerialization.row_index = this.row_index
|
|
280
|
+
extraSerialization.col_index = this.col_index
|
|
279
281
|
extraSerialization.moduleField = { id: this.moduleField.id }
|
|
280
282
|
} else if (this.layer == 'user_deactivated_panel') {
|
|
281
|
-
extraSerialization.
|
|
283
|
+
extraSerialization.row_index = this.row_index
|
|
284
|
+
extraSerialization.col_index = this.col_index
|
|
282
285
|
extraSerialization.moduleField = { id: this.moduleField.id }
|
|
283
286
|
}
|
|
284
287
|
return JSON.parse(
|
|
@@ -348,7 +351,8 @@ export class Polygon {
|
|
|
348
351
|
} else if (['panel', 'user_deactivated_panel'].includes(this.layer)) {
|
|
349
352
|
return {
|
|
350
353
|
id: this.id,
|
|
351
|
-
|
|
354
|
+
row_index: this.row_index,
|
|
355
|
+
col_index: this.col_index,
|
|
352
356
|
outline: this.outline.map((v) => [v.x, v.y, v.z]),
|
|
353
357
|
moduleField: {
|
|
354
358
|
id: this.moduleField.id,
|
package/src/objects/hydrate.js
CHANGED
|
@@ -16,10 +16,12 @@ export function hydratePolygon(serializedPolygon) {
|
|
|
16
16
|
polygon.panels = []
|
|
17
17
|
polygon.userDeactivatedPanels = []
|
|
18
18
|
} else if (layer == 'panel') {
|
|
19
|
-
polygon.
|
|
19
|
+
polygon.row_index = serializedPolygon.row_index
|
|
20
|
+
polygon.col_index = serializedPolygon.col_index
|
|
20
21
|
polygon.moduleField = serializedPolygon.moduleField
|
|
21
22
|
} else if (layer == 'user_deactivated_panel') {
|
|
22
|
-
polygon.
|
|
23
|
+
polygon.row_index = serializedPolygon.row_index
|
|
24
|
+
polygon.col_index = serializedPolygon.col_index
|
|
23
25
|
polygon.moduleField = serializedPolygon.moduleField
|
|
24
26
|
}
|
|
25
27
|
return polygon
|