[vtkusers] Frustum Culling

David E DeMarle dave.demarle at kitware.com
Wed Mar 7 10:12:09 EST 2007


To answer your original question: look at line 557. This tests a point
against the plane equations that define the frustum (when this->ExactTest is
off).

If you decide to backport ExtractSelectedFrustum this explanation may help.
The algorithm it uses (when this->ExactTest is  on) comes from Ned Greene,
Graphics Gems IV, 1994, p 74-82.  What it does is, instead of testing each
vertex of a cell against all six plane equations that define the frustum,
you can determine which vertex is nearest and farthest to each of the
planes. By testing just those two vertices against the plane equations you
can quickly reject the cells that are completely outside of the frustum and
quickly accept the cells that are completely inside the frustum. The cells
that are neither completely in or out are then clipped to determine if they
really do intersect.

In either case when the PassThrough flag is on, it runs through each cell,
uses one of the above options to determine if it is in or not and then puts
that result into the vtkInsidedness array.

To test if a dataset has that array just do:
 vtkDataArray *insidedness = ds->GetCellData()->GetArray("vtkInsidedNess);
//or GetPointData as the case may be
 if (insidedness == NULL)
   {
    cerr << "It doesn't have it."
   }

cheers,
Dave DeMarle

On 3/7/07, Michael Knopke <Michael.Knopke at gmx.de> wrote:
>
>  Problem is, that I can't use the latest cvs for my app, coz it has several issues. Lately I can't even start the app, gives me strange access violations in vtkPlane.cxx (even though this is the same file I use).
>
> I tried installing only vtkExtractSelectedFrustum but there where too many dependencies.
>
> I read the source code and can't really say how they detect the vtkInsideness, it's a different way than what I tried, maybe I try to adopt the code.
>
>
>
> Another Question: I read that data inside the frustum will be tagget with the attribute "vtkInsideness" How can I querry a Dataset for this attribute?
>
>
>
> Regards
>
>
>
> Michael
>
>
>
>
>
>
>
>
>
>
>
>
>
> >Have you tried vtkExtractSelectedFrustum?
>
>
>
> On 3/6/07, Michael Knopke <Michael.Knopke at gmx.de <http://www.vtk.org/mailman/listinfo/vtkusers>> wrote:
>
> >* *
>
> >*  Hi,*
>
> >* *
>
> >* *
>
> >* *
>
> >* I'm trying to write a new vtk-filter that can crop-out (set scalars to*
>
> >* fixed value e.g. 0) selected volumes (e.g. inside of BoxWidget).*
>
> >* *
>
> >* Unlike all other cropping filter I know, will this filter work with*
>
> >* vtkImageData and preserve topology and geometry. This means it will not cut*
>
> >* cells.*
>
> >* *
>
> >* Therefore I'm trying to implement frustum culling (with the planes from*
>
> >* BoxWidget) and later add octree to speed up calculation.*
>
> >* *
>
> >* *
>
> >* *
>
> >* The problem I have is regarding detection if the point that is evaluated*
>
> >* lies behind the plane. As far as I know, one has to calculate:*
>
> >* *
>
> >* *
>
> >* *
>
> >* 1). Shortest distance to plane (this works well)  à returns*
>
> >* PlanePointDistance*
>
> >* *
>
> >* *
>
> >* *
>
> >* 2). Add this distance to the DotProduct of ( PointX, NormalOfPlane):*
>
> >* *
>
> >* *
>
> >* *
>
> >*    Result = PlanePointDistance + (vtkMath::Dot(PointX, Normal));*
>
> >* *
>
> >* *
>
> >* *
>
> >* 3). If result is negative than pointX lies behind Plane*
>
> >* *
>
> >* *
>
> >* *
>
> >* *
>
> >* *
>
> >* Unfortunately this yields wrong results. Does anybody know what's wrong?*
>
> >* *
>
> >* *
>
> >* *
>
> >* Michael*
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the 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/20070307/eb190d63/attachment.htm>


More information about the vtkusers mailing list