| 389 | |
| 390 | template <typename T> |
| 391 | int TestKernel(vtkSmartPointer<T> kernel, vtkIdType numberOfPoints, const std::string& description) |
| 392 | { |
| 393 | int status = 0; |
| 394 | std::cout << "Testing " << description; |
| 395 | vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New(); |
| 396 | sphere->SetPhiResolution(21); |
| 397 | sphere->SetThetaResolution(21); |
| 398 | sphere->SetRadius(.5); |
| 399 | sphere->Update(); |
| 400 | |
| 401 | vtkSmartPointer<vtkPointSource> randomSphere = vtkSmartPointer<vtkPointSource>::New(); |
| 402 | randomSphere->SetRadius(sphere->GetRadius() * 2.0); |
| 403 | randomSphere->SetNumberOfPoints(numberOfPoints); |
| 404 | randomSphere->Update(); |
| 405 | vtkSmartPointer<vtkDoubleArray> distances = vtkSmartPointer<vtkDoubleArray>::New(); |
| 406 | distances->SetNumberOfTuples(randomSphere->GetOutput()->GetNumberOfPoints()); |
| 407 | vtkSmartPointer<vtkDoubleArray> normals = vtkSmartPointer<vtkDoubleArray>::New(); |
| 408 | normals->SetNumberOfComponents(3); |
| 409 | normals->SetNumberOfTuples(randomSphere->GetOutput()->GetNumberOfPoints()); |
| 410 | |
| 411 | double refPt[3]; |
| 412 | refPt[0] = 0.0; |
| 413 | refPt[1] = 0.0; |
| 414 | refPt[2] = 0.0; |
| 415 | for (vtkIdType id = 0; id < randomSphere->GetOutput()->GetNumberOfPoints(); ++id) |
| 416 | { |
| 417 | double distance; |
| 418 | double pt[3]; |
| 419 | randomSphere->GetOutput()->GetPoint(id, pt); |
| 420 | distance = std::sqrt(vtkMath::Distance2BetweenPoints(refPt, pt)); |
| 421 | distances->SetTuple1(id, distance); |
| 422 | double normal[3]; |
| 423 | normal[0] = pt[0]; |
| 424 | normal[1] = pt[1]; |
| 425 | normal[2] = pt[2]; |
| 426 | normals->SetTuple3(id, normal[0], normal[1], normal[2]); |
| 427 | } |
| 428 | distances->SetName("TestDistances"); |
| 429 | normals->SetName("TestNormals"); |
| 430 | |
| 431 | randomSphere->GetOutput()->GetPointData()->AddArray(distances); |
| 432 | randomSphere->GetOutput()->GetPointData()->AddArray(normals); |
| 433 | |
| 434 | vtkSmartPointer<vtkStaticPointLocator> locator = vtkSmartPointer<vtkStaticPointLocator>::New(); |
| 435 | locator->SetDataSet(randomSphere->GetOutput()); |
| 436 | double meanProbe = 0.0; |
| 437 | kernel->Initialize(locator, randomSphere->GetOutput(), randomSphere->GetOutput()->GetPointData()); |
| 438 | |
| 439 | std::ostringstream fullPrint; |
| 440 | kernel->Print(fullPrint); |
| 441 | for (vtkIdType id = 0; id < sphere->GetOutput()->GetNumberOfPoints(); ++id) |
| 442 | { |
| 443 | double point[3]; |
| 444 | sphere->GetOutput()->GetPoints()->GetPoint(id, point); |
| 445 | vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); |
| 446 | vtkSmartPointer<vtkDoubleArray> weights = vtkSmartPointer<vtkDoubleArray>::New(); |
| 447 | kernel->ComputeBasis(point, ptIds); |
| 448 | kernel->ComputeWeights(point, ptIds, weights); |
nothing calls this directly
no test coverage detected