Skip to content

Commit afdf1cd

Browse files
finetjulfloryst
authored andcommitted
fix(stlreader): fix infinite update loop due to incorrect MTime
Slightly speedup removeDuplicateVertices by avoiding unnecessary array copy
1 parent 572238a commit afdf1cd

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Sources/IO/Geometry/STLReader/index.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,31 +152,31 @@ function vtkSTLReader(publicAPI, model) {
152152
}
153153
}
154154

155-
const outVerts = new Float32Array(vMap.size * 3);
156-
const keys = Array.from(vMap.keys());
157-
158-
for (let i = 0; i < keys.length; i++) {
159-
const k = keys[i];
160-
const j = vMap.get(k) * 3;
161-
const coords = k.split(',').map((e) => +e * 10 ** -tolerance);
162-
outVerts[j] = coords[0];
163-
outVerts[j + 1] = coords[1];
164-
outVerts[j + 2] = coords[2];
165-
}
155+
if (pointsChanged) {
156+
const outVerts = new Float32Array(vMap.size * 3);
157+
const keys = Array.from(vMap.keys());
158+
159+
for (let i = 0; i < keys.length; i++) {
160+
const k = keys[i];
161+
const j = vMap.get(k) * 3;
162+
const coords = k.split(',').map((e) => +e * 10 ** -tolerance);
163+
outVerts[j] = coords[0];
164+
outVerts[j + 1] = coords[1];
165+
outVerts[j + 2] = coords[2];
166+
}
166167

167-
const outFaces = new Int32Array(faces);
168-
for (let i = 0; i < faces.length; i += 4) {
169-
outFaces[i] = 3;
170-
outFaces[i + 1] = vIndexMap.get(faces[i + 1]);
171-
outFaces[i + 2] = vIndexMap.get(faces[i + 2]);
172-
outFaces[i + 3] = vIndexMap.get(faces[i + 3]);
173-
}
168+
const outFaces = new Int32Array(faces.length);
169+
for (let i = 0; i < faces.length; i += 4) {
170+
outFaces[i] = 3;
171+
outFaces[i + 1] = vIndexMap.get(faces[i + 1]);
172+
outFaces[i + 2] = vIndexMap.get(faces[i + 2]);
173+
outFaces[i + 3] = vIndexMap.get(faces[i + 3]);
174+
}
174175

175-
polydata.getPoints().setData(outVerts);
176-
polydata.getPolys().setData(outFaces);
176+
polydata.getPoints().setData(outVerts);
177+
polydata.getPolys().setData(outFaces);
177178

178-
if (pointsChanged) {
179-
publicAPI.modified();
179+
polydata.modified();
180180
}
181181
}
182182

0 commit comments

Comments
 (0)