[vtkusers] Updating and destroying the pipeline

Cyrille Faucheux cyrille.faucheux at etu.univ-tours.fr
Thu Jul 8 04:51:07 EDT 2010


Le 07/07/2010 20:09, Karthik Krishnan a écrit :
> On Wed, Jul 7, 2010 at 2:56 PM, Cyrille Faucheux 
> <cyrille.faucheux at etu.univ-tours.fr 
> <mailto:cyrille.faucheux at etu.univ-tours.fr>> wrote:
>
>
>     Creating and connecting all these objects seems to be the proper
>     way to build the pipeline in order to display an image, but
>     recreating and reconnecting everything seems wrong to me when I
>     want to open another image.
>
>     Can somebody confirm if it's the proper way or if there is
>     better/more efficient way to achieve this ?
>
>
> If you've set things up correctly, there should be no need to 
> reconnect everything again. The pipeline will ensure that an update of 
> the output (or render) will account for any changes in the input at 
> any stage of the pipeline.
Ok, so now I'm creating my vtkImageViewer and connecting it to my 
QVTKWidget once in the constructor of my class (which is connected to 
the GUI).

Then, in the method in charge of opening a new image, I still have to 
create my itk::ImageReader and my itk::ImageToVTKImageFilter, connect 
them and link it to the vtkImageViewer in order to get everything working.

I've tried several conbinations of creating and connecting the whole 
pipeline in my constructor and just calling the SetFilename method of my 
reader in the function in charge of opening a new image, but all I get 
is either an exception, a black window, or no change at all.

An example I have is ${VTK-5.4.2_SRC}\Examples\GUI\Qt\SimpleView, but it 
always load the same data, so maybe it hides some unwanted behaviours I 
want to avoid.

>
>
>     I've a second question concerning the proper way to destroy the
>     pipeline.
>     Right now, everything is automatically deleted since I use smart
>     pointers. But again, it seems wrong to me to let the application
>     decide about the order of deletion of these objects since they are
>     all connected.
>
>
> Why is this of concern ? You can always force smart pointers to go out 
> of scope by setting the smart pointer to NULL at any point.
>
For example, if a filter is destroyed before the renderer, will the 
renderer be in an "broken" state until it is deleted ?

>
>     Is it necessary to first "dismantle" the pipeline ?
>
>
> I'm not sure what you understand by "dismantle" a pipeline. If you 
> mean disconnect a data-object from the pipeline, its done in VTK via a 
> shallow copy. For instance :
>
>   vtkPolyData *disconnectedPoly = vtkPolyData::New(0;
>   filter->Update() ;
>   disconnectedPoly->ShallowCopy(filter->GetOutput());
>
Yes, that's what I meant.
But not in order to get a disconnected copy, in order to leave the 
pipeline in a "static" state.

> Similarly in ITK, you would use the method "DisconnectPipeline" on an 
> itk::DataObject. For instance :
>
>   filter->Update();
>   itk::DataObject::Pointer dataObject = filter->GetOutput();
>   dataObject->DisconnectPipeline();
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100708/1102bb9d/attachment.htm>


More information about the vtkusers mailing list