diff --git a/vtkm/exec/CellLocatorRectilinearGrid.h b/vtkm/exec/CellLocatorRectilinearGrid.h index 228f41df9..cc131d23c 100644 --- a/vtkm/exec/CellLocatorRectilinearGrid.h +++ b/vtkm/exec/CellLocatorRectilinearGrid.h @@ -63,34 +63,33 @@ public: DeviceAdapter) : PlaneSize(planeSize) , RowSize(rowSize) + , CellSet(cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType())) + , Coords(coords.PrepareForInput(DeviceAdapter())) + , PointDimensions(cellSet.GetPointDimensions()) { - CellSet = cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType()); - Coords = coords.PrepareForInput(DeviceAdapter()); + this->AxisPortals[0] = Coords.GetFirstPortal(); + this->AxisPortals[1] = Coords.GetSecondPortal(); + this->AxisPortals[2] = Coords.GetThirdPortal(); - PointDimensions = CellSet.GetPointDimensions(); + this->MinPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(0); + this->MinPoint[1] = coords.GetPortalConstControl().GetSecondPortal().Get(0); + this->MinPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(0); - AxisPortals[0] = Coords.GetFirstPortal(); - AxisPortals[1] = Coords.GetSecondPortal(); - AxisPortals[2] = Coords.GetThirdPortal(); - - MinPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(0); - MinPoint[1] = coords.GetPortalConstControl().GetSecondPortal().Get(0); - MinPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(0); - - MaxPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(PointDimensions[0] - 1); - MaxPoint[1] = coords.GetPortalConstControl().GetSecondPortal().Get(PointDimensions[1] - 1); - MaxPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(PointDimensions[2] - 1); + this->MaxPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(PointDimensions[0] - 1); + this->MaxPoint[1] = + coords.GetPortalConstControl().GetSecondPortal().Get(PointDimensions[1] - 1); + this->MaxPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(PointDimensions[2] - 1); } VTKM_EXEC inline bool IsInside(const vtkm::Vec& point) const { bool inside = true; - if (point[0] < MinPoint[0] || point[0] > MaxPoint[0]) + if (point[0] < this->MinPoint[0] || point[0] > this->MaxPoint[0]) inside = false; - if (point[1] < MinPoint[1] || point[1] > MaxPoint[1]) + if (point[1] < this->MinPoint[1] || point[1] > this->MaxPoint[1]) inside = false; - if (point[2] < MinPoint[2] || point[2] > MaxPoint[2]) + if (point[2] < this->MinPoint[2] || point[2] > this->MaxPoint[2]) inside = false; return inside; } @@ -106,6 +105,7 @@ public: cellId = -1; return; } + // Get the Cell Id from the point. vtkm::Vec logicalCell(0, 0, 0); for (vtkm::Int32 dim = 0; dim < 3; ++dim) @@ -122,9 +122,9 @@ public: } bool found = false; - vtkm::FloatDefault minVal = AxisPortals[dim].Get(logicalCell[dim]); + vtkm::FloatDefault minVal = this->AxisPortals[dim].Get(logicalCell[dim]); const vtkm::Id searchDir = (point[dim] - minVal >= 0.f) ? 1 : -1; - vtkm::FloatDefault maxVal = AxisPortals[dim].Get(logicalCell[dim] + 1); + vtkm::FloatDefault maxVal = this->AxisPortals[dim].Get(logicalCell[dim] + 1); while (!found) { @@ -136,7 +136,7 @@ public: logicalCell[dim] += searchDir; vtkm::Id nextCellId = searchDir == 1 ? logicalCell[dim] + 1 : logicalCell[dim]; - vtkm::FloatDefault next = AxisPortals[dim].Get(nextCellId); + vtkm::FloatDefault next = this->AxisPortals[dim].Get(nextCellId); if (searchDir == 1) { minVal = maxVal; @@ -151,14 +151,14 @@ public: } // Get the actual cellId, from the logical cell index of the cell - cellId = logicalCell[2] * PlaneSize + logicalCell[1] * RowSize + logicalCell[0]; + cellId = logicalCell[2] * this->PlaneSize + logicalCell[1] * this->RowSize + logicalCell[0]; bool success = false; using IndicesType = typename CellSetPortal::IndicesType; - IndicesType cellPointIndices = CellSet.GetIndices(cellId); + IndicesType cellPointIndices = this->CellSet.GetIndices(cellId); vtkm::VecFromPortalPermute cellPoints(&cellPointIndices, Coords); - auto cellShape = CellSet.GetCellShape(cellId); + auto cellShape = this->CellSet.GetCellShape(cellId); // Get Parametric Coordinates from the cell, for the point. parametric = vtkm::exec::WorldCoordinatesToParametricCoordinates( cellPoints, point, cellShape, success, worklet);