[vtkusers] Does the order of using Delete() matter

Weiguang Guan weiguang at schrodinger.com
Wed Nov 21 14:16:32 EST 2001


Hi all,

I have a volume go through vtkContourFilter then get suface data back.
Core dump happens when using Delete() to free resources. Does 
anyone know what causes it. Here is the code segment:
        .........
        vtkStructuredPoints *vtk_str_pnt;
        vtk_str_pnt= vtkStructuredPoints::New();

        vtk_str_pnt->SetOrigin((float)origin[0], (float)origin[1], 
                               (float)origin[2]);
        vtk_str_pnt->SetDimensions(dimensions);
        vtk_str_pnt->SetSpacing((float)spacings[0], (float)spacings[1],
                                (float)origin[2]);
        vtkScalars *scalars;
        scalars= vtkScalars::New();
        vtk_str_pnt->GetPointData()->SetScalars(scalars);
        scalars->SetDataTypeToChar();

        // feed data in
        scalars->Allocate(dimensions[0]*dimensions[1]*dimensions[2]);
        for (i= 0; i< dimensions[0]*dimensions[1]*dimensions[2]; i++) {
            s= *(((char*) buf) + i);
            scalars->InsertScalar(i, s);
        }

        vtkContourFilter *iso_gen;
        iso_gen= vtkContourFilter::New();
        iso_gen->SetInput(vtk_str_pnt);
        iso_gen->SetValue(0, iso_value);       
        iso_gen->Update();

        vtkPolyData *iso;
        iso= iso_gen->GetOutput();      /* Surface data is in iso */

        vtkCellArray *polys;
        polys= iso->GetPolys();
        vtkPoints *points;
        points= iso->GetPoints();
	..........

        scalars->Delete(); 
        vtk_str_pnt->Delete();
        iso_gen->Delete();
        points->Delete();
        polys->Delete();
        iso->Delete();

Weiguang

--
Weiguang Guan, Schrodinger Inc | Email: weiguang at schrodinger.com
Tel: 503-299-1150 ext. 128 (O) 




More information about the vtkusers mailing list