[vtkusers] Clipping problem (?) trying to use vtkCubeSource as selection marker
Elvis Stansvik
elvis.stansvik at orexplore.com
Wed Sep 14 08:50:06 EDT 2016
Hi all,
I'm rendering a cylindrical volume and need to let the user select a
segment of the volume.
As a "selection marker" I thought I'd, for simplicity, just use a
semi-transparent cube with "no shading" which I put around the segment
of the volume to indicate the selection:
vtkSmartPointer<vtkCubeSource> m_selectionMarker;
which I then configure with:
auto selectionMarkerMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
selectionMarkerMapper->SetInputConnection(m_selectionMarker->GetOutputPort());
auto selectionMarkerActor = vtkSmartPointer<vtkActor>::New();
selectionMarkerActor->SetMapper(selectionMarkerMapper);
selectionMarkerActor->GetProperty()->SetColor(0.0, 0.0, 1.0);
selectionMarkerActor->GetProperty()->SetOpacity(0.1);
selectionMarkerActor->GetProperty()->SetAmbient(1.0);
selectionMarkerActor->GetProperty()->SetDiffuse(0.0);
selectionMarkerActor->GetProperty()->SetSpecular(0.0);
renderer()->AddActor(selectionMarkerActor);
Now, my interactor style is such that the camera is locked to move on
a cylinder around my subject volume, and the camera is always uses
parallel projection.
When the camera is modified (zoomed or panned "around" my subject), I
do something like this to update the selection marker cube source:
int *windowSize = GetRenderWindow()->GetSize();
// Half window width in world coordinates
auto halfWindowWidth = renderer()->GetActiveCamera()->GetParallelScale()
* (double(windowSize[0]) / windowSize[1]);
m_selectionMarker->SetBounds(
-halfWindowWidth, halfWindowWidth,
-halfWindowWidth, halfWindowWidth,
start,
end
);
where start and end are the start/end of the selection.
This seems to work fine, and the selection has the look I'm after (see
looks_fine.png).
But, if I zoom out quite a bit, I get a strange look (see looks_strange.png).
Anyone know what is happening here? Is the cube clipped perhaps? Each
time the camera moves or is zoomed, I also reset the camera clipping
range with
renderer->ResetCameraClippingRange()
So I wouldn't expect the cube to be clipped...
Thanks for any advice.
Elvis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: looks_fine.png
Type: image/png
Size: 39912 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160914/c9c8106c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: looks_strange.png
Type: image/png
Size: 3819 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160914/c9c8106c/attachment-0001.png>
More information about the vtkusers
mailing list