//============================================================================ // 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 #include #include #include namespace { template void BuildForType(vtkm::cont::CellLocatorGeneral& locator, LocatorVariantType& locatorVariant) { constexpr vtkm::IdComponent LOCATOR_INDEX = LocatorVariantType::template GetIndexOf(); if (locatorVariant.GetIndex() != LOCATOR_INDEX) { locatorVariant = LocatorImplType{}; } LocatorImplType& locatorImpl = locatorVariant.template Get(); locatorImpl.SetCellSet(locator.GetCellSet()); locatorImpl.SetCoordinates(locator.GetCoordinates()); locatorImpl.Update(); } } // anonymous namespace namespace vtkm { namespace cont { VTKM_CONT void CellLocatorGeneral::Build() { using StructuredCellSet = vtkm::cont::CellSetStructured<3>; using UniformCoordinates = vtkm::cont::ArrayHandleUniformPointCoordinates; using RectilinearCoordinates = vtkm::cont::ArrayHandleCartesianProduct, vtkm::cont::ArrayHandle, vtkm::cont::ArrayHandle>; vtkm::cont::DynamicCellSet cellSet = this->GetCellSet(); vtkm::cont::CoordinateSystem coords = this->GetCoordinates(); if (cellSet.IsType() && coords.GetData().IsType()) { BuildForType(*this, this->LocatorImpl); } else if (cellSet.IsType() && coords.GetData().IsType()) { BuildForType(*this, this->LocatorImpl); } else { BuildForType(*this, this->LocatorImpl); } } struct CellLocatorGeneral::PrepareFunctor { template ExecObjType operator()(LocatorType&& locator, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const { return locator.PrepareForExecution(device, token); } }; CellLocatorGeneral::ExecObjType CellLocatorGeneral::PrepareForExecution( vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) const { this->Update(); return this->LocatorImpl.CastAndCall(PrepareFunctor{}, device, token); } } } // vtkm::cont