[vtkusers] No vectors in input data after ShallowCopy
Werner Sembach
werner at sembach.de
Fri Oct 30 10:46:06 EDT 2015
Ok it makes even less sense to me now:
For testingpupose i have changed:
void MainWindow::updateImage(vtkSmartPointer<vtkImageData> newImage) {
image->ShallowCopy(newImage);
image->Modified();
qvtkWidget->GetRenderWindow()->Render();
}
too
void MainWindow::updateImage(vtkSmartPointer<vtkImageData> newImage) {
image->ShallowCopy(newImage);
initializeImage2()
qvtkWidget->GetRenderWindow()->Render();
}
where inizializeImage2 prints a different picture than the first
inizialization.
And this works, but when i do this:
void MainWindow::updateImage(vtkSmartPointer<vtkImageData> newImage) {
image = newImage;
initializeImage2()
qvtkWidget->GetRenderWindow()->Render();
}
nothing in the output changes at all.
this doesn't make sense to me anymore. What am i missing guys? pls help
void MainWindow::initializeImage2()
{
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.0;
pixel[1] = 1.0;
pixel[2] = 0.0;
}
}
image->GetPointData()->SetVectors(image->GetPointData()->GetArray(0));
//image->GetPointData()->SetActiveVectors("ImageScalars");
image->Modified();
}
Am 28.10.2015 um 16:03 schrieb Werner Sembach:
> 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
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151030/07bcc198/attachment.html>
More information about the vtkusers
mailing list