[vtkusers] No vectors in input data after ShallowCopy

Werner Sembach werner at sembach.de
Wed Oct 28 16:13:42 EDT 2015


The
newImage->GetPointData()->SetActiveVectors("imageScalars");
was copyed out of an example, and the initilazation didn't work without it.

Ok i tryed to replace it with
newImage->GetPointData()->SetVectors(newImage->GetPointData()->GetArray(0));
but it has still the same behavior and complains about "No Vectors in 
input" after i copyed it over.
Greetings
Matombo

Am 28.10.2015 um 16:29 schrieb Cory Quammen:
> Hi Werner,
>
> Consider this line.
>
> newImage->GetPointData()->SetActiveVectors("imageScalars");
>
> Where is an array named "imageScalars"? I don't see that anywhere in 
> the code, so whatever active vectors there might be in the image are 
> being unset by the call above.
>
> After you allocate the scalars, you can give them a name with 
> something like
>
> newImage->GetPointData()->GetArray(0)->SetName("imageScalars");
>
> Or you can skip naming the array and set the active vectors with
>
> newImage->GetPointData()->SetVectors(newImage->GetPointData()->GetArray(0));
>
> HTH,
> Cory
>
> On Wed, Oct 28, 2015 at 11:03 AM, Werner Sembach <werner at sembach.de 
> <mailto:werner at sembach.de>> wrote:
>
>     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);
>     }
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/opensource/opensource.html
>
>     Please keep messages on-topic and check the VTK FAQ at:
>     http://www.vtk.org/Wiki/VTK_FAQ
>
>     Search the list archives at: http://markmail.org/search/?q=vtkusers
>
>     Follow this link to subscribe/unsubscribe:
>     http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>
> -- 
> Cory Quammen
> R&D Engineer
> Kitware, Inc.

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


More information about the vtkusers mailing list