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

Method SearchNeighborsForDuplicate

Common/DataModel/vtkKdTree.cxx:2029–2098  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2027
2028//------------------------------------------------------------------------------
2029int vtkKdTree::SearchNeighborsForDuplicate(
2030 int regionId, float* point, int** pointsSoFar, int* len, float tolerance, float tolerance2)
2031{
2032 int duplicateFound = -1;
2033
2034 float dist2 =
2035 this->RegionList[regionId]->GetDistance2ToInnerBoundary(point[0], point[1], point[2]);
2036
2037 if (dist2 >= tolerance2)
2038 {
2039 // There are no other regions with data that are within the
2040 // tolerance distance of this point.
2041
2042 return duplicateFound;
2043 }
2044
2045 // Find all regions that are within the tolerance distance of the point
2046
2047 int* regionIds = new int[this->NumberOfRegions];
2048
2049 this->BSPCalculator->ComputeIntersectionsUsingDataBoundsOn();
2050
2051#ifdef USE_SPHERE
2052
2053 // Find all regions which intersect a sphere around the point
2054 // with radius equal to tolerance. Compute the intersection using
2055 // the bounds of data within regions, not the bounds of the region.
2056
2057 int nRegions = this->BSPCalculator->IntersectsSphere2(
2058 regionIds, this->NumberOfRegions, point[0], point[1], point[2], tolerance2);
2059#else
2060
2061 // Technically, we want all regions that intersect a sphere around the
2062 // point. But this takes much longer to compute than a box. We'll compute
2063 // all regions that intersect a box. We may occasionally get a region
2064 // we don't need, but that's OK.
2065
2066 double box[6];
2067 box[0] = point[0] - tolerance;
2068 box[1] = point[0] + tolerance;
2069 box[2] = point[1] - tolerance;
2070 box[3] = point[1] + tolerance;
2071 box[4] = point[2] - tolerance;
2072 box[5] = point[2] + tolerance;
2073
2074 int nRegions = this->BSPCalculator->IntersectsBox(regionIds, this->NumberOfRegions, box);
2075
2076#endif
2077
2078 this->BSPCalculator->ComputeIntersectionsUsingDataBoundsOff();
2079
2080 for (int reg = 0; reg < nRegions; reg++)
2081 {
2082 if ((regionIds[reg] == regionId) || (len[reg] == 0))
2083 {
2084 continue;
2085 }
2086

Callers 1

Tested by

no test coverage detected