Hi there, I have an issue with vtkvolumemapper.
void updateImage() {
vtkSmartVolumeMapper* mapper = nullptr;
int sampleRate = 1;
if (m_Volume) {
mapper = vtkSmartVolumeMapper::SafeDownCast(m_Volume->GetMapper());
}
if (mapper) {
double* bounds = m_ClippingBox->GetBounds();
vtkSmartPointer<vtkImageData> volumeImageData = ImageUtilities::ComputeSubsampledImage(m_Image, sampleRate);
// Part 1
mapper->RemoveAllInputs();
mapper->SetInputData(volumeImageData);
mapper->SetCroppingRegionPlanes(bounds);
mapper->SetCroppingRegionFlagsToSubVolume();
mapper->CroppingOn();
mapper->InteractiveAdjustSampleDistancesOff();
mapper->Update();
// end of part 1
// Part 2
vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
volumeMapper->SetInputData(volumeImageData);
volumeMapper->SetCroppingRegionPlanes(bounds);
volumeMapper->SetCroppingRegionFlagsToSubVolume();
volumeMapper->CroppingOn();
volumeMapper->InteractiveAdjustSampleDistancesOff();
m_Volume->SetMapper(volumeMapper);
// end of part 2
}
}
So, here, m_Volume is already hook up with the mapper. Part 1 is using the same mapper of the volume, but update the input data. Part 2 is creating a new mapper and reset it for the volume. And when I run the code, I only use one part and comment the other. The result is, part 2 works but part1 doesn’t.
Am I missing anything here?
Thank you!