[vtkusers] Wrong coordinate system for bounds computation in vtkClipPlanesPainter
xabi riobe
xabivtk at gmail.com
Tue May 14 09:13:13 EDT 2013
Here is a simple example to illustrate the issue, with screenshots of
different situations:
clip.jpg: the mapper is clipped, the actor has no transformation
transform.jpg: the mapper is not clipped, the actor has a transformation
cliptransform.jpg: the mapper is clipped, the actor has a transformation
==> the actor is culled
#include <vtkActor.h>
#include <vtkAxesActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkPlanes.h>
#include <vtkTransform.h>
vtkSmartPointer<vtkRenderer> ren1= vtkSmartPointer<vtkRenderer>::New();
ren1->SetBackground(0.4, 0.4, 0.5);
ren1->SetBackground2(0.2,0.2,0.3);
ren1->SetGradientBackground(true);
vtkSmartPointer<vtkRenderWindow> renWin=
vtkSmartPointer<vtkRenderWindow>::New();
renWin->SetSize( 972, 800 );
renWin->AddRenderer(ren1);
vtkSmartPointer<vtkRenderWindowInteractor> iren=
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer<vtkSphereSource> sph=
vtkSmartPointer<vtkSphereSource>::New();
sph->SetPhiResolution(22);
sph->SetThetaResolution(22);
sph->SetRadius(2.0);
sph->Update();
vtkSmartPointer<vtkPlanes> planes= vtkSmartPointer<vtkPlanes>::New();
planes->SetBounds(1.5,-1.5,1.5,-1.5,1.5,-1.5);
vtkSmartPointer<vtkPolyDataMapper> Mapper=
vtkSmartPointer<vtkPolyDataMapper>::New();
Mapper->SetInputConnection(sph->GetOutputPort());
Mapper->SetClippingPlanes(planes);
vtkSmartPointer<vtkTransform> tr= vtkSmartPointer<vtkTransform>::New();
tr->Translate(10,0,0);
vtkSmartPointer<vtkActor> Actor= vtkSmartPointer<vtkActor>::New();
Actor->SetMapper(Mapper);
Actor->SetUserTransform(tr);
vtkSmartPointer<vtkAxesActor> axes= vtkSmartPointer<vtkAxesActor>::New();
axes->AxisLabelsOff();
ren1->AddActor(Actor);
ren1->AddActor(axes);
ren1->ResetCamera();
renWin->Render();
iren->Start();
2013/5/6 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...
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Wrong-coordinate-system-for-bounds-computation-in-vtkClipPlanesPainter-tp5720585.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130514/b3ad558b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clip.jpg
Type: image/jpeg
Size: 21581 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130514/b3ad558b/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cliptransform.jpg
Type: image/jpeg
Size: 14726 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130514/b3ad558b/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transform.jpg
Type: image/jpeg
Size: 16831 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130514/b3ad558b/attachment-0002.jpg>
More information about the vtkusers
mailing list