[vtkusers] Replacing Image Data

Werner Sembach werner at sembach.de
Mon Oct 26 09:25:40 EDT 2015


I have a main object with a ImageData pointer which is also doing all 
the rendering stuff.
At some point i want to replace the vtk image data from wihting a method 
of another class.
So i have a setter method in my main class that gets a new image Data 
pointer that should replace the old one.
But it dosn't work, rendering give me a blackscreen and when i want 
tocall functions of the new image data i get a segfault.

(Pseudo)Code:
     vtkImageData* image;

     main{
         image = vtkImageData::New();
         //writing some example output in image
         //create Mapper, Actor and Render Window
         //connect all stuf together
         callTheOtherClassToDoSomeMath();
     }

     //called from the other class after individual computation steps 
are finished
     updateImage(vtkImageData* newImage) {
         image=newImage;
         //from here on functions like image->GetNumberOfScalars() give 
segfault
         image->Modifyed();
         renderWindow->Render();
     }


More information about the vtkusers mailing list