[vtkusers] Clipping problem (?) trying to use vtkCubeSource as selection marker

Elvis Stansvik elvis.stansvik at orexplore.com
Wed Sep 14 09:27:18 EDT 2016


2016-09-14 14:50 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> 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...

Bah, so silly, parts of my selection marker were actually behind the
camera. Nevermind.

Elvis

>
> Thanks for any advice.
>
> Elvis


More information about the vtkusers mailing list