Skip to content

Commit aa3138f

Browse files
committed
refactor(filters): factorize requestData() check for deletion
Check for deletion is now performed before calling requestData().
1 parent 42800b6 commit aa3138f

File tree

21 files changed

+21
-104
lines changed

21 files changed

+21
-104
lines changed

Sources/Filters/Sources/ArrowSource/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ function vtkArrowSource(publicAPI, model) {
1212
// Set our className
1313
model.classHierarchy.push('vtkArrowSource');
1414

15-
function requestData(inData, outData) {
16-
if (model.deleted) {
17-
return;
18-
}
19-
15+
publicAPI.requestData = (inData, outData) => {
2016
const cylinder = vtkCylinderSource.newInstance({ capping: true });
2117
cylinder.setResolution(model.shaftResolution);
2218
cylinder.setRadius(model.shaftRadius);
@@ -80,10 +76,7 @@ function vtkArrowSource(publicAPI, model) {
8076
// Update output
8177
outData[0] = append.getOutputData();
8278
}
83-
}
84-
85-
// Expose methods
86-
publicAPI.requestData = requestData;
79+
};
8780
}
8881

8982
// ----------------------------------------------------------------------------

Sources/Filters/Sources/CircleSource/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ function vtkCircleSource(publicAPI, model) {
1111
// Set our classname
1212
model.classHierarchy.push('vtkCircleSource');
1313

14-
function requestData(inData, outData) {
15-
if (model.deleted) {
16-
return;
17-
}
18-
14+
publicAPI.requestData = (inData, outData) => {
1915
const dataset = outData[0] || vtkPolyData.newInstance();
2016

2117
// Points
@@ -57,10 +53,7 @@ function vtkCircleSource(publicAPI, model) {
5753

5854
// Update output
5955
outData[0] = dataset;
60-
}
61-
62-
// Expose methods
63-
publicAPI.requestData = requestData;
56+
};
6457
}
6558

6659
// ----------------------------------------------------------------------------

Sources/Filters/Sources/ConcentricCylinderSource/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ function vtkConcentricCylinderSource(publicAPI, model) {
7272
publicAPI.getMaskLayer = (index) =>
7373
index === undefined ? model.mask : model.mask[index];
7474

75-
function requestData(inData, outData) {
76-
if (model.deleted || !model.radius.length) {
75+
publicAPI.requestData = (inData, outData) => {
76+
if (!model.radius.length) {
77+
macro.vtkErrorMacro('No radius defined');
7778
return;
7879
}
7980

@@ -391,10 +392,7 @@ function vtkConcentricCylinderSource(publicAPI, model) {
391392

392393
// Update output
393394
outData[0] = dataset;
394-
}
395-
396-
// Expose methods
397-
publicAPI.requestData = requestData;
395+
};
398396
}
399397

400398
// ----------------------------------------------------------------------------

Sources/Filters/Sources/ConeSource/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ function vtkConeSource(publicAPI, model) {
1010
// Set our className
1111
model.classHierarchy.push('vtkConeSource');
1212

13-
function requestData(inData, outData) {
14-
if (model.deleted) {
15-
return;
16-
}
17-
13+
publicAPI.requestData = (inData, outData) => {
1814
const angle = (2 * Math.PI) / model.resolution;
1915
const xbot = -model.height / 2.0;
2016
const numberOfPoints = model.resolution + 1;
@@ -72,10 +68,7 @@ function vtkConeSource(publicAPI, model) {
7268

7369
// Update output
7470
outData[0] = dataset;
75-
}
76-
77-
// Expose methods
78-
publicAPI.requestData = requestData;
71+
};
7972
}
8073

8174
// ----------------------------------------------------------------------------

Sources/Filters/Sources/CubeSource/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ function vtkCubeSource(publicAPI, model) {
3838
// Set our className
3939
model.classHierarchy.push('vtkCubeSource');
4040

41-
function requestData(inData, outData) {
42-
if (model.deleted) {
43-
return;
44-
}
45-
41+
publicAPI.requestData = (inData, outData) => {
4642
const polyData = outData[0] || vtkPolyData.newInstance();
4743
outData[0] = polyData;
4844

@@ -249,7 +245,7 @@ function vtkCubeSource(publicAPI, model) {
249245
polyData.getLines().initialize();
250246
}
251247
polyData.modified();
252-
}
248+
};
253249

254250
publicAPI.setBounds = (...bounds) => {
255251
let boundsArray = [];
@@ -275,9 +271,6 @@ function vtkCubeSource(publicAPI, model) {
275271
(boundsArray[4] + boundsArray[5]) / 2.0,
276272
]);
277273
};
278-
279-
// Expose methods
280-
publicAPI.requestData = requestData;
281274
}
282275

283276
// ----------------------------------------------------------------------------

Sources/Filters/Sources/Cursor3D/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ function vtkCursor3D(publicAPI, model) {
9494
};
9595

9696
publicAPI.requestData = (inData, outData) => {
97-
if (model.deleted) {
98-
return;
99-
}
10097
let numPts = 0;
10198
let numLines = 0;
10299
// Check bounding box and origin

Sources/Filters/Sources/CylinderSource/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ function vtkCylinderSource(publicAPI, model) {
1111
// Set our classname
1212
model.classHierarchy.push('vtkCylinderSource');
1313

14-
function requestData(inData, outData) {
15-
if (model.deleted) {
16-
return;
17-
}
18-
14+
publicAPI.requestData = (inData, outData) => {
1915
const angle = (2.0 * Math.PI) / model.resolution;
2016
let numberOfPoints = 2 * model.resolution;
2117
let numberOfPolys = 5 * model.resolution;
@@ -166,10 +162,7 @@ function vtkCylinderSource(publicAPI, model) {
166162

167163
// Update output
168164
outData[0] = dataset;
169-
}
170-
171-
// Expose methods
172-
publicAPI.requestData = requestData;
165+
};
173166
}
174167

175168
// ----------------------------------------------------------------------------

Sources/Filters/Sources/DiskSource/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ function vtkDiskSource(publicAPI, model) {
2525
pointType,
2626
} = model;
2727

28-
if (model.deleted) {
29-
return;
30-
}
31-
32-
let dataset = outData[0];
33-
3428
// Points
3529
const points = vtkPoints.newInstance({
3630
dataType: pointType,
@@ -114,7 +108,7 @@ function vtkDiskSource(publicAPI, model) {
114108
}
115109
polys.setData(cellData, cellCount, 1);
116110

117-
dataset = vtkPolyData.newInstance();
111+
const dataset = outData[0] || vtkPolyData.newInstance();
118112
dataset.setPoints(points);
119113
dataset.setPolys(polys);
120114

Sources/Filters/Sources/ImageGridSource/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ function vtkImageGridSource(publicAPI, model) {
1111
model.classHierarchy.push('vtkImageGridSource');
1212

1313
publicAPI.requestData = (inData, outData) => {
14-
if (model.deleted) {
15-
return;
16-
}
17-
1814
const state = {};
1915
const dataset = {
2016
type: 'vtkImageData',

Sources/Filters/Sources/LineSource/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ function vtkLineSource(publicAPI, model) {
1313
model.classHierarchy.push('vtkLineSource');
1414

1515
publicAPI.requestData = (inData, outData) => {
16-
if (model.deleted) {
17-
return;
18-
}
19-
2016
const dataset = outData[0];
2117

2218
// Check input

0 commit comments

Comments
 (0)