@eturnity/eturnity_3d 7.24.1 → 7.24.2-EPDM-10923.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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_3d",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "7.24.
|
|
4
|
+
"version": "7.24.2-EPDM-10923.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"prettier": "prettier --write \"**/*.{js,vue}\""
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@eturnity/eturnity_maths": "7.24.1",
|
|
18
|
+
"@eturnity/eturnity_maths": "7.24.1-EPDM-10923.0",
|
|
19
19
|
"@originjs/vite-plugin-commonjs": "1.0.3",
|
|
20
20
|
"core-js": "2.6.12",
|
|
21
21
|
"cors": "2.8.5",
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { Point, Line } from '@eturnity/eturnity_maths'
|
|
2
|
-
import { mmTolerance, mmTolerance3dNode } from '../config'
|
|
3
|
-
import {
|
|
4
|
-
isAlmostSamePoint3D,
|
|
5
|
-
isAlmostSameSegment2D,
|
|
6
|
-
isAlmostSameSegment3D,
|
|
7
|
-
isAlmostSamePoint2D,
|
|
8
|
-
verticalProjectionOnPlane
|
|
9
|
-
} from '@eturnity/eturnity_maths'
|
|
10
|
-
|
|
11
|
-
export function generateNodes2D(polygons) {
|
|
12
|
-
let nodes2D = []
|
|
13
|
-
polygons
|
|
14
|
-
.filter((poly) =>
|
|
15
|
-
[
|
|
16
|
-
'roof',
|
|
17
|
-
'obstacle',
|
|
18
|
-
'tmpModuleField',
|
|
19
|
-
'moduleField',
|
|
20
|
-
'construction'
|
|
21
|
-
].includes(poly.layer)
|
|
22
|
-
)
|
|
23
|
-
.forEach((polygon) => {
|
|
24
|
-
const outline = polygon.outline
|
|
25
|
-
outline.forEach((point, i) => {
|
|
26
|
-
//check if nodes2D already exist
|
|
27
|
-
let node2D = nodes2D.find(
|
|
28
|
-
(node) =>
|
|
29
|
-
isAlmostSamePoint2D(node, point, mmTolerance) &&
|
|
30
|
-
node.layer == polygon.layer
|
|
31
|
-
)
|
|
32
|
-
if (!node2D) {
|
|
33
|
-
node2D = new Point(point.x, point.y, point.z, polygon.layer)
|
|
34
|
-
node2D.belongsTo = []
|
|
35
|
-
node2D.id = 'node2D'
|
|
36
|
-
node2D.itemType = 'node2D'
|
|
37
|
-
node2D.layer = polygon.layer
|
|
38
|
-
node2D.masterHandle = {
|
|
39
|
-
id: node2D.id,
|
|
40
|
-
itemType: 'masterHandle',
|
|
41
|
-
open: null,
|
|
42
|
-
selected: null
|
|
43
|
-
}
|
|
44
|
-
nodes2D.push(node2D)
|
|
45
|
-
}
|
|
46
|
-
node2D.belongsTo.push({
|
|
47
|
-
polygonId: polygon.id,
|
|
48
|
-
index: i,
|
|
49
|
-
polygon
|
|
50
|
-
})
|
|
51
|
-
node2D.id += '_' + polygon.id + '_' + i
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
//all nodes has been created. now lets update open/selected field
|
|
56
|
-
nodes2D.forEach((node2D) => {
|
|
57
|
-
if (node2D.masterHandle) {
|
|
58
|
-
node2D.masterHandle.open = node2D.belongsTo.some(
|
|
59
|
-
(item) =>
|
|
60
|
-
item.index == null ||
|
|
61
|
-
item.polygon.outline[item.index].open ||
|
|
62
|
-
item.polygon.outline[item.index].hasWarning
|
|
63
|
-
)
|
|
64
|
-
node2D.masterHandle.hasWarning = node2D.belongsTo.some(
|
|
65
|
-
(item) =>
|
|
66
|
-
item.index == null || item.polygon.outline[item.index].hasWarning
|
|
67
|
-
)
|
|
68
|
-
node2D.masterHandle.selected = node2D.belongsTo.every(
|
|
69
|
-
(item) =>
|
|
70
|
-
item.index == null || item.polygon.outline[item.index].selected
|
|
71
|
-
)
|
|
72
|
-
node2D.masterHandle.locked = node2D.belongsTo.every(
|
|
73
|
-
(item) => item.index == null || item.polygon.outline[item.index].locked
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
return nodes2D
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function generateNodes3D(polygons) {
|
|
81
|
-
let nodes3D = []
|
|
82
|
-
polygons
|
|
83
|
-
.filter((poly) =>
|
|
84
|
-
['roof', 'obstacle', 'tmpModuleField', 'moduleField'].includes(poly.layer)
|
|
85
|
-
)
|
|
86
|
-
.forEach((polygon) => {
|
|
87
|
-
const outline = polygon.outline
|
|
88
|
-
outline.forEach((point, i) => {
|
|
89
|
-
//check if nodes2D already exist
|
|
90
|
-
let node3D = nodes3D.find((node) =>
|
|
91
|
-
isAlmostSamePoint3D(node, point, mmTolerance3dNode)
|
|
92
|
-
)
|
|
93
|
-
if (!node3D) {
|
|
94
|
-
node3D = new Point(point.x, point.y, point.z, polygon.layer)
|
|
95
|
-
node3D.belongsTo = []
|
|
96
|
-
node3D.id = 'node3D'
|
|
97
|
-
node3D.itemType = 'node3D'
|
|
98
|
-
node3D.layer = polygon.layer
|
|
99
|
-
node3D.masterHandle = {
|
|
100
|
-
id: node3D.id,
|
|
101
|
-
itemType: 'masterHandle',
|
|
102
|
-
open: null,
|
|
103
|
-
selected: null
|
|
104
|
-
}
|
|
105
|
-
nodes3D.push(node3D)
|
|
106
|
-
}
|
|
107
|
-
node3D.belongsTo.push({
|
|
108
|
-
polygonId: polygon.id,
|
|
109
|
-
index: i,
|
|
110
|
-
polygon
|
|
111
|
-
})
|
|
112
|
-
node3D.id += '_' + polygon.id + '_' + i
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
//all nodes has been created. now lets update open/selected field
|
|
116
|
-
nodes3D.forEach((node3D) => {
|
|
117
|
-
if (node3D.masterHandle) {
|
|
118
|
-
node3D.masterHandle.open = node3D.belongsTo.some(
|
|
119
|
-
(item) => item.polygon.outline[item.index].open
|
|
120
|
-
)
|
|
121
|
-
node3D.masterHandle.selected = node3D.belongsTo.every(
|
|
122
|
-
(item) => item.polygon.outline[item.index].selected
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
return nodes3D
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function generateEdges2D(polygons, splitEdgesIds = []) {
|
|
130
|
-
let edges2D = []
|
|
131
|
-
polygons
|
|
132
|
-
.filter((poly) =>
|
|
133
|
-
['roof', 'obstacle', 'moduleField', 'construction'].includes(poly.layer)
|
|
134
|
-
)
|
|
135
|
-
.forEach((polygon) => {
|
|
136
|
-
const outline = polygon.outline
|
|
137
|
-
outline.forEach((point, i) => {
|
|
138
|
-
const isLastPointOfPolygon = i == outline.length - 1
|
|
139
|
-
if (!polygon.isClosed && isLastPointOfPolygon) {
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
//check if edge2D already exist
|
|
143
|
-
const nextPoint = outline[(i + 1) % outline.length]
|
|
144
|
-
let edge2D = edges2D.find((edge) => {
|
|
145
|
-
return (
|
|
146
|
-
isAlmostSameSegment2D(
|
|
147
|
-
[point, nextPoint],
|
|
148
|
-
edge.outline,
|
|
149
|
-
mmTolerance
|
|
150
|
-
) && edge.layer == polygon.layer
|
|
151
|
-
)
|
|
152
|
-
})
|
|
153
|
-
if (!edge2D) {
|
|
154
|
-
//create an edge at this position
|
|
155
|
-
edge2D = new Line(point, nextPoint, polygon.layer)
|
|
156
|
-
edge2D.id = 'edge2D'
|
|
157
|
-
edge2D.belongsTo = []
|
|
158
|
-
edge2D.layer = polygon.layer
|
|
159
|
-
edge2D.selected = false
|
|
160
|
-
edge2D.itemType = 'edge2D'
|
|
161
|
-
edges2D.push(edge2D)
|
|
162
|
-
}
|
|
163
|
-
//add BelongToPolygon
|
|
164
|
-
edge2D.belongsTo.push({
|
|
165
|
-
polygonId: polygon.id,
|
|
166
|
-
index: i,
|
|
167
|
-
polygon
|
|
168
|
-
})
|
|
169
|
-
if (polygon.roofs && polygon.roofs.length > 0) {
|
|
170
|
-
polygon.roofs.forEach((supportRoof) => {
|
|
171
|
-
edge2D.belongsTo.push({
|
|
172
|
-
polygonId: supportRoof.id,
|
|
173
|
-
index: null,
|
|
174
|
-
polygon: supportRoof
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
}
|
|
178
|
-
edge2D.id += '_' + polygon.id + '_' + i
|
|
179
|
-
})
|
|
180
|
-
})
|
|
181
|
-
edges2D.forEach((edge2D) => {
|
|
182
|
-
edge2D.isSplit = splitEdgesIds.includes(edge2D.id)
|
|
183
|
-
if (edge2D.belongsTo.length > 2) {
|
|
184
|
-
edge2D.belongsTo = edge2D.belongsTo.filter((i) => i.index !== null)
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
edges2D.forEach((edge2D) => {
|
|
188
|
-
const isNotSplit = edge2D.belongsTo.every((item, index, array) => {
|
|
189
|
-
if (index == 0) {
|
|
190
|
-
return true
|
|
191
|
-
}
|
|
192
|
-
const outline0 = array[0].polygon.outline
|
|
193
|
-
const outline1 = item.polygon.outline
|
|
194
|
-
let point0, point1, nextPoint0, nextPoint1
|
|
195
|
-
let pointNull = []
|
|
196
|
-
if (array[0].index !== null) {
|
|
197
|
-
point0 = outline0[array[0].index]
|
|
198
|
-
nextPoint0 = outline0[(array[0].index + 1) % outline0.length]
|
|
199
|
-
} else {
|
|
200
|
-
pointNull.push(0)
|
|
201
|
-
point0 = verticalProjectionOnPlane(
|
|
202
|
-
outline1[item.index],
|
|
203
|
-
array[0].polygon.normalVector,
|
|
204
|
-
array[0].polygon.flatOutline[0]
|
|
205
|
-
)
|
|
206
|
-
nextPoint0 = verticalProjectionOnPlane(
|
|
207
|
-
outline1[(item.index + 1) % outline1.length],
|
|
208
|
-
array[0].polygon.normalVector,
|
|
209
|
-
array[0].polygon.flatOutline[0]
|
|
210
|
-
)
|
|
211
|
-
}
|
|
212
|
-
if (item.index !== null) {
|
|
213
|
-
point1 = outline1[item.index]
|
|
214
|
-
nextPoint1 = outline1[(item.index + 1) % outline1.length]
|
|
215
|
-
} else {
|
|
216
|
-
pointNull.push(1)
|
|
217
|
-
point1 = verticalProjectionOnPlane(
|
|
218
|
-
outline0[array[0].index],
|
|
219
|
-
item.polygon.normalVector,
|
|
220
|
-
item.polygon.flatOutline[0]
|
|
221
|
-
)
|
|
222
|
-
nextPoint1 = verticalProjectionOnPlane(
|
|
223
|
-
outline0[(array[0].index + 1) % outline0.length],
|
|
224
|
-
item.polygon.normalVector,
|
|
225
|
-
item.polygon.flatOutline[0]
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
const isSameSeg = isAlmostSameSegment3D(
|
|
229
|
-
[point0, nextPoint0],
|
|
230
|
-
[point1, nextPoint1],
|
|
231
|
-
mmTolerance
|
|
232
|
-
)
|
|
233
|
-
return isSameSeg
|
|
234
|
-
})
|
|
235
|
-
if (!isNotSplit && edge2D.belongsTo.length == 2 && edge2D.layer == 'roof') {
|
|
236
|
-
edge2D.isSplit = true
|
|
237
|
-
}
|
|
238
|
-
})
|
|
239
|
-
return edges2D
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function generateEdges3D(polygons) {
|
|
243
|
-
let edges3D = []
|
|
244
|
-
polygons
|
|
245
|
-
.filter((poly) =>
|
|
246
|
-
['roof', 'obstacle', 'moduleField', 'construction'].includes(poly.layer)
|
|
247
|
-
)
|
|
248
|
-
.forEach((polygon) => {
|
|
249
|
-
const outline = polygon.outline
|
|
250
|
-
outline.forEach((point, i) => {
|
|
251
|
-
const isLastPointOfPolygon = i == outline.length - 1
|
|
252
|
-
if (!polygon.isClosed && isLastPointOfPolygon) {
|
|
253
|
-
return
|
|
254
|
-
}
|
|
255
|
-
//check if edge2D already exist
|
|
256
|
-
const nextPoint = outline[(i + 1) % outline.length]
|
|
257
|
-
let edge3D = edges3D.find((edge) => {
|
|
258
|
-
return (
|
|
259
|
-
isAlmostSameSegment3D(
|
|
260
|
-
[point, nextPoint],
|
|
261
|
-
edge.outline,
|
|
262
|
-
mmTolerance
|
|
263
|
-
) && edge.layer == polygon.layer
|
|
264
|
-
)
|
|
265
|
-
})
|
|
266
|
-
if (!edge3D) {
|
|
267
|
-
//create an edge at this position
|
|
268
|
-
edge3D = new Line(point, nextPoint, polygon.layer)
|
|
269
|
-
edge3D.id = 'edge3D'
|
|
270
|
-
edge3D.belongsTo = []
|
|
271
|
-
edge3D.layer = polygon.layer
|
|
272
|
-
edge3D.selected = false
|
|
273
|
-
edge3D.itemType = 'edge3D'
|
|
274
|
-
edges3D.push(edge3D)
|
|
275
|
-
}
|
|
276
|
-
//add BelongToPolygon
|
|
277
|
-
edge3D.belongsTo.push({
|
|
278
|
-
polygonId: polygon.id,
|
|
279
|
-
index: i,
|
|
280
|
-
polygon
|
|
281
|
-
})
|
|
282
|
-
edge3D.id += '_' + polygon.id + '_' + i
|
|
283
|
-
})
|
|
284
|
-
})
|
|
285
|
-
return edges3D
|
|
286
|
-
}
|