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

Weiguang Guan weiguang at schrodinger.com
Mon Nov 26 12:28:36 EST 2001


Hi Amy,

Thank you very much. I think this is the reason that caused the problem in
my code.

Weiguang

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

On Mon, 26 Nov 2001, Amy Henderson wrote:

> Don't call Delete for points, polys, or iso.  Since you did not create them 
> by calling New, don't call Delete on them either.
> 
> - Amy
> 
> At 11:16 AM 11/21/2001 -0800, Weiguang Guan wrote:
> >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)
> >
> >_______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at: 
> ><http://public.kitware.com/cgi-bin/vtkfaq>
> >Follow this link to subscribe/unsubscribe:
> >http://public.kitware.com/mailman/listinfo/vtkusers
> 




More information about the vtkusers mailing list