[vtk-developers] Bug or feature in vtkPlane::IntersectWithLine ?

Philippe Pebay philippe.pebay at kitware.com
Mon Nov 28 10:42:34 EST 2011


Hello Will,

Thanks for the comments and background information.

I will modify the vtkTriangle intersection routine; at this point what
would probably be the fastest would be to calculate the intersection with
the 3 edges when parallelism is detected.

Best
Philippe

On Mon, Nov 28, 2011 at 4:16 PM, Will Schroeder
<will.schroeder at kitware.com>wrote:

> Philippe-
>
> I agree, if parallel, then a distance check should be performed between
> the line and the triangle and compared to the input tolerance. Obviously
> it's distance to a *finite line*, so you might start by computing distance
> of a infinite line to the infinite plane containing the triangle (this
> should be fast). Then if this is within tolerance, then take into account
> the finite nature of the line and triangle to return the final verdict.
>
> Similar code should be extended to the polygon as well.
>
> I suspect that this was written as a performance "feature" for picking.
> The nature of meshes is such that if a ray is parallel to a triangle t1,
> then it is likely to hit another triangle connected to t1 but with a
> different normal. And if t1 and all connected triangles are all parallel to
> the ray, then you can't see them hence pick them :-) But line intersection
> is being used for heavier-duty operations in VTK now, so we should beef the
> operation up.
>
> W
>
> On Sun, Nov 27, 2011 at 11:28 AM, Philippe Pebay <
> philippe.pebay at kitware.com> wrote:
>
>> Hello all,
>>
>> The IntersectWithLine()  routine in vtkPlane returns 0, i.e., no
>> intersection, whenever the plane and line are parallel.
>> Specifically, this occurs in lines 171-20, copied below:
>>
>>   num = vtkMath::Dot(n,p0) - ( n[0]*p1[0] + n[1]*p1[1] + n[2]*p1[2] ) ;
>>   den = n[0]*p21[0] + n[1]*p21[1] + n[2]*p21[2];
>>   //
>>   // If denominator with respect to numerator is "zero", then the line and
>>   // plane are considered parallel.
>>   //
>>
>>   // trying to avoid an expensive call to fabs()
>>   if (den < 0.0)
>>     {
>>     fabsden = -den;
>>     }
>>   else
>>     {
>>     fabsden = den;
>>     }
>>   if (num < 0.0)
>>     {
>>     fabstolerance = -num*VTK_PLANE_TOL;
>>     }
>>   else
>>     {
>>     fabstolerance = num*VTK_PLANE_TOL;
>>     }
>>   if ( fabsden <= fabstolerance )
>>     {
>>     t = VTK_DOUBLE_MAX;
>>     return 0;
>>     }
>>
>> Nevertheless, a line may be parallel to a plane and yet be contained
>> inside said plane. In this case, the routine will return 0 just as if the
>> line was parallel and outside of the plane, as the calculation does not
>> consider the plane-to-line distance.
>>
>> It might have been intended to be like this. However, this becomes a
>> problem in the implementation of vtkTriangle's implementation of
>> IntersectWithLine(), which first calls vtkPlane::IntersectWithLine(): as a
>> result, a line which goes through a vtkTriangle, while being contained in
>> the plane of this triangle, will be considered as NOT intersecting the
>> triangle, which is clearly an error.
>>
>> I am therefore wondering whether this behavior of
>> vtkPlane::IntersectWithLine is a feature, or a bug.
>>
>> If it is not a bug, then I would submit that the implementation of
>> vtkTriangle::IntersectWithLine() should be modified, by checking, for lines
>> that ARE parallel to the triangle, whether they are contained in the same
>> plane.
>>
>> Please let me know what you think. Thank you,
>> Philippe
>>
>>
>>
>>
>> --
>> Philippe Pébay
>> Directeur de la Visualisation et du Calcul Haute Performance
>> Kitware SAS
>> 20 rue de la Villette
>> 69328 Lyon cedex 03, France
>> +33 (0)4.26.68.50.03 begin_of_the_skype_highlighting            +33
>> (0)4.26.68.50.03      end_of_the_skype_highlighting
>> http://www.kitware.fr
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>>
>
>
> --
> William J. Schroeder, PhD
> Kitware, Inc.
> 28 Corporate Drive
> Clifton Park, NY 12065
> will.schroeder at kitware.com
> http://www.kitware.com
> (518) 881-4902
>



-- 
Philippe Pébay
Directeur de la Visualisation et du Calcul Haute Performance
Kitware SAS
20 rue de la Villette
69328 Lyon cedex 03, France
+33 (0)4.26.68.50.03
http://www.kitware.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20111128/f83ae4a0/attachment.html>


More information about the vtk-developers mailing list