<br>Hello all,<br><br>I am a relatively new VTK user. I am attempting to visualize an array of floats by manually entering them into a vtkImageData class. I have made a test program, but it appears that all the values are being mapped to 255 (the highest intensity value). I see that in the vtkImageData there is a vtkDataSet which has a ScalarRange which has the max and min set to
1.0 and 0.0. Do I need to change this somehow to match my data? And if so, how would I go about it?<br><br>Any help would be greatly appreciated. I have attached my code up to right before rendering below.<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>