2019-03-20 23:38:50 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2019-03-20 23:38:50 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
2019-03-28 12:27:37 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
|
|
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
2019-03-20 23:38:50 +00:00
|
|
|
#include <vtkm/cont/CellLocatorRectilinearGrid.h>
|
2019-03-28 12:27:37 +00:00
|
|
|
#include <vtkm/cont/CellSetStructured.h>
|
2019-03-20 23:38:50 +00:00
|
|
|
|
|
|
|
#include <vtkm/exec/CellLocatorRectilinearGrid.h>
|
|
|
|
|
2019-03-28 12:27:37 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
|
|
|
void CellLocatorRectilinearGrid::Build()
|
2019-03-20 23:38:50 +00:00
|
|
|
{
|
|
|
|
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
|
|
|
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
|
|
|
|
|
|
|
if (!coords.GetData().IsType<RectilinearType>())
|
2019-08-08 16:15:28 +00:00
|
|
|
throw vtkm::cont::ErrorBadType("Coordinates are not rectilinear type.");
|
2019-03-20 23:38:50 +00:00
|
|
|
|
2019-07-11 17:45:30 +00:00
|
|
|
if (cellSet.IsSameType(Structured2DType()))
|
|
|
|
{
|
|
|
|
this->Is3D = false;
|
|
|
|
vtkm::Vec<vtkm::Id, 2> celldims =
|
|
|
|
cellSet.Cast<Structured2DType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
|
|
|
this->PlaneSize = celldims[0] * celldims[1];
|
|
|
|
this->RowSize = celldims[0];
|
|
|
|
}
|
|
|
|
else if (cellSet.IsSameType(Structured3DType()))
|
|
|
|
{
|
|
|
|
this->Is3D = true;
|
|
|
|
vtkm::Vec<vtkm::Id, 3> celldims =
|
|
|
|
cellSet.Cast<Structured3DType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
|
|
|
this->PlaneSize = celldims[0] * celldims[1];
|
|
|
|
this->RowSize = celldims[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-08 16:15:28 +00:00
|
|
|
throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type.");
|
2019-07-11 17:45:30 +00:00
|
|
|
}
|
2019-03-20 23:38:50 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 15:32:01 +00:00
|
|
|
vtkm::exec::CellLocatorRectilinearGrid CellLocatorRectilinearGrid::PrepareForExecution(
|
2020-01-21 20:18:03 +00:00
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token) const
|
2019-03-20 23:38:50 +00:00
|
|
|
{
|
2020-11-11 22:29:48 +00:00
|
|
|
this->Update();
|
|
|
|
|
2020-09-22 15:32:01 +00:00
|
|
|
using ExecObjType = vtkm::exec::CellLocatorRectilinearGrid;
|
|
|
|
|
2019-07-11 17:45:30 +00:00
|
|
|
if (this->Is3D)
|
|
|
|
{
|
2020-09-22 15:32:01 +00:00
|
|
|
return ExecObjType(this->PlaneSize,
|
|
|
|
this->RowSize,
|
|
|
|
this->GetCellSet().template Cast<Structured3DType>(),
|
|
|
|
this->GetCoordinates().GetData().template AsArrayHandle<RectilinearType>(),
|
|
|
|
device,
|
|
|
|
token);
|
2019-07-11 17:45:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-22 15:32:01 +00:00
|
|
|
return ExecObjType(this->PlaneSize,
|
|
|
|
this->RowSize,
|
|
|
|
this->GetCellSet().template Cast<Structured2DType>(),
|
|
|
|
this->GetCoordinates().GetData().template AsArrayHandle<RectilinearType>(),
|
|
|
|
device,
|
|
|
|
token);
|
2019-03-20 23:38:50 +00:00
|
|
|
}
|
2019-03-28 12:27:37 +00:00
|
|
|
}
|
2020-09-22 15:32:01 +00:00
|
|
|
|
2019-04-01 20:25:51 +00:00
|
|
|
} //namespace cont
|
|
|
|
} //namespace vtkm
|