diff --git a/vtkm/cont/PointLocatorUniformGrid.h b/vtkm/cont/PointLocatorUniformGrid.h index 7bc44e66f..62e617eed 100644 --- a/vtkm/cont/PointLocatorUniformGrid.h +++ b/vtkm/cont/PointLocatorUniformGrid.h @@ -95,7 +95,7 @@ public: using Algorithm = vtkm::cont::DeviceAdapterAlgorithm; // Save training data points. - //Algorithm::Copy(coords, _Coords); + Algorithm::Copy(self.GetCoords().GetData(), self.coords); // generate unique id for each input point vtkm::cont::ArrayHandleCounting pointCounting( diff --git a/vtkm/cont/testing/TestingPointLocatorUniformGrid.h b/vtkm/cont/testing/TestingPointLocatorUniformGrid.h index a72656e69..d520a2b84 100644 --- a/vtkm/cont/testing/TestingPointLocatorUniformGrid.h +++ b/vtkm/cont/testing/TestingPointLocatorUniformGrid.h @@ -78,7 +78,6 @@ public: } }; -#if 1 class PointLocatorUniformGridWorklet : public vtkm::worklet::WorkletMapField { public: @@ -102,7 +101,6 @@ public: locator->FindNearestNeighbor(qc, nnIdOut, nnDis); }; }; -#endif template class TestingPointLocatorUniformGrid @@ -111,17 +109,8 @@ public: using Algorithm = vtkm::cont::DeviceAdapterAlgorithm; void TestTest() const { - - // TODO: locator needs to be a point to have runtime polymorphism. - //vtkm::cont::PointLocator * locator = new vtkm::cont::PointLocatorUniformGrid( - // { 0.0f, 0.0f, 0.0f }, { 10.0f, 10.0f, 10.0f }, { 5, 5, 5 }); - vtkm::cont::PointLocatorUniformGrid locator( - { 0.0f, 0.0f, 0.0f }, { 10.0f, 10.0f, 10.0f }, { 5, 5, 5 }); - // TODO: generate training points - locator.Build(); - - vtkm::Int32 nTrainingPoints = 1000; - vtkm::Int32 nTestingPoint = 1000; + vtkm::Int32 nTrainingPoints = 5; + vtkm::Int32 nTestingPoint = 1; std::vector> coordi; @@ -135,14 +124,17 @@ public: } auto coordi_Handle = vtkm::cont::make_ArrayHandle(coordi); -#if 0 - vtkm::cont::PointLocatorUniformGrid uniformGrid( - { 0.0f, 0.0f, 0.0f }, { 10.0f, 10.0f, 10.0f }, { 5, 5, 5 }); - uniformGrid.Build(coordi_Handle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); - auto locator = uniformGrid.PrepareForExecution(VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); -#endif + vtkm::cont::CoordinateSystem coord("points", coordi_Handle); - ///// randomly generate training points///// + // TODO: locator needs to be a pointer to have runtime polymorphism. + //vtkm::cont::PointLocator * locator = new vtkm::cont::PointLocatorUniformGrid( + // { 0.0f, 0.0f, 0.0f }, { 10.0f, 10.0f, 10.0f }, { 5, 5, 5 }); + vtkm::cont::PointLocatorUniformGrid locator( + { 0.0f, 0.0f, 0.0f }, { 10.0f, 10.0f, 10.0f }, { 5, 5, 5 }); + locator.SetCoords(coord); + locator.Build(); + + ///// randomly generate testing points///// std::vector> qcVec; for (vtkm::Int32 i = 0; i < nTestingPoint; i++) { @@ -152,14 +144,12 @@ public: vtkm::cont::ArrayHandle nnId_Handle; vtkm::cont::ArrayHandle nnDis_Handle; -#if 1 + PointLocatorUniformGridWorklet pointLocatorUniformGridWorklet; vtkm::worklet::DispatcherMapField locatorDispatcher(pointLocatorUniformGridWorklet); locatorDispatcher.Invoke(qc_Handle, locator, nnId_Handle, nnDis_Handle); -#endif -#if 0 // brute force vtkm::cont::ArrayHandle bfnnId_Handle; vtkm::cont::ArrayHandle bfnnDis_Handle; @@ -169,7 +159,7 @@ public: nnsbf3DDispatcher.Invoke( qc_Handle, vtkm::cont::make_ArrayHandle(coordi), bfnnId_Handle, bfnnDis_Handle); - ///// verfity search result ///// + ///// verify search result ///// bool passTest = true; for (vtkm::Int32 i = 0; i < nTestingPoint; i++) { @@ -185,9 +175,7 @@ public: passTest = false; } } - VTKM_TEST_ASSERT(passTest, "Uniform Grid NN search result incorrect."); -#endif } void operator()() const { this->TestTest(); } diff --git a/vtkm/exec/PointLocatorUniformGrid.h b/vtkm/exec/PointLocatorUniformGrid.h index 6c7d1e77f..0627a4b14 100644 --- a/vtkm/exec/PointLocatorUniformGrid.h +++ b/vtkm/exec/PointLocatorUniformGrid.h @@ -82,7 +82,7 @@ public: FloatDefault& distance) const override { std::cout << "FindNeareastNeighbor: " << queryPoint << std::endl; -#if 0 +#if 1 auto nlayers = vtkm::Max(vtkm::Max(Dims[0], Dims[1]), Dims[2]); vtkm::Vec xyz = (queryPoint - Min) / Dxdydz; @@ -106,7 +106,7 @@ public: for (auto k = minz; k <= maxz; k++) { if (i == (xyz[0] + layer) || i == (xyz[0] - layer) || j == (xyz[1] + layer) || - j == (xyz[1] - layer) || k == (xyz[2] + layer) || k == (xyz[2] - layer)) + j == (xyz[1] - layer) || k == (xyz[2] + layer) || k == (xyz[2] - layer)) { auto cellid = i + j * Dims[0] + k * Dims[0] * Dims[1]; auto lower = cellLower.Get(cellid);