I'm newbie at VTK and I'm trying to understand the basics.
Let's suppose that I need to display three dimensional structured data (vtkImageData) which has: nx = 10, ny = 10, nz = 10
where nx/ny/nz - number of points along each dimension. For each point (x,y,z) I have a value val(x,y,z)
. So the color of each node is defined by the val
.
As I know in C++ I would write:
int main(int argc, char *argv[])
{
// Create an image data
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
// Specify the size of the image data
int nx = 10;
int ny = 10;
int nz = 10;
imageData->SetDimensions(nx,ny,nz);
imageData->SetSpacing(1.0, 1.0, 1.0);
imageData->SetOrigin(0.0, 0.0, 0.0);
double val[1000];
for (int i = 0; i < 1000; i++){
data[i] = i;
}
// after that I need to set val-array as color for imageData object
return 0;
}
How to set val[1000]
array to imageData
so the color of each node to be defined by the val
?
P.S. I've seen some examples from VTK web site but still didn't solve the problem
Best regards,
kerim
int main(int argc, char *argv[])
{
// Create an image data
vtkNew<vtkImageData> imageData;
// Specify the size of the image data
int nx = 10;
int ny = 10;
int nz = 10;
imageData->SetDimensions(nx,ny,nz);
imageData->SetSpacing(1.0, 1.0, 1.0);
imageData->SetOrigin(0.0, 0.0, 0.0);
vtkNew<vtkDoubleArray> array;
array->SetName("Name");
double val[1000];
for (int i = 0; i < 1000; i++){
array->InsertNextValue(i);
}
image->GetPointData()->AddArray(array);
return 0;
}