[vtkusers] ImageData Sets
Prashanth Udupa
prashanth.udupa at gmail.com
Sun Sep 16 09:42:11 EDT 2007
Hi,
I was creating a image source (subclass of vtkImageAlgorithm) which
conceptually looks something like this.
int vtkCustomImageSource::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector
)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the ouptut
vtkImageData *output =
vtkImageData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
output->SetDimensions(10, 10, 1);
output->SetNumberOfScalarComponents(1);
output->SetSpacing(1,1,1);
output->AllocateScalars();
vtkIdType index = 0;
for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
for(int k=0; k<1; k++)
{
double* point = output->GetPoint(index++);
double dist = sqrt( point[0]*point[0] + point[1]*point[1] +
point[2]*point[2] );
output->SetScalarComponentFromDouble(i, j, k, 0, dist);
}
}
}
return 1;
}
The custom image source is similar in concept to the code written above
(although not the same). But the above image source did not seem to work. I
connected vtkCustomImageSource to vtkDataSetMapper and expected to see a
colored box. But I saw absolotely no output.
Then I connected vtkCustomImageSource to a vtkOutlineFilter to see a outline
of the data set. The surprising thing is that I see cube ! As the width,
height and depth of the cube are equal.
I would be very thankful to anyone who can point out my mistake in the code.
Best Regards,
Prashanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070916/395febd4/attachment.htm>
More information about the vtkusers
mailing list