@eturnity/eturnity_maths 9.13.0 → 9.19.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,15 +1,9 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "9.13.0",
3
+ "version": "9.19.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
7
- "scripts": {
8
- "test": "jest",
9
- "prepare": "husky",
10
- "lint": "eslint --fix --debug --ext .js,.vue .",
11
- "merge-remote-master": "node scripts/merge-master.js"
12
- },
13
7
  "repository": {
14
8
  "type": "git",
15
9
  "url": "git+ssh://git@bitbucket.org/eturnitydevs/eturnity_maths.git"
@@ -43,5 +37,10 @@
43
37
  "prettier": "^2.8.4",
44
38
  "prettier-plugin-vue": "^1.1.6"
45
39
  },
46
- "description": ""
47
- }
40
+ "description": "",
41
+ "scripts": {
42
+ "test": "jest",
43
+ "lint": "eslint --fix --debug --ext .js,.vue .",
44
+ "merge-remote-master": "node scripts/merge-master.js"
45
+ }
46
+ }
@@ -404,6 +404,7 @@ export class Polygon {
404
404
  } else if (this.layer == 'roof_plan_item') {
405
405
  extraSerialization.colorIndex = this.colorIndex
406
406
  extraSerialization.hasFillColor = this.hasFillColor
407
+ extraSerialization.isClosed = this.isClosed
407
408
  }
408
409
  return JSON.parse(
409
410
  JSON.stringify({ ...baseSerialization, ...extraSerialization })
@@ -78,7 +78,11 @@ export function updateComputedGeometryPolygon(polygon) {
78
78
  return polygon
79
79
  }
80
80
  let newOutline = [...polygon.outline]
81
+ const isOpenRoofPlanItem =
82
+ polygon.layer === 'roof_plan_item' && polygon.isClosed === false
83
+
81
84
  if (
85
+ !isOpenRoofPlanItem &&
82
86
  newOutline.length > 0 &&
83
87
  isAlmostSamePoint2D(newOutline[0], newOutline[newOutline.length - 1], 10)
84
88
  ) {
@@ -90,6 +94,15 @@ export function updateComputedGeometryPolygon(polygon) {
90
94
  }
91
95
  newOutline = calculateValidOutlineFromPolygon(newOutline)
92
96
 
97
+ if (isOpenRoofPlanItem) {
98
+ if (newOutline.length < 2) {
99
+ throw new Error('outline not valid')
100
+ }
101
+ if (newOutline.length < 3) {
102
+ return updateComputedGeometryOpenRoofPlanItemPolygon(polygon, newOutline)
103
+ }
104
+ }
105
+
93
106
  if (newOutline.length < 3) {
94
107
  throw new Error('outline not valid')
95
108
  }
@@ -124,6 +137,9 @@ export function updateComputedGeometryPolygon(polygon) {
124
137
  polygon.direction = direction
125
138
  polygon.area = calculateArea(polygon.flatOutline) / 1000000
126
139
  polygon.isClockwise = isClockWise(polygon.outline)
140
+ if (polygon.layer === 'roof_plan_item' && polygon.isClosed === false) {
141
+ polygon.isClockwise = false
142
+ }
127
143
  polygon = updateMarginOutlinePolygon(polygon)
128
144
  if (polygon.layer == 'moduleField') {
129
145
  let trimedOutline = []
@@ -150,6 +166,27 @@ export function updateComputedGeometryPolygon(polygon) {
150
166
  }
151
167
  return polygon
152
168
  }
169
+
170
+ function updateComputedGeometryOpenRoofPlanItemPolygon(polygon, newOutline) {
171
+ polygon.outline = newOutline
172
+ const normalVector = { x: 0, y: 0, z: 1 }
173
+ const meanPoint = meanVector(newOutline)
174
+ polygon.flatOutline = newOutline.map((p) => ({
175
+ x: p.x,
176
+ y: p.y,
177
+ z: Math.max(0, Math.min(50000, p.z)),
178
+ }))
179
+ polygon.maximumGap = 0
180
+ polygon.isFlat = true
181
+ polygon.normalVector = normalVector
182
+ polygon.meanPoint = meanPoint
183
+ polygon.incline = inclineWithNormalVector(normalVector)
184
+ polygon.direction = directionWithNormalVector(normalVector)
185
+ polygon.area = 0
186
+ polygon.isClockwise = false
187
+ return updateMarginOutlinePolygon(polygon)
188
+ }
189
+
153
190
  export function calculateValidOutlineFromPolygon(outline) {
154
191
  //check if two nodes are same
155
192
  outline = [...outline]
@@ -49,6 +49,9 @@ export function hydratePolygon(serializedPolygon) {
49
49
  polygon.shape = 'polygon'
50
50
  polygon.colorIndex = serializedPolygon.colorIndex
51
51
  polygon.hasFillColor = serializedPolygon.hasFillColor
52
+ if (serializedPolygon.isClosed === false) {
53
+ polygon.isClosed = false
54
+ }
52
55
  }
53
56
  updateComputedGeometryPolygon(polygon)
54
57
  return polygon