MCPcopy Create free account
hub / github.com/Kitware/VTK / FindPointsWithinRadius

Method FindPointsWithinRadius

Common/DataModel/vtkStaticPointLocator.cxx:1045–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043// touch.
1044template <typename TIds>
1045void BucketList<TIds>::FindPointsWithinRadius(double R, const double x[3], vtkIdList* result)
1046{
1047 double dist2;
1048 double pt[3];
1049 vtkIdType ptId, cno, numIds;
1050 double R2 = R * R;
1051 const vtkLocatorTuple<TIds>* ids;
1052 double xMin[3], xMax[3];
1053 int i, j, k, ii, jOffset, kOffset, ijkMin[3], ijkMax[3];
1054
1055 // Determine the range of indices in each direction based on radius R
1056 xMin[0] = x[0] - R;
1057 xMin[1] = x[1] - R;
1058 xMin[2] = x[2] - R;
1059 xMax[0] = x[0] + R;
1060 xMax[1] = x[1] + R;
1061 xMax[2] = x[2] + R;
1062
1063 // Find the footprint in the locator
1064 this->GetBucketIndices(xMin, ijkMin);
1065 this->GetBucketIndices(xMax, ijkMax);
1066
1067 // Clear out previous results
1068 result->Reset();
1069
1070 // Add points within footprint and radius
1071 for (k = ijkMin[2]; k <= ijkMax[2]; ++k)
1072 {
1073 kOffset = k * this->xyD;
1074 for (j = ijkMin[1]; j <= ijkMax[1]; ++j)
1075 {
1076 jOffset = j * this->xD;
1077 for (i = ijkMin[0]; i <= ijkMax[0]; ++i)
1078 {
1079 cno = i + jOffset + kOffset;
1080
1081 if ((numIds = this->GetNumberOfIds(cno)) > 0)
1082 {
1083 ids = this->GetIds(cno);
1084 for (ii = 0; ii < numIds; ii++)
1085 {
1086 ptId = ids[ii].PtId;
1087 this->DataSet->GetPoint(ptId, pt);
1088 dist2 = vtkMath::Distance2BetweenPoints(x, pt);
1089 if (dist2 <= R2)
1090 {
1091 result->InsertNextId(ptId);
1092 }
1093 } // for all points in bucket
1094 } // if points in bucket
1095 } // i-footprint
1096 } // j-footprint
1097 } // k-footprint
1098}
1099
1100//------------------------------------------------------------------------------
1101// Find the point within tol of the finite line, and closest to the starting

Callers

nothing calls this directly

Calls 7

GetNumberOfIdsMethod · 0.95
GetIdsMethod · 0.95
BuildLocatorMethod · 0.95
InsertNextIdMethod · 0.80
GetBucketIndicesMethod · 0.45
ResetMethod · 0.45
GetPointMethod · 0.45

Tested by

no test coverage detected