[vtkusers] No vectors in input data after ShallowCopy

Werner Sembach werner at sembach.de
Wed Oct 28 11:03:06 EDT 2015


So i have a function that gehts a vtkImageData*
and should replace another, already displayed, vtkImageData*

void MainWindow::updateImage(vtkSmartPointer<vtkImageData> newImage) {
     image->ShallowCopy(newImage);
     image->Modified();

     qvtkWidget->GetRenderWindow()->Render();
}

however when i try to run this i get the error "vtkHedgeHog (0xa3fc80): 
No vectors in input data"

if i use a standart assignment (image = newImage) the display doesn't 
change at all



initial image is created here (image is a instance variable):

void MainWindow::initializeImage()
{
     unsigned int dim = 20;

     image->SetDimensions(dim, dim, 1);
     image->SetSpacing(1.0, 1.0, 1.0);
     image->SetOrigin(0.0, 0.0, 0.0);

     image->AllocateScalars(VTK_DOUBLE,3);

     for(unsigned int x = 0; x < dim; x++)
     {
         for(unsigned int y = 0; y < dim; y++)
         {
             double* pixel = 
static_cast<double*>(image->GetScalarPointer(x,y,0));
             pixel[0] = -1;
             pixel[1] = 1;
             pixel[2] = 0.0;
         }
     }
     image->GetPointData()->SetActiveVectors("ImageScalars");
     image->Modified();
}

the new image is generated here:

void MainWindow::on_actionTest_Update_triggered()
{
     vtkSmartPointer<vtkImageData> newImage = 
vtkSmartPointer<vtkImageData>::New();
     unsigned int dim = 30;

     newImage->SetDimensions(dim, dim, 1);
     newImage->SetSpacing(1.0, 1.0, 1.0);
     newImage->SetOrigin(0.0, 0.0, 0.0);

     newImage->AllocateScalars(VTK_DOUBLE,3);

     for(unsigned int x = 0; x < dim; x++)
     {
         for(unsigned int y = 0; y < dim; y++)
         {
             double* pixel = 
static_cast<double*>(newImage->GetScalarPointer(x,y,0));
             pixel[0] = 1;
             pixel[1] = 0.0;
             pixel[2] = 0.0;
         }
     }
newImage->GetPointData()->SetActiveVectors("imageScalars");
     newImage->Modified();
     updateImage(newImage);
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151028/e8553af4/attachment.html>


More information about the vtkusers mailing list