Commit 1c424f60 authored by Andrew Bauer's avatar Andrew Bauer
Browse files

Fixed problem of not using cached cell bounds properly.

I finally figured out what was really supposed to be happening
in part of the code and changed it so that it would properly
use cell bounds if they were precomputed.  Also improved the test.

Change-Id: I3831a2dff6b1128669e4298851dea366222f64fb
parent a84b5f93
......@@ -23,7 +23,7 @@
#include "vtkDebugLeaks.h"
int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
int TestWithCachedCellBoundsParameter(int cachedCellBounds)
{
// kuhnan's sample code used to test
// vtkCellLocator::IntersectWithLine(...9 params...)
......@@ -48,7 +48,7 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
// the cell locator
vtkNew<vtkCellTreeLocator> locator;
locator->SetDataSet(sphere2->GetOutput());
//locator->CacheCellBoundsOn();
locator->SetCacheCellBounds(cachedCellBounds);
locator->AutomaticOn();
locator->BuildLocator();
......@@ -83,8 +83,9 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
if ( numIntersected != 9802 )
{
int numMissed = 9802 - numIntersected;
cerr << "ERROR: " << numMissed << " ray-sphere intersections missed!!!" << endl;
cerr << "If on a non-WinTel32 platform, try rayLen = 0.200001 or 0.20001 for a new test." << endl;
vtkGenericWarningMacro("ERROR: " << numMissed << " ray-sphere intersections missed! "
<< "If on a non-WinTel32 platform, try rayLen = 0.200001"
<< " or 0.20001 for a new test.");
return 1;
}
else
......@@ -96,3 +97,10 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
return 0;
}
int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
{
int retVal = TestWithCachedCellBoundsParameter(0);
retVal += TestWithCachedCellBoundsParameter(1);
return retVal;
}
......@@ -740,7 +740,7 @@ int vtkCellTreeLocator::IntersectWithLine(double p1[3], double p2[3], double tol
// Does ray pass through root BBox
tmin = 0; tmax = 1;
if (!RayMinMaxT(p1, ray_vec, tmin, tmax)) // 0 for root node
if (!this->RayMinMaxT(p1, ray_vec, tmin, tmax)) // 0 for root node
{
return false;
}
......@@ -822,17 +822,22 @@ int vtkCellTreeLocator::IntersectWithLine(double p1[3], double p2[3], double tol
vtkIdType cell_ID = this->Tree->Leaves[node->Start()+i];
//
if (this->CellBounds == NULL)
double* boundsPtr = cellBounds;
if (this->CellBounds)
{
boundsPtr = this->CellBounds[cell_ID];
}
else
{
this->DataSet->GetCellBounds(cell_ID, cellBounds);
}
if (_getMinDist(p1, ray_vec, cellBounds) > closest_intersection)
if (_getMinDist(p1, ray_vec, boundsPtr) > closest_intersection)
{
break;
}
//
ctmin = _tmin; ctmax = _tmax;
if (RayMinMaxT(cellBounds, p1, ray_vec, ctmin, ctmax))
if (this->RayMinMaxT(boundsPtr, p1, ray_vec, ctmin, ctmax))
{
if (this->IntersectCellInternal(cell_ID, p1, p2, tol, t_hit, ipt, pcoords, subId))
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment