[vtkusers] Viewport clipping

Doug Hoppes dhoppes at mbfbioscience.com
Wed Jun 29 11:02:55 EDT 2016

Sure… it’s a bit convoluted since it’s part of a larger program but I can give you some of the essentials:

Building the viewports (I have my own ViewPort class that is a wrapper around the vtkViewport code):

1)      In my situation, I have create 4 viewports using:
void Viewport::CreateViewPort()
              // A Viewport is composed of the renderer, camera, light, and interactor.
              m_pRenderer = new SceneRenderer(m_pSceneManager->GetRenderWindow());
              m_pCamera = new VTKCameras(m_pRenderer, m_pSceneManager);
              m_pLight = new VTKLights(m_pRenderer);

              // Create the scene item list.  This list is really only a list of the
              // items in the current viewport.  The main list is stored with the scene
              // manager.
              m_pSceneItems = new VTKSceneItemList(m_pSceneManager, false);

2)      I then set the position of the viewport in the VTK scene

m_iCurrentViewport = 0;
       m_arViews[0]->SetPosition(0.0, 0.667, 0.333, 1.0);

       m_iCurrentViewport = 1;
       m_arViews[1]->SetPosition(0.0, 0.334, 0.333, 0.665);

       m_iCurrentViewport = 2;
       m_arViews[2]->SetPosition(0.0, 0.0, 0.333, 0.332);

       m_iCurrentViewport = 3;
       m_arViews[3]->SetPosition(0.335, 0, 1.0, 1.0);

where SetPosition is a function in my Viewport class:

void Viewport::SetPosition(double dMinX, double dMinY, double dMaxX,
                           double dMaxY)
       // Tell the renderer where the viewport is located
       m_pRenderer->SetViewportPosition(dMinX, dMinY, dMaxX, dMaxY);

Once the viewport is created, I call

vtkSmartPointer<vtkImageActor> pHelpActor = m_pSceneItems->SetUserHelpItem(pImageData);
RefreshScene(true, true, true);

Where RefreshScene resets the cameras and the camera clipping ranges for all of the viewports:



From: Bill Lorensen [mailto:bill.lorensen at gmail.com]
Sent: Wednesday, June 29, 2016 10:50 AM
To: Doug Hoppes
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Viewport clipping

Can you post the code?

On Wed, Jun 29, 2016 at 10:39 AM, Doug Hoppes <dhoppes at mbfbioscience.com<mailto:dhoppes at mbfbioscience.com>> wrote:
Sorry about that…. Here’s more information…

In VTK Version 6.2.0 using the OpenGL flag, this is what we see in all 4 viewports, we see that the vtkimageactor looks fine.

[cid:image001.png at 01D1D1F4.EC2CF610]

However, we just moved to VTK Version 7.0.0 using the OpenGL2 flag.  This is what we now see:

[cid:image002.png at 01D1D1F4.EC2CF610]

Notice the clipping. The upper two viewports show nothing, the bottom viewport is correct and the rightmost viewport is clipped in the center of the viewport. If we resize the overall vtk window, the viewport is still clipped in the center.  It seems that there is no display to the right-side of the viewport.  In the main right viewport, we can actually move the objects around without a problem but the results are still clipped.

We have seen this issue with really large vtkvolumes but it doesn’t happen all of the time.  Using the vtkimageactor, this happens consistently.  This problem does not present itself with any generic vtkactors.

I’ll also check the vtkImageSliceMapper code to see if I can get any information from it.


From: David Gobbi [mailto:david.gobbi at gmail.com<mailto:david.gobbi at gmail.com>]
Sent: Wednesday, June 29, 2016 9:03 AM
To: Doug Hoppes
Subject: Re: [vtkusers] Viewport clipping

Hi Doug,

Please keep the discussion on the list.  It's possible that the near/far clipping planes are too tight.  When you reset the focal point, you can try calling SetClippingRange(near, far) at the same time.

Also, I hate to be redundant, but what version of VTK are you using? Do you see this only with vtkImageActor, or also with vtkVolume?  It helps me help you if you answer these questions...

 - David

On Wed, Jun 29, 2016 at 6:45 AM, Doug Hoppes <dhoppes at mbfbioscience.com<mailto:dhoppes at mbfbioscience.com>> wrote:
Hey  David!

                Thanks for responding.  Here’s what we are seeing:

I can move the image in the 3D area without any problem…. It’s just that the image is clipped.  We have seen it happen with a couple of large images and I noticed that it happens when I try to reset the camera focal point.

From: David Gobbi [mailto:david.gobbi at gmail.com<mailto:david.gobbi at gmail.com>]
Sent: Wednesday, June 29, 2016 8:25 AM
To: Doug Hoppes
Cc: vtkusers at vtk.org<mailto:vtkusers at vtk.org>
Subject: Re: [vtkusers] Viewport clipping

On Wed, Jun 29, 2016 at 6:10 AM, Doug Hoppes <dhoppes at mbfbioscience.com<mailto:dhoppes at mbfbioscience.com>> wrote:
Hey all,

                Running into a critical issue and not sure where to turn.  We’ve been using vtkViewport for a while and never seem to have an issue with them.  However, just updated the software and moved to OpenGL2 and now running into an issue.  Some of the viewports seem to be clipped.  I can move my objects without a problem in them but, in one case, vtkImageActor, the display is clipped.

                Is there a particular place I can look at in the code to see what is happening?  The vtkViewport code seems to have the correct port size.  Where is the display rendering done?  I’ve noticed that, if I use a sphere actor or any general surface actor, there doesn’t seem to be a problem.  It only happens when I’m rendering a volume or an image actor.

Hmm... I haven't seen anything like this.  By "clipped", do you mean that the actor/volume is limited to a rectangle that is smaller than the viewport?  Is this rectangle always in the upper left corner of the viewport, or is it somewhere else?  When you say "rendering a volume", do you mean rendered with a vtkVolume?  If so, what volume mapper was used?  What version of VTK?

For OpenGL2 the vtkImageActor rendering is done by Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx, which in turn uses vtkTexture and vtkPolyDataMapper.

 - David

Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:

Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160629/f78bb948/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 28972 bytes
Desc: image001.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160629/f78bb948/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 15944 bytes
Desc: image002.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160629/f78bb948/attachment-0003.png>

More information about the vtkusers mailing list