GetCenter for each single volume in vtkMultiVolume

Hello there!
I recently started playing with vtk and I am using vtkVolume to visualize medical images. I want to overlay two images (CT and MR) on top of each other and match them. I’m using vtkMultiVolume for this and I want to get the positions of the center of each volume. However, every time calling the volume->GetCenter() function returns a position of 0,0,0 which is false, similarly GetPosition(). Below is the code on how I create vtkMultiVolume and how I try to get the center position.

vtkGPUVolumeRayCastMapper* mapper = vtkGPUVolumeRayCastMapper::New();
mapper->SetInputConnection(0, firstFileData->getThreshold());
mapper->SetInputConnection(1, secondFileData->getThreshold());

vtkMultiVolume* mergedVolume = vtkMultiVolume::New();

vtkVolume* firstActor = vtkVolume::New();
vtkVolume* secondActor = vtkVolume::New();

mergedVolume->SetVolume(firstActor, 0);
mergedVolume->SetVolume(secondActor, 1);
vtkVolume* volume = mergedVolume->GetVolume(1);
double* center = volume->GetCenter(); // this always returns [0,0,0]

I will appreciate any advice. Thanks!

@wasp vtkMultiVolume is just intended as a wrapper class for rendering multiple overlapping vtkVolume objects. It doesn’t do anything with them other than provide a convenient way for the mapper to access each volume. To calculate the center of each volume, you’d have to use the individual volume instances. I guess, we could add the ability to query the global bbox center.

1 Like

I was able to calculate the volume center, but I was curious why this method doesn’t work.
Thank you for your reply!