[vtkusers] Crash on deleting a vtkPolyDataConnectivityFilter
Jean-Marie Normand
normand at lina.univ-nantes.fr
Tue Nov 30 05:47:06 EST 2004
Hi all,
I'm using VTK4.2 under linux (Fedora Core 2) and Kdevelop 3.1.1. My
problem is that I encounter a segmentation fault each time I want to
delete a vtkPolyDataConnectivityFilter in my app.
This is the code that produces the seg fault
// Sampling the implicit function
vtkSampleFunction *implicitSampleFunction = vtkSampleFunction::New();
implicitSampleFunction->SetImplicitFunction(impFunc);
implicitSampleFunction->SetModelBounds(-10,10,-10,10,-10,10);
implicitSampleFunction->SetSampleDimensions(30,30,30);
implicitSampleFunction->ComputeNormalsOff();
// Creating a ContourFilter of the above Sample Function
vtkContourFilter *implicitContourFilter = vtkContourFilter::New();
implicitContourFilter->SetInput(implicitSampleFunction->GetOutput());
implicitContourFilter->SetValue(0,0.);
// cleaning up the result before sending it through a
vtkPolyDataConnectivityFilter
vtkCleanPolyData *implicitCleaned = vtkCleanPolyData::New();
implicitCleaned->SetInput( implicitContourFilter->GetOutput() );
implicitCleaned->SetTolerance(0.);
// Applying the vtkPolyDataConnectivityFilter
vtkPolyDataConnectivityFilter *implicitPDCF =
vtkPolyDataConnectivityFilter::New();
implicitPDCF->SetInput(implicitCleaned->GetOutput());
implicitPDCF->ScalarConnectivityOff();
// getting the number of connected components of the implicit function
(eventually 1)
implicitPDCF->SetExtractionModeToAllRegions();
implicitPDCF->Update();
int nb_connected_components =
implicitPDCF->GetNumberOfExtractedRegions();
// declaring temp variables
vtkPolyData *extractedPolyData = vtkPolyData::New();
implicitPDCF->SetExtractionModeToSpecifiedRegions();
// extracting all the regions in a loop
for(int i=0; i<nb_connected_components; i++)
{
// retrieving the ith region
implicitPDCF->AddSpecifiedRegion(i);
implicitPDCF->Update();
// copying it into a vtkPolyData*
extractedPolyData = implicitPDCF->GetOutput();
// retrieving the bounds of the implicit function
extractedPolyData->GetBounds(temp_bounds);
// retrieving the center of mass
extractedPolyData->GetCenter(temp_center);
}
// Deleting memory
implicitCleaned->Delete();
implicitContourFilter->Delete();
implicitSampleFunction->Delete();
extractedPolyData->Delete();
//implicitPDCF->Delete(); //<-- if I uncomment this line I get a
segfault.
The aim of the function is to retrieve the bounds and center of an
implicit function (putting them into temp_bounds and temp_center).
I'd like to know what kind of mistake I'm doing. Thanks in advance
Jim
More information about the vtkusers
mailing list