Skip to content

Commit 8ecd009

Browse files
committed
fix(links): clear Cells and Links arrays when polydata is cleared
BuildLinks enforces building cells only if they do not exist. When clearing the polydata, cells and links must be cleared accordingly. Same when verts, lines, polys and strips arrays are changed fix #3361
1 parent 456f4dd commit 8ecd009

File tree

1 file changed

+8
-1
lines changed
  • Sources/Common/DataModel/PolyData

1 file changed

+8
-1
lines changed

Sources/Common/DataModel/PolyData/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ function vtkPolyData(publicAPI, model) {
3939
.replace(/\s+/g, '');
4040
}
4141

42+
function clearCells() {
43+
model.cells = undefined;
44+
model.links = undefined;
45+
}
46+
4247
// build empty cell arrays and set methods
4348
POLYDATA_FIELDS.forEach((type) => {
4449
publicAPI[`getNumberOf${camelize(type)}`] = () =>
@@ -48,6 +53,7 @@ function vtkPolyData(publicAPI, model) {
4853
} else {
4954
model[type] = vtk(model[type]);
5055
}
56+
model[`_on${camelize(type)}Changed`] = clearCells;
5157
});
5258

5359
publicAPI.getNumberOfCells = () =>
@@ -75,6 +81,7 @@ function vtkPolyData(publicAPI, model) {
7581
const superInitialize = publicAPI.initialize;
7682
publicAPI.initialize = () => {
7783
POLYDATA_FIELDS.forEach((type) => model[type]?.initialize());
84+
clearCells();
7885
return superInitialize();
7986
};
8087

@@ -180,7 +187,7 @@ function vtkPolyData(publicAPI, model) {
180187
* topologically complex queries.
181188
*/
182189
publicAPI.buildLinks = (initialSize = 0) => {
183-
if (model.cells === undefined) {
190+
if (model.cells == null) {
184191
publicAPI.buildCells();
185192
}
186193

0 commit comments

Comments
 (0)