[vtkusers] stenciling problem-- is this code thread safe?
Mark Roden
mmroden at gmail.com
Fri Feb 11 12:00:48 EST 2011
Hi all,
This code does not have threads enabled in vtk 5.6.1 (the code is in Java):
vtkLinearExtrusionFilter extruder = new vtkLinearExtrusionFilter();
extruder.SetInput(data);
extruder.SetVector(0, 0, spacing[2]);
extruder.Update();
vtkPolyData extruderOutput = extruder.GetOutput();
vtkPolyDataToImageStencil pol2Stenc = new vtkPolyDataToImageStencil();
pol2Stenc.SetTolerance(0);
pol2Stenc.SetInput(extruderOutput);
pol2Stenc.SetInformationInput(binaryOrgan);
pol2Stenc.Update();
vtkImageStencilData pol2StencOutput = pol2Stenc.GetOutput();
// This is where the memory leak is!!!!
vtkImageStencil stencil = new vtkImageStencil();
stencil.SetInput(binaryOrgan);
stencil.ReverseStencilOn();
stencil.SetStencil(pol2StencOutput);
stencil.Update();
// We're doing this because of an email to Mark
// that says this will fix our memory issues
final vtkImageData stencilOutput = stencil.GetOutput();
final vtkImageData imageToKeep = new vtkImageData();
imageToKeep.DeepCopy(stencilOutput);
stencilOutput.Delete();
When I try to call this code from multiple threads (ie, to create the
stencils for multiple organs), Bad Things happen, as in, the data are
entirely corrupted. Is this code thread safe?
Mark
More information about the vtkusers
mailing list