[vtkusers] A Problem with vtkAbstractVolumeMapper and vtkMapper
Matthias Keil
matthias.keil at igd.fhg.de
Thu Sep 2 04:05:07 EDT 2004
Hello all!
Yesterday I encountered a problem using the vtkRenderer with two vtkActors. I want to display two image datasets with the one vtkRenderer. In order to display both datasets I would like to translate one of them. For this task I will need an vtkActor. While the program is running I have both Datasets shown by two different vtkRenderers. The Datasets are stored in the vtkAbstractVolumeMapper of the corresponding vtkVolume for rendering. So here for a better understanding:
1. Dataset: vtkRenderer -> vtkVolume -> vtkAbstractVolumeMapper -> Image Dataset
2. Dataset: vtkRenderer -> vtkVolume -> vtkAbstractVolumeMapper -> Image Dataset
My problem is now, that I would like to render both datasets with the second vtkRenderer and to translate the second dataset before the rendering.
So the idea was to use two vtkActors in the second vtkRenderer. I thought that it would be possible to use the mapper of the first vtkRenderer as the mapper for the vtkActors in the second vtkRenderer. But there is a problem with the class hierarchy in vtk version 4.4.
When I use myMapper = vtkVolume->GetMapper() it returns an vtkAbstractVolumeMapper, which includes my image dataset.
Now I have my mapper.
If I am trying to add this mapper to the vtkActor of the second vtkRenderer with vtkActor->SetMapper(myMapper) I will get an error message. This is because vtkActor->SetMapper() expects a vtkMapper and not a vtkAbstractVolumeMapper.
The problem is now that it is not possible to cast the vtkAbstractVolumeMapper to a vtkMapper.
My qestion is now: Is there anybody who might help me solving this problem? I think this situation might come up quite often.
So any help would be appreciated!
Thanks a lot, Matthias
Heres some code, maybe it helps understanding my problem:
vtkRenderer *myRenderer1 = vtkRenderer::New();
vtkRenderer *myRenderer2 = vtkRenderer::New();
vtkVolume *testvol;
vtkAbstractVolumeMapper *testmap;
vtkActor *testact = vtkActor::New();
vtkActor *testact2 = vtkActor::New();
testvol = myRenderer1->GetVolumes()->GetNextVolume();
testmap = testvol->GetMapper();
if (testmap != NULL)
{
testact->RotateX(-90);
testact->SetMapper(testmap); // error because vtkMapper is expected and vtkAbstractVolumeMapper is set
myRenderer2->AddActor(testact);
myRenderer2->AddActor(testact2);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040902/02150438/attachment.htm>
More information about the vtkusers
mailing list