[vtkusers] Wrong coordinate system for bounds computation in vtkClipPlanesPainter

David Gobbi david.gobbi at gmail.com
Thu Feb 27 11:28:22 EST 2014


Hi Xabi,

As I mentioned in the bug report, I think the UpdateBounds() method
for vtkClipPlanesPainter should be removed.  I can provide some
additional information here to explain why.  Hopefully someone who is
more familiar with the painter code can confirm or deny my
explanation.  In any case, it's good to have this discussion on the
developer list.

The UpdateBounds() method is called during the "Update" phase of the
mapper, rather than during the "Render" phase.  During the "Update"
phase, the mapper only sees the "data" side of the pipeline: it has no
access to the actor, the renderer, or the window.  Mapper clipping
planes in VTK are expressed in world coordinates, and the clipping is
typically done in hardware by the GPU.  In other words, clipping
occurs during the "Render" phase.

If clipping is to be applied to the data itself, using data
coordinates for the clipping planes, then that can be done with e.g.
vtkClipPolyData.  This is slower than hardware clipping if the
clipping planes need to be dynamic.  However, it is faster than
hardware clipping if the clipping planes are static, because it means
that fewer points and cells have to be loaded onto the GPU.

Your assertion that vtkRenderer::ResetCamera() should take the
hardware (i.e. mapper) clipping planes into consideration is,
unfortunately, one that we will probably have to reject.  Even if it
makes sense that UpdateBounds() should be based on the rendered
representation of the data (rather than just on the data itself), the
clear split between the "Data Update" phase versus the "Data Render"
phase in the mapper makes it nearly impossible.

My advice, then, is to remove vtkClipPlanesPainter::UpdateBounds().
And for applications where ResetCamera needs to use the clipped
bounds, use vtkClipPolyData instead of setting the planes on the
mapper.

  David


On Wed, Feb 26, 2014 at 2:57 AM, Xabi Riobe <xabivtk at gmail.com> wrote:
> Hello,
>
> I would want to discuss about the issue reported here:
> http://vtk.org/Bug/view.php?id=11949
>
> The vtkClipPlanesPainter::UpdateBounds method is incorrect, but should it be
> removed or fixed if possible?
>
> the documentation for vtkPainter says:
> " Expand or shrink the estimated bounds of the object based on the geometric
> transformations performed in the painter. If the painter does not modify the
> geometry, the bounds are passed through. "
>
> Since we are talking about the painter, i understand that the geometry
> referred here is the one of the data representation, not the data itself.
> And in that case, it is modified if clipped by the planes (in
> vtkOpenGLClipPlanesPainter), so the bounds should be updated.
>
> But for that we need the actor's matrix, which is not accessible in the
> method UpdateBounds.
>
> And the initial problem is that the vtkRenderer::ResetCamera method should
> take into consideration the clipped bounds in order to recenter about the
> visible geometry.
>
> Any ideas or comments about that?
>
>
> 2013-05-06 17:31 GMT+02:00 xabivtk <xabivtk at gmail.com>:
>
>> Hi,
>>
>> For the 5.10 release, the method vtkClipPlanesPainter::UpdateBounds has
>> been
>> implemented to fix a bug, but i think that there is a transformation
>> missing
>> for the planes, leading to the incorrect culling of some props in the case
>> they have a transformation matrix different than identity.
>>
>> this->ClippingPlanes are expressed in world coordinates, after the use of
>> the actor's matrix, whereas the bounds are in data coordinates
>>
>> To clip the data, the planes are used in
>> vtkOpenGLClipPlanesPainter::RenderInternal to be passed to glClipPlane
>> after
>> beeing transformed from world to data coords with the use of the actor's
>> matrix.
>> But in the rendering pipeline we have a call to
>> vtkClipPlanesPainter::UpdateBounds where these planes are considered to be
>> in the data coordinates.
>>
>> Here is the calling stack:
>>
>> vtkClipPlanesPainter::UpdateBounds              ===> original data bounds,
>> but actor's world coordinates transformed planes
>> vtkPainterPolyDataMapper::ComputeBounds
>> vtkPolyDataMapper::GetBounds
>> vtkActor::GetBounds                                  ===> actor's
>> transformation Matrix applied to the bounds
>> vtkFrustumCoverageCuller::Cull                    ===> Prop can be
>> incorrectly culled !!!!
>>
>> So in the method vtkClipPlanesPainter::UpdateBounds, the planes should be
>> transformed with the actor's matrix before changing the bounds.
>>
>>
>> I used to fill a report in the Mantis Bug Tracker for this kind of bug,
>> but
>> it seems that vtk has been removed from it...


More information about the vtkusers mailing list