@@ -95,6 +95,12 @@ vtkHyperTreeGridPlaneCutter::~vtkHyperTreeGridPlaneCutter()
95
95
this ->Cutter ->Delete ();
96
96
this ->Cutter = nullptr ;
97
97
}
98
+
99
+ if ( this ->SelectedCells )
100
+ {
101
+ this ->SelectedCells ->Delete ();
102
+ this ->SelectedCells = nullptr ;
103
+ }
98
104
}
99
105
100
106
// ----------------------------------------------------------------------------
@@ -197,10 +203,14 @@ int vtkHyperTreeGridPlaneCutter::ProcessTrees( vtkHyperTreeGrid* input,
197
203
}
198
204
199
205
// Retrieve input point data
200
- this ->InData = input->GetPointData ();
206
+ this ->InData = input->GetPointData ();
201
207
202
208
// Retrieve material mask
203
- this ->InMask = input->HasMask () ? input->GetMask () : 0 ;
209
+ this ->InMask = input->HasMask () ? input->GetMask () : nullptr ;
210
+
211
+ // Reset PolyData
212
+ this ->Points ->SetNumberOfPoints (0 );
213
+ this ->Cells ->SetNumberOfCells (0 );
204
214
205
215
// Compute cut on dual or primal input depending on specification
206
216
if ( this ->Dual )
@@ -210,11 +220,17 @@ int vtkHyperTreeGridPlaneCutter::ProcessTrees( vtkHyperTreeGrid* input,
210
220
this ->OutData ->CopyAllocate ( this ->InData );
211
221
212
222
// Storage for leaf indices
213
- this ->Leaves = vtkIdList::New ();
223
+ if (this ->Leaves == nullptr )
224
+ {
225
+ this ->Leaves = vtkIdList::New ();
226
+ }
214
227
this ->Leaves ->SetNumberOfIds ( 8 );
215
228
216
229
// Initialize storage for dual geometry
217
- this ->Centers = vtkPoints::New ();
230
+ if (this ->Centers == nullptr )
231
+ {
232
+ this ->Centers = vtkPoints::New ();
233
+ }
218
234
this ->Centers ->SetNumberOfPoints ( 8 );
219
235
220
236
// Convert plane parameters into normal/origin specification
@@ -234,15 +250,21 @@ int vtkHyperTreeGridPlaneCutter::ProcessTrees( vtkHyperTreeGrid* input,
234
250
plane->SetNormal ( this ->Plane [0 ], this ->Plane [1 ], this ->Plane [2 ] );
235
251
236
252
// Initialize plane cutter
237
- this ->Cutter = vtkCutter::New ();
253
+ if (this ->Cutter == nullptr )
254
+ {
255
+ this ->Cutter = vtkCutter::New ();
256
+ }
238
257
this ->Cutter ->GenerateTrianglesOff ();
239
258
this ->Cutter ->SetCutFunction ( plane );
240
259
241
260
// Clean up
242
261
plane->Delete ();
243
262
244
263
// Create storage to keep track of selected cells
245
- this ->SelectedCells = vtkBitArray::New ();
264
+ if (this ->SelectedCells == nullptr )
265
+ {
266
+ this ->SelectedCells = vtkBitArray::New ();
267
+ }
246
268
vtkIdType numCells = input->GetNumberOfVertices ();
247
269
this ->SelectedCells ->SetNumberOfTuples ( numCells );
248
270
for ( vtkIdType i = 0 ; i < numCells; ++ i )
@@ -277,6 +299,7 @@ int vtkHyperTreeGridPlaneCutter::ProcessTrees( vtkHyperTreeGrid* input,
277
299
278
300
// Clean up
279
301
this ->SelectedCells ->Delete ();
302
+ this ->SelectedCells = nullptr ;
280
303
} // if ( this->Dual )
281
304
else
282
305
{
@@ -309,8 +332,6 @@ int vtkHyperTreeGridPlaneCutter::ProcessTrees( vtkHyperTreeGrid* input,
309
332
cleaner->Update ();
310
333
output->ShallowCopy ( cleaner->GetOutput () );
311
334
output->Squeeze ();
312
-
313
- // Clean up
314
335
cleaner->Delete ();
315
336
return 1 ;
316
337
}
0 commit comments