------------------------------------------------------------------------------ Query functions subsequent to BuildLocatorFromPoints, relating to duplicate and nearby points
| 1867 | // relating to duplicate and nearby points |
| 1868 | // |
| 1869 | vtkIdTypeArray* vtkKdTree::BuildMapForDuplicatePoints(float tolerance = 0.0) |
| 1870 | { |
| 1871 | int i; |
| 1872 | |
| 1873 | if ((tolerance < 0.0) || (tolerance >= this->MaxWidth)) |
| 1874 | { |
| 1875 | vtkWarningMacro(<< "vtkKdTree::BuildMapForDuplicatePoints - invalid tolerance"); |
| 1876 | tolerance = this->MaxWidth; |
| 1877 | } |
| 1878 | |
| 1879 | TIMER("Find duplicate points"); |
| 1880 | |
| 1881 | int* idCount = new int[this->NumberOfRegions]; |
| 1882 | int** uniqueFound = new int*[this->NumberOfRegions]; |
| 1883 | |
| 1884 | if (!idCount || !uniqueFound) |
| 1885 | { |
| 1886 | delete[] idCount; |
| 1887 | delete[] uniqueFound; |
| 1888 | |
| 1889 | vtkErrorMacro(<< "vtkKdTree::BuildMapForDuplicatePoints memory allocation"); |
| 1890 | return nullptr; |
| 1891 | } |
| 1892 | |
| 1893 | memset(idCount, 0, sizeof(int) * this->NumberOfRegions); |
| 1894 | |
| 1895 | for (i = 0; i < this->NumberOfRegions; i++) |
| 1896 | { |
| 1897 | uniqueFound[i] = new int[this->RegionList[i]->GetNumberOfPoints()]; |
| 1898 | |
| 1899 | if (!uniqueFound[i]) |
| 1900 | { |
| 1901 | delete[] idCount; |
| 1902 | for (int j = 0; j < i; j++) |
| 1903 | delete[] uniqueFound[j]; |
| 1904 | delete[] uniqueFound; |
| 1905 | vtkErrorMacro(<< "vtkKdTree::BuildMapForDuplicatePoints memory allocation"); |
| 1906 | return nullptr; |
| 1907 | } |
| 1908 | } |
| 1909 | |
| 1910 | float tolerance2 = tolerance * tolerance; |
| 1911 | |
| 1912 | vtkIdTypeArray* uniqueIds = vtkIdTypeArray::New(); |
| 1913 | uniqueIds->SetNumberOfValues(this->NumberOfLocatorPoints); |
| 1914 | |
| 1915 | int idx = 0; |
| 1916 | int nextRegionId = 0; |
| 1917 | float* point = this->LocatorPoints; |
| 1918 | |
| 1919 | while (idx < this->NumberOfLocatorPoints) |
| 1920 | { |
| 1921 | // first point we have in this region |
| 1922 | |
| 1923 | int currentId = this->LocatorIds[idx]; |
| 1924 | |
| 1925 | int regionId = this->GetRegionContainingPoint(point[0], point[1], point[2]); |
| 1926 |
nothing calls this directly
no test coverage detected