| 13 | #include <iostream> |
| 14 | |
| 15 | int TimePointLocators(int, char*[]) |
| 16 | { |
| 17 | int nPts = 100000; |
| 18 | int nQ = nPts / 10; |
| 19 | int N = 10; |
| 20 | double R = 0.01; |
| 21 | |
| 22 | vtkTimerLog* timer = vtkTimerLog::New(); |
| 23 | double buildTime[4], cpTime[4], cnpTime[4], crpTime[4]; |
| 24 | for (int i = 0; i < 4; ++i) |
| 25 | { |
| 26 | buildTime[i] = cpTime[i] = cnpTime[i] = crpTime[i] = 0.0; |
| 27 | } |
| 28 | |
| 29 | std::cout << "\nTiming for " << nPts << " points, " << nQ << " queries\n"; |
| 30 | |
| 31 | // Populate a list of points and query locations |
| 32 | vtkPoints* points = vtkPoints::New(); |
| 33 | points->SetDataTypeToDouble(); |
| 34 | points->SetNumberOfPoints(nPts); |
| 35 | for (int i = 0; i < nPts; ++i) |
| 36 | { |
| 37 | points->SetPoint(i, vtkMath::Random(-1, 1), vtkMath::Random(-1, 1), vtkMath::Random(-1, 1)); |
| 38 | } |
| 39 | |
| 40 | vtkPolyData* polydata = vtkPolyData::New(); |
| 41 | polydata->SetPoints(points); |
| 42 | points->ComputeBounds(); |
| 43 | |
| 44 | // Create points array which are positions to probe data with FindClosestPoint(). |
| 45 | vtkPoints* qPoints = vtkPoints::New(); |
| 46 | qPoints->SetDataTypeToDouble(); |
| 47 | qPoints->SetNumberOfPoints(nQ); |
| 48 | vtkMath::RandomSeed(314159); |
| 49 | for (int i = 0; i < nQ; ++i) |
| 50 | { |
| 51 | qPoints->SetPoint(i, vtkMath::Random(-1, 1), vtkMath::Random(-1, 1), vtkMath::Random(-1, 1)); |
| 52 | } |
| 53 | |
| 54 | vtkIdList* closest = vtkIdList::New(); |
| 55 | |
| 56 | //--------------------------------------------------------------------------- |
| 57 | // The simple uniform binning point locator |
| 58 | vtkPointLocator* uniformLocator = vtkPointLocator::New(); |
| 59 | timer->StartTimer(); |
| 60 | uniformLocator->SetDataSet(polydata); |
| 61 | uniformLocator->BuildLocator(); |
| 62 | timer->StopTimer(); |
| 63 | uniformLocator->Delete(); |
| 64 | buildTime[0] = timer->GetElapsedTime(); |
| 65 | |
| 66 | uniformLocator = vtkPointLocator::New(); |
| 67 | uniformLocator->SetDataSet(polydata); |
| 68 | uniformLocator->BuildLocator(); |
| 69 | timer->StartTimer(); |
| 70 | for (int i = 0; i < nQ; ++i) |
| 71 | { |
| 72 | uniformLocator->FindClosestPoint(qPoints->GetPoint(i)); |
nothing calls this directly
no test coverage detected