vtkCellTreeLocator::FindCell causes redundant calculation of closest point
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Here is my patched code....
vtkIdType vtkCellTreeLocator::FindCell( double pos[3], double , vtkGenericCell cell, double pcoords[3], double weights ) { if( this->Tree == 0 ) { return -1; }
// ADSK, JNH, closestPoint is redundant! double /closestPoint[3],/ dist2; int subId;
const float _pos[3] = { static_cast(pos[0]), static_cast(pos[1]), static_cast(pos[2]) }; vtkCellPointTraversal pt( *(this->Tree), _pos );
//bool found = false;
while( const vtkCellTreeNode* n = pt.Next() ) { const unsigned int* begin = &(this->Tree->Leaves[n->Start()]); const unsigned int* end = begin + n->Size();
for( ; begin!=end; ++begin )
{
this->DataSet->GetCell(*begin, cell);
// ADSK, JNH, closestPoints is redundant!
if( cell->EvaluatePosition(pos, 0 /*closestPoint*/, subId, pcoords, dist2, weights)==1 )
{
return *begin;
}
}
}
return -1; }