MantisBT - VTK
View Issue Details
0010349VTK(No Category)public2010-03-01 09:012014-02-17 14:26
xabi riobe 
Andy Bauer 
normalmajoralways
closedfixed 
 
6.1.dev 
TBD
incorrect functionality
0010349: vtkCellLocator precision issue
There is a numerical precision problem with the method vtkCellLocator::IntersectWithLine

in vtkCellLocator.cxx in line 287 of revision 1.89:
  if (cell->IntersectWithLine(a0, a1, tol, t, x, pcoords, subId) )
    {
    if ( ! this->IsInOctantBounds(x) )

sometimes the resulting intersection point returned by the cell->IntersectWithLine is a (0.000000000000004) little out of the bounds and the call to IsInOctantBounds discard the point.

I think it will be a good thing to add a tolerance to the method vtkCellLocator::IsInOctantBounds(double x[3]).
in the attached file there is an example that illustrates the issue.
a vtkCellLocator is filled with a cube and a line going from dPoint to dPoint2 intersect the box.
in Z axis, the bounds of the box are (1.0; -20)

if dPoint2[2] = -77.76333863288239, the resulting intersection point is at -20 and all is correct
if dPoint2[2] = -77.76333863288238, the resulting intersection point is at -20.000000000000004, so out of bounds.
No tags attached.
cpp Intersect.cpp (4,183) 2010-03-01 09:01
https://www.vtk.org/Bug/file/7918/Intersect.cpp
cxx locatorbug.cxx (7,930) 2013-04-25 13:49
https://www.vtk.org/Bug/file/9437/locatorbug.cxx
Issue History
2010-03-01 09:01xabi riobeNew Issue
2010-03-01 09:01xabi riobeFile Added: Intersect.cpp
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2012-03-07 03:57xabi riobeStatusexpired => backlog
2012-03-07 03:57xabi riobeResolutionopen => reopened
2013-04-16 16:53Steve LangerNote Added: 0030576
2013-04-25 13:49Steve LangerFile Added: locatorbug.cxx
2013-04-25 13:51Steve LangerNote Added: 0030623
2013-09-30 04:34xabi riobeNote Added: 0031656
2013-10-07 10:46xabi riobeNote Added: 0031681
2013-10-07 10:46xabi riobeStatusbacklog => gerrit review
2013-12-17 13:11Dave DeMarleNote Added: 0031982
2013-12-17 13:11Dave DeMarleAssigned To => Dave DeMarle
2013-12-17 13:11Dave DeMarleStatusgerrit review => backlog
2014-01-14 05:52xabi riobeStatusbacklog => gerrit review
2014-02-17 14:25Andy BauerProject => TBD
2014-02-17 14:25Andy BauerType => incorrect functionality
2014-02-17 14:25Andy BauerAssigned ToDave DeMarle => Andy Bauer
2014-02-17 14:26Andy BauerNote Added: 0032342
2014-02-17 14:26Andy BauerStatusgerrit review => closed
2014-02-17 14:26Andy BauerResolutionreopened => fixed
2014-02-17 14:26Andy BauerFixed in Version => 6.1.dev

Notes
(0030576)
Steve Langer   
2013-04-16 16:53   
I just ran into the same issue. It causes vtkPicker::Pick to choose the wrong object when resolving mouse clicks on the surface of a grid.

A solution would to remove the "if" at line 1242 of vtkCellLocator::BuildLocatorInternal in vtkCellLocator.cxx (version 5.10.1). Always increase the size of the bounding box to ensure that all cells are actually within the box, even if min!=max. This fixes the problem in my situation.
(0030623)
Steve Langer   
2013-04-25 13:51   
I uploaded another file that illustrates the problem in a real world situation, distilled from a larger program. There are comments in the file explaining what's going on.
(0031656)
xabi riobe   
2013-09-30 04:34   
The problem is still there in 6.0.0

add the following line to Intersect.cpp :
#define vtkRenderingCore_AUTOINIT 2(vtkInteractionStyle, vtkRenderingOpenGL)
(0031681)
xabi riobe   
2013-10-07 10:46   
http://review.source.kitware.com/#/c/12936/ [^]
(0031982)
Dave DeMarle   
2013-12-17 13:11   
proposed patch had problems in gerrit review
(0032342)
Andy Bauer   
2014-02-17 14:26   
Merged in through gerrit. Commit SHA is 618d6279992e23182093ef683ea25400267a09ce