Commit a7a1c103 authored by Will Schroeder's avatar Will Schroeder Committed by Kitware Robot
Browse files

Merge topic 'ModernizePointLocator'

3298ad05 Encapsulated helper class in anonymous namespace
1c2a6930

 Performance related refactoring
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !938
parents f2038df7 3298ad05
......@@ -34,7 +34,7 @@
//
// .SECTION See Also
// vtkLocator, vtkIncrementalOctreePointLocator, vtkPointLocator,
// vtkMergePoints
// vtkMergePoints vtkStaticPointLocator
#ifndef vtkIncrementalPointLocator_h
#define vtkIncrementalPointLocator_h
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
// operations described here.
// .SECTION See Also
// vtkCellPicker vtkPointPicker
// vtkCellPicker vtkPointPicker vtkStaticPointLocator
#ifndef vtkPointLocator_h
#define vtkPointLocator_h
......@@ -52,6 +52,8 @@ public:
// 25 points per bucket.
static vtkPointLocator *New();
// Description:
// Standard methods for type management and printing.
vtkTypeMacro(vtkPointLocator,vtkIncrementalPointLocator);
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -218,11 +220,6 @@ protected:
double Distance2ToBucket(const double x[3], const int nei[3]);
double Distance2ToBounds(const double x[3], const double bounds[6]);
// Description:
// Give the bucket index that point is located in.
vtkIdType GetBucketIndex(const double x[3]);
void GetBucketIndices(const double x[3], int ijk[3]);
vtkPoints *Points; // Used for merging points
int Divisions[3]; // Number of sub-divisions in x-y-z directions
int NumberOfPointsPerBucket; //Used with previous boolean to control subdivide
......@@ -231,9 +228,34 @@ protected:
double InsertionTol2;
vtkIdType InsertionPointId;
double InsertionLevel;
// These are inlined methods and data members for performance reasons
double HX, HY, HZ;
double FX, FY, FZ, BX, BY, BZ;
vtkIdType XD, YD, ZD, SliceSize;
void GetBucketIndices(const double *x, int ijk[3]) const
{
// Compute point index. Make sure it lies within range of locator.
ijk[0] = static_cast<int>(((x[0] - this->BX) * this->FX));
ijk[1] = static_cast<int>(((x[1] - this->BY) * this->FY));
ijk[2] = static_cast<int>(((x[2] - this->BZ) * this->FZ));
ijk[0] = (ijk[0] < 0 ? 0 : (ijk[0] >= XD ? XD-1 : ijk[0]));
ijk[1] = (ijk[1] < 0 ? 0 : (ijk[1] >= YD ? YD-1 : ijk[1]));
ijk[2] = (ijk[2] < 0 ? 0 : (ijk[2] >= ZD ? ZD-1 : ijk[2]));
}
vtkIdType GetBucketIndex(const double *x) const
{
int ijk[3];
this->GetBucketIndices(x, ijk);
return ijk[0] + ijk[1]*this->XD + ijk[2]*this->SliceSize;
}
void ComputePerformanceFactors();
private:
vtkPointLocator(const vtkPointLocator&); // Not implemented.
void operator=(const vtkPointLocator&); // Not implemented.
......
......@@ -907,6 +907,7 @@ FindClosestPointWithinRadius(double radius, const double x[3],
return closest;
}
namespace {
//-----------------------------------------------------------------------------
// Obtaining closest points requires sorting nearby points
class IdTuple
......@@ -918,6 +919,7 @@ public:
bool operator< (const IdTuple& tuple) const
{return Dist2 < tuple.Dist2;}
};
}
//-----------------------------------------------------------------------------
template <typename TIds> void BucketList<TIds>::
......@@ -1157,7 +1159,7 @@ GetOverlappingBuckets(NeighborBuckets* buckets, const double x[3], double dist,
for ( k= minLevel[2]; k <= maxLevel[2]; k++ )
{
kFactor = k*this->Divisions[0]*this->Divisions[1];
kFactor = k * this->xyD;
if (k >= prevMinLevel[2] && k <= prevMaxLevel[2])
{
kSkipFlag = 1;
......@@ -1176,7 +1178,7 @@ GetOverlappingBuckets(NeighborBuckets* buckets, const double x[3], double dist,
{
jkSkipFlag = 0;
}
jFactor = j*this->Divisions[0];
jFactor = j * this->xD;
for ( i= minLevel[0]; i <= maxLevel[0]; i++ )
{
if ( jkSkipFlag && i == prevMinLevel[0] )
......
Markdown is supported
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