Hi there,
I’m working on a volume rendering task in a 3D dataset. Points in the dataset have already been clustered as individual objects, and my work is to visualize individual objects with different colors.
Since I need different colors, I tried to use the VTKLookUpTable. Unfortunately, the VTKVolumeMapper seems not provide SetLookUpTable() method so I turn to the vtkDiscretizableColorTransferFunction and try to make it work in the volumeproperty. However, the output is different with what I expect. Here’s what I did so far:
vtkNew<vtkDiscretizableColorTransferFunction> discreteColorTransferFunction2;
discreteColorTransferFunction2->SetColorSpaceToRGB();
discreteColorTransferFunction2->SetScaleToLinear();
discreteColorTransferFunction2->SetNanColor(0, 0, 0);
discreteColorTransferFunction2->SetAboveRangeColor(0, 0, 0);
discreteColorTransferFunction2->UseAboveRangeColorOn();
discreteColorTransferFunction2->SetBelowRangeColor(0, 0, 0);
discreteColorTransferFunction2->UseBelowRangeColorOn();
for(int colorIndex = 0; colorIndex<Num; colorIndex++){
discreteColorTransferFunction2->AddRGBPoint(colorIndex, colorIndex%256, colorIndex/256, 0);
}
discreteColorTransferFunction2->SetNumberOfValues(Num);
discreteColorTransferFunction2->SetNumberOfIndexedColors(Num);
discreteColorTransferFunction2->DiscretizeOn();
discreteColorTransferFunction2->IndexedLookupOn();
discreteColorTransferFunction2->Build();
vtkNew<vtkVolumeProperty> volumeProperty2;
volumeProperty2->SetColor(discreteColorTransferFunction2);
volumeProperty2->SetInterpolationTypeToLinear();
vtkNew<vtkVolume> volume2;
volume2->SetProperty(volumeProperty2);
The output figure only has solid colors instead of the expected gradient color. Can anyone give me some advice?
Thanks,