<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
So i have a function that gehts a vtkImageData*<br>
and should replace another, already displayed, vtkImageData*<br>
<br>
void MainWindow::updateImage(vtkSmartPointer<vtkImageData>
newImage) {<br>
image->ShallowCopy(newImage);<br>
image->Modified();<br>
<br>
qvtkWidget->GetRenderWindow()->Render();<br>
}<br>
<br>
however when i try to run this i get the error "vtkHedgeHog
(0xa3fc80): No vectors in input data"<br>
<br>
if i use a standart assignment (image = newImage) the display
doesn't change at all<br>
<br>
<br>
<br>
initial image is created here (image is a instance variable):<br>
<br>
void MainWindow::initializeImage()<br>
{<br>
unsigned int dim = 20;<br>
<br>
image->SetDimensions(dim, dim, 1);<br>
image->SetSpacing(1.0, 1.0, 1.0);<br>
image->SetOrigin(0.0, 0.0, 0.0);<br>
<br>
image->AllocateScalars(VTK_DOUBLE,3);<br>
<br>
for(unsigned int x = 0; x < dim; x++)<br>
{<br>
for(unsigned int y = 0; y < dim; y++)<br>
{<br>
double* pixel =
static_cast<double*>(image->GetScalarPointer(x,y,0));<br>
pixel[0] = -1;<br>
pixel[1] = 1;<br>
pixel[2] = 0.0;<br>
}<br>
}<br>
image->GetPointData()->SetActiveVectors("ImageScalars");<br>
image->Modified();<br>
}<br>
<br>
the new image is generated here:<br>
<br>
void MainWindow::on_actionTest_Update_triggered()<br>
{<br>
vtkSmartPointer<vtkImageData> newImage =
vtkSmartPointer<vtkImageData>::New();<br>
unsigned int dim = 30;<br>
<br>
newImage->SetDimensions(dim, dim, 1);<br>
newImage->SetSpacing(1.0, 1.0, 1.0);<br>
newImage->SetOrigin(0.0, 0.0, 0.0);<br>
<br>
newImage->AllocateScalars(VTK_DOUBLE,3);<br>
<br>
for(unsigned int x = 0; x < dim; x++)<br>
{<br>
for(unsigned int y = 0; y < dim; y++)<br>
{<br>
double* pixel =
static_cast<double*>(newImage->GetScalarPointer(x,y,0));<br>
pixel[0] = 1;<br>
pixel[1] = 0.0;<br>
pixel[2] = 0.0;<br>
}<br>
}<br>
newImage->GetPointData()->SetActiveVectors("imageScalars");<br>
newImage->Modified();<br>
updateImage(newImage);<br>
}<br>
<br>
<meta name="qrichtext" content="1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
</body>
</html>