Commit e9255e2d authored by Andrew Bauer's avatar Andrew Bauer Committed by Kitware Robot
Browse files

Merge topic 'vtkCellTreeLocator_compiler_warnings'

1c424f60 Fixed problem of not using cached cell bounds properly.
parents 1b63b087 1c424f60
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "vtkDebugLeaks.h" #include "vtkDebugLeaks.h"
int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] ) int TestWithCachedCellBoundsParameter(int cachedCellBounds)
{ {
// kuhnan's sample code used to test // kuhnan's sample code used to test
// vtkCellLocator::IntersectWithLine(...9 params...) // vtkCellLocator::IntersectWithLine(...9 params...)
...@@ -48,7 +48,7 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] ) ...@@ -48,7 +48,7 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
// the cell locator // the cell locator
vtkNew<vtkCellTreeLocator> locator; vtkNew<vtkCellTreeLocator> locator;
locator->SetDataSet(sphere2->GetOutput()); locator->SetDataSet(sphere2->GetOutput());
//locator->CacheCellBoundsOn(); locator->SetCacheCellBounds(cachedCellBounds);
locator->AutomaticOn(); locator->AutomaticOn();
locator->BuildLocator(); locator->BuildLocator();
...@@ -83,8 +83,9 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] ) ...@@ -83,8 +83,9 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
if ( numIntersected != 9802 ) if ( numIntersected != 9802 )
{ {
int numMissed = 9802 - numIntersected; int numMissed = 9802 - numIntersected;
cerr << "ERROR: " << numMissed << " ray-sphere intersections missed!!!" << endl; vtkGenericWarningMacro("ERROR: " << numMissed << " ray-sphere intersections missed! "
cerr << "If on a non-WinTel32 platform, try rayLen = 0.200001 or 0.20001 for a new test." << endl; << "If on a non-WinTel32 platform, try rayLen = 0.200001"
<< " or 0.20001 for a new test.");
return 1; return 1;
} }
else else
...@@ -96,3 +97,10 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] ) ...@@ -96,3 +97,10 @@ int CellTreeLocator( int vtkNotUsed(argc), char *vtkNotUsed(argv)[] )
return 0; 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 ...@@ -740,7 +740,7 @@ int vtkCellTreeLocator::IntersectWithLine(double p1[3], double p2[3], double tol
// Does ray pass through root BBox // Does ray pass through root BBox
tmin = 0; tmax = 1; 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; return false;
} }
...@@ -822,17 +822,22 @@ int vtkCellTreeLocator::IntersectWithLine(double p1[3], double p2[3], double tol ...@@ -822,17 +822,22 @@ int vtkCellTreeLocator::IntersectWithLine(double p1[3], double p2[3], double tol
vtkIdType cell_ID = this->Tree->Leaves[node->Start()+i]; 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); this->DataSet->GetCellBounds(cell_ID, cellBounds);
} }
if (_getMinDist(p1, ray_vec, cellBounds) > closest_intersection) if (_getMinDist(p1, ray_vec, boundsPtr) > closest_intersection)
{ {
break; break;
} }
// //
ctmin = _tmin; ctmax = _tmax; 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)) 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