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

Function TestKernel

Filters/Points/Testing/Cxx/UnitTestKernels.cxx:391–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389
390template <typename T>
391int 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);

Callers

nothing calls this directly

Calls 15

SetPhiResolutionMethod · 0.80
SetThetaResolutionMethod · 0.80
SetTuple1Method · 0.80
SetTuple3Method · 0.80
FillComponentMethod · 0.80
SetScalarsMethod · 0.80
NewFunction · 0.50
sqrtFunction · 0.50
FuzzyCompareFunction · 0.50
SetRadiusMethod · 0.45
UpdateMethod · 0.45
GetRadiusMethod · 0.45

Tested by

no test coverage detected