landxml 0.5.0 → 0.5.2
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/CHANGELOG.md +12 -0
- package/dist/index.js +12 -1
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# landxml
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6cafe85: Bugfix parsing landxml's without extra triangulated faces
|
|
8
|
+
|
|
9
|
+
## 0.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2d30d02: Fix: Edge case generating contour lines that are shared between multiple faces
|
|
14
|
+
|
|
3
15
|
## 0.5.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -166,7 +166,7 @@ var parseXML = (xmlString) => __async(void 0, null, function* () {
|
|
|
166
166
|
}, []);
|
|
167
167
|
faces = surface.Definition.Faces.F.reduce((faceList, face) => {
|
|
168
168
|
const { attr, content } = face;
|
|
169
|
-
if (attr.i === "1")
|
|
169
|
+
if ((attr == null ? void 0 : attr.i) === "1")
|
|
170
170
|
return faceList;
|
|
171
171
|
const [a, b, c] = content.split(" ").map((v) => pointIdMap[v]);
|
|
172
172
|
if ([a, b, c].filter((v) => typeof v === "undefined").length > 0) {
|
|
@@ -218,15 +218,22 @@ var to_glb_default = toGlb;
|
|
|
218
218
|
|
|
219
219
|
// src/private/get-contours.ts
|
|
220
220
|
var contourLineOnFace = (face, z) => {
|
|
221
|
+
let vertsAtElevation = 0;
|
|
221
222
|
let line = [];
|
|
222
223
|
for (let i = 0; i < face.length; i++) {
|
|
223
224
|
let vertex1 = face[i];
|
|
224
225
|
let vertex2 = face[(i + 1) % face.length];
|
|
226
|
+
if (vertex1[2] === z)
|
|
227
|
+
vertsAtElevation++;
|
|
225
228
|
if ((vertex1[2] <= z && vertex2[2] >= z || vertex1[2] >= z && vertex2[2] <= z) && !Number.isNaN((z - vertex1[2]) / (vertex2[2] - vertex1[2]))) {
|
|
226
229
|
let t = (z - vertex1[2]) / (vertex2[2] - vertex1[2]);
|
|
227
230
|
line.push([vertex1[0] + t * (vertex2[0] - vertex1[0]), vertex1[1] + t * (vertex2[1] - vertex1[1])]);
|
|
228
231
|
}
|
|
229
232
|
}
|
|
233
|
+
if (vertsAtElevation >= 2 && face.map((f) => f[2]).reduce((a, b) => a + b) > z * face.length)
|
|
234
|
+
return void 0;
|
|
235
|
+
if (line.length === 2 && line[0][0] === line[1][0] && line[0][1] === line[1][1])
|
|
236
|
+
return void 0;
|
|
230
237
|
if (line.length > 2) {
|
|
231
238
|
line = [...new Set(line.map((v) => JSON.stringify(v)))].map((s) => JSON.parse(s));
|
|
232
239
|
}
|
|
@@ -338,6 +345,10 @@ var getContours = (data, interval = 2) => __async(void 0, null, function* () {
|
|
|
338
345
|
return prev;
|
|
339
346
|
}, []);
|
|
340
347
|
const polylinesAtElevationE = linesToPolyLines(linesAtElevationE);
|
|
348
|
+
if (e === 442) {
|
|
349
|
+
console.log("linesAtElevationE", JSON.stringify(linesAtElevationE));
|
|
350
|
+
console.log("polylinesAtElevationE", JSON.stringify(polylinesAtElevationE));
|
|
351
|
+
}
|
|
341
352
|
return {
|
|
342
353
|
elevation: e,
|
|
343
354
|
polylines: polylinesAtElevationE
|
package/dist/index.mjs
CHANGED
|
@@ -131,7 +131,7 @@ var parseXML = (xmlString) => __async(void 0, null, function* () {
|
|
|
131
131
|
}, []);
|
|
132
132
|
faces = surface.Definition.Faces.F.reduce((faceList, face) => {
|
|
133
133
|
const { attr, content } = face;
|
|
134
|
-
if (attr.i === "1")
|
|
134
|
+
if ((attr == null ? void 0 : attr.i) === "1")
|
|
135
135
|
return faceList;
|
|
136
136
|
const [a, b, c] = content.split(" ").map((v) => pointIdMap[v]);
|
|
137
137
|
if ([a, b, c].filter((v) => typeof v === "undefined").length > 0) {
|
|
@@ -183,15 +183,22 @@ var to_glb_default = toGlb;
|
|
|
183
183
|
|
|
184
184
|
// src/private/get-contours.ts
|
|
185
185
|
var contourLineOnFace = (face, z) => {
|
|
186
|
+
let vertsAtElevation = 0;
|
|
186
187
|
let line = [];
|
|
187
188
|
for (let i = 0; i < face.length; i++) {
|
|
188
189
|
let vertex1 = face[i];
|
|
189
190
|
let vertex2 = face[(i + 1) % face.length];
|
|
191
|
+
if (vertex1[2] === z)
|
|
192
|
+
vertsAtElevation++;
|
|
190
193
|
if ((vertex1[2] <= z && vertex2[2] >= z || vertex1[2] >= z && vertex2[2] <= z) && !Number.isNaN((z - vertex1[2]) / (vertex2[2] - vertex1[2]))) {
|
|
191
194
|
let t = (z - vertex1[2]) / (vertex2[2] - vertex1[2]);
|
|
192
195
|
line.push([vertex1[0] + t * (vertex2[0] - vertex1[0]), vertex1[1] + t * (vertex2[1] - vertex1[1])]);
|
|
193
196
|
}
|
|
194
197
|
}
|
|
198
|
+
if (vertsAtElevation >= 2 && face.map((f) => f[2]).reduce((a, b) => a + b) > z * face.length)
|
|
199
|
+
return void 0;
|
|
200
|
+
if (line.length === 2 && line[0][0] === line[1][0] && line[0][1] === line[1][1])
|
|
201
|
+
return void 0;
|
|
195
202
|
if (line.length > 2) {
|
|
196
203
|
line = [...new Set(line.map((v) => JSON.stringify(v)))].map((s) => JSON.parse(s));
|
|
197
204
|
}
|
|
@@ -303,6 +310,10 @@ var getContours = (data, interval = 2) => __async(void 0, null, function* () {
|
|
|
303
310
|
return prev;
|
|
304
311
|
}, []);
|
|
305
312
|
const polylinesAtElevationE = linesToPolyLines(linesAtElevationE);
|
|
313
|
+
if (e === 442) {
|
|
314
|
+
console.log("linesAtElevationE", JSON.stringify(linesAtElevationE));
|
|
315
|
+
console.log("polylinesAtElevationE", JSON.stringify(polylinesAtElevationE));
|
|
316
|
+
}
|
|
306
317
|
return {
|
|
307
318
|
elevation: e,
|
|
308
319
|
polylines: polylinesAtElevationE
|