[vtkusers] What is the order of calling delete methods on a pipeline?

Peter F Bradshaw pfb at exadios.com
Tue May 10 20:26:35 EDT 2011


Hi Chasan;

I'm not clear what you want to keep. Which of the objects in the code
below do you need to keep?

On Sun, 8 May 2011, chasank wrote:

> Hi Peter,
>
> I have designed a class containing many vtk objects, that's why I do not
> want
> to release memory resources by scope. The other vtk objects have to live.
> I want to release only volume rendering pipeline on runtime. How can I do it
> safely?
> Thanks!
>
>
> Peter F Bradshaw wrote:
> >
> > Hi Chasan;
> >
> > If you wish to release the pipeline below why not encase it in its own
> > scope? If you are using vtkSmartPointer, which you are, then the
> > pipeline will be destroyed when it goes out of scope.
> >
> > On Sat, 7 May 2011, Chasan KIOUTSOUKMOUSTAFA wrote:
> >
> >> I have a volume rendering pipeline and I want to release all the memory
> >> resources of pipeline on runtime .
> >> How can I release memory resources of the pipeline safely?
> >> It seems the iren is the end of pipeline, if I call the iren->Delete(),
> >> will
> >> it delete recursively all of the pipeline?
> >> What is the solution ? Pipeline is below. Thanks for answers!!
> >>
> >>     renderer = vtkSmartPointer < vtkRenderer > :: New();
> >>     renderWindow = vtkSmartPointer < vtkWin32OpenGLRenderWindow > ::
> >> New();
> >>     renderWindow->AddRenderer(renderer);
> >>     renderWindow->SetSize(width, height);
> >>
> >>     iren = vtkSmartPointer < vtkWin32RenderWindowInteractor > :: New();
> >>     iren->SetRenderWindow(renderWindow);
> >>
> >>     volumeMapper =
> >> vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
> >>     volumeMapper->SetInputConnection(reader->GetOutputPort());
> >>     volumeMapper->SetBlendModeToComposite();
> >>
> >>     volumeColor = vtkSmartPointer<vtkColorTransferFunction>::New();
> >>     volumeColor->AddRGBPoint(0,    0.0, 0.0, 0.0);
> >>     volumeColor->AddRGBPoint(500,  1.0, 0.5, 0.3);
> >>     volumeColor->AddRGBPoint(1000, 1.0, 0.5, 0.3);
> >>     volumeColor->AddRGBPoint(1150, 1.0, 1.0, 0.9);
> >>
> >>     volumeScalarOpacity =  vtkSmartPointer<vtkPiecewiseFunction>::New();
> >>     volumeScalarOpacity->AddPoint(0,    0.00);
> >>     volumeScalarOpacity->AddPoint(500,  0.15);
> >>     volumeScalarOpacity->AddPoint(1000, 0.15);
> >>     volumeScalarOpacity->AddPoint(1150, 0.90);
> >>
> >>     volumeGradientOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
> >>     volumeGradientOpacity->AddPoint(0,   0.0);
> >>     volumeGradientOpacity->AddPoint(90,  0.5);
> >>     volumeGradientOpacity->AddPoint(100, 1.0);
> >>
> >>     volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
> >>     volumeProperty->SetColor(volumeColor);
> >>     volumeProperty->SetScalarOpacity(volumeScalarOpacity);
> >>     volumeProperty->SetGradientOpacity(volumeGradientOpacity);
> >>     volumeProperty->SetInterpolationTypeToLinear();
> >>     volumeProperty->ShadeOff();
> >>     volumeProperty->SetAmbient(0.4);
> >>     volumeProperty->SetDiffuse(0.6);
> >>     volumeProperty->SetSpecular(0.2);
> >>
> >>     LODProperty = vtkSmartPointer <vtkLODProp3D>::New();
> >>     int id = LODProperty->AddLOD(volumeMapper, volumeProperty, 0.0);
> >>     LODProperty->SetLODLevel(id, 0.0);
> >>
> >>     renderer->AddViewProp(LODProperty);
> >>     renderer->ResetCamera();
> >>     renderer->Render();
> >>
> >>     iren->Initialize();
> >>
> >
> > Cheers
> >
> > --
> > Peter F Bradshaw: http://www.exadios.com (public keys avaliable there).
> > Personal site: http://personal.exadios.com
> > "I love truth, and the way the government still uses it occasionally to
> >  keep us guessing." - Sam Kekovich.

Cheers

-- 
Peter F Bradshaw: http://www.exadios.com (public keys avaliable there).
Personal site: http://personal.exadios.com
"I love truth, and the way the government still uses it occasionally to
 keep us guessing." - Sam Kekovich.



More information about the vtkusers mailing list