<br>Hello all,<br><br>I am a relatively new VTK user. I am attempting to
visualize an array of floats by displaying each of them as a cube with a gray-scale values spanning the range of the floats. I was thinking about trying to manually enter the data into a vtkImageData class which I have had success in working with before. However, I am having no luck with this, as it appears that
all the values are being mapped to 255 (the highest intensity value).<br><br>Any suggestions as to how I could proceed in this direction, or even suggestions of a different method to try would be extremely helpful. Links to documentation or examples would also help.
<br><br>I've attached my code below up through just before rendering.<br><br>Thanks!<br><br>Dave<br><br><span style="font-family: courier new,monospace;"> vtkImageData *realData = vtkImageData::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> //vtkFloatArray *scalars = vtkFloatArray::New();
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> int dim[3];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
dim[0] = 255;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dim[1] = 255;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
dim[2] = 255;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> float *temp;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> realData->SetDimensions(dim);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
realData->SetScalarTypeToFloat();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> realData->SetNumberOfScalarComponents(1);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> realData->AllocateScalars();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
float *ptr = (float *) realData->GetScalarPointer();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> for (int i = 0; i<255*255*255 ; i++)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> *ptr++ = i;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //scalars->Delete();</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">vtkFixedPointVolumeRayCastMapper *volumeMapper = vtkFixedPointVolumeRayCastMapper::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">volumeMapper->SetInput(realData);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> volumeProperty->IndependentComponentsOff();</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> volumeProperty->SetScalarOpacity(tfun);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkVolume *newvol = vtkVolume::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> newvol->SetMapper(volumeMapper);
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> newvol->SetProperty(volumeProperty);</span><br>