//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #include #include #include #include #include namespace vtkm { namespace cont { void CellLocatorRectilinearGrid::Build() { vtkm::cont::CoordinateSystem coords = this->GetCoordinates(); vtkm::cont::UnknownCellSet cellSet = this->GetCellSet(); if (!coords.GetData().IsType()) throw vtkm::cont::ErrorBadType("Coordinates are not rectilinear type."); if (cellSet.CanConvert()) { this->Is3D = false; vtkm::Vec celldims = cellSet.AsCellSet().GetSchedulingRange(vtkm::TopologyElementTagCell()); this->PlaneSize = celldims[0] * celldims[1]; this->RowSize = celldims[0]; } else if (cellSet.CanConvert()) { this->Is3D = true; vtkm::Vec celldims = cellSet.AsCellSet().GetSchedulingRange(vtkm::TopologyElementTagCell()); this->PlaneSize = celldims[0] * celldims[1]; this->RowSize = celldims[0]; } else { throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type."); } } vtkm::exec::CellLocatorRectilinearGrid CellLocatorRectilinearGrid::PrepareForExecution( vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const { this->Update(); using ExecObjType = vtkm::exec::CellLocatorRectilinearGrid; if (this->Is3D) { return ExecObjType(this->PlaneSize, this->RowSize, this->GetCellSet().AsCellSet(), this->GetCoordinates().GetData().template AsArrayHandle(), device, token); } else { return ExecObjType(this->PlaneSize, this->RowSize, this->GetCellSet().AsCellSet(), this->GetCoordinates().GetData().template AsArrayHandle(), device, token); } } } //namespace cont } //namespace vtkm