[vtkusers] Strange problem with the positioning of rendered actors
Sonca Teng
ryteng at gmail.com
Fri Oct 12 19:39:03 EDT 2007
Hi all,
I've come across a strange issue. I've been adding actors to the renderer in
order to display some overlays in the windows, and initially they look fine,
but when I scroll through the slices and compare the transaxial, coronal,
and sagittal views, it is apparent that there are discrepencies between the
views.
For example, in a test case, I added a single dot (vertex) to the rendered
image at world coordinates (50,50,50).
If I add the actor by "this->RenderWidget->AddViewProp(actor);"
or
"this->RenderWidget->GetRenderer()->AddActor(actor);"
then,
In the transaxial view, I will see this dot from all of slices 0-49, at XY
coordinates (50, 50).
In the coronal view, I will see the dot from all of slices 51-127, at XZ
coordinates (50, 50).
In the sagittal view, I will see the dot from all of slices 0-49, at YZ
coordinates (50, 50).
(strange, every slice EXCEPT the correct one!)
If I add the actor by "this->RenderWidget->AddOverlayViewProp(actor);"
or
"this->RenderWidget->GetOverlayRenderer()->AddActor(actor);"
then,
In the transaxial view, I will see this dot from all of slices 48-54, at XY
coordinates (50, 50).
In the coronal view, I will see the dot from all of slices 46-53, at XZ
coordinates (50, 50).
In the sagittal view, I will see the dot from all of slices 47-56, at YZ
coordinates (50, 50).
If I add the actor by
"this->ImageViewer->GetRenderer()->AddActor(actor);"
then
In the transaxial view, I will see this dot from all of slices 0-49, at XY
coordinates (50, 50).
In the coronal view, I will see the dot from all of slices 51-127, at XZ
coordinates (50, 50).
In the sagittal view, I will see the dot from all of slices 0-49, at YZ
coordinates (50, 50).
So it seems that the views being represented on the XY, XZ, and YZ planes
are fine, but they are showing up on the wrong slices, and on multiple
slices.
Note that when adding actors to the overlay renderer, the results are very
different than when adding to normal renderers. It seems strange to me,
because both are derived from the vtkRenderer class, are they not?
The following is my code that generates the actor and adds it to the
renderer.
vtkPoints *points = vtkPoints::New();
vtkCellArray *cellArray = vtkCellArray::New();
cellArray->InsertNextCell(1);
points->InsertPoint(0, 50, 50, 50);
cellArray->InsertCellPoint(0);
vtkPolyData *polyData = vtkPolyData::New();
polyData->SetPoints(points);
polyData->SetVerts(cellArray);
vtkPolyDataMapper *polyDataMapper = vtkPolyDataMapper::New();
polyDataMapper->SetInput(polyData);
vtkActor *actor = vtkActor::New();
actor->SetMapper(polyDataMapper);
actor->GetProperty()->SetColor(0,0,0);
actor->GetProperty()->SetPointSize(2);
// this->RenderWidget->AddViewProp(actor)
// this->RenderWidget->GetRenderer()->AddActor(actor);
// this->RenderWidget->AddOverlayViewProp(actor);
// this->RenderWidget->GetOverlayRenderer()->AddActor(actor);
this->ImageViewer->GetRenderer()->AddActor(actor);
this->ImageViewer->Modified();
this->ImageViewer->Render();
this->RenderWidget->Render();
...
...::SliceChangerCallback(...)
this->ImageViewer->SetSlice((int)value);
this->RecentlyModified = 1;
I could really use some guidance on how to figure this out. I'm out of
ideas.
Any suggestions at all would be very welcome.
Thanks very much,
Sonca Teng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071012/a0095c00/attachment.htm>
More information about the vtkusers
mailing list