vtk-m/vtkm/cont/CellLocator.h
ayenpure 671987148f Adding working implementation of BIH with test
- Uses smart pointers
  - need to get rid of them
2018-06-13 15:08:15 -07:00

91 lines
2.0 KiB
C++

#ifndef vtk_m_cont_CellLocator_h
#define vtk_m_cont_CellLocator_h
#include <vtkm/Types.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ExecutionObjectBase.h>
namespace vtkm
{
namespace exec
{
// This will actually be used in the Execution Environment.
// As this object is returned by the PrepareForExecution on
// the CellLocator we need it to be covarient, and this acts
// like a base class.
class CellLocator
{
public:
VTKM_EXEC
virtual void FindCell(const vtkm::Vec<vtkm::FloatDefault, 3>& point,
vtkm::Id& cellId,
vtkm::Vec<vtkm::FloatDefault, 3>& parametric,
const vtkm::exec::FunctorBase& worklet) const = 0;
};
} // namespace exec
namespace cont
{
class CellLocator : public ExecutionObjectBase
{
public:
CellLocator()
: Dirty(true)
{
}
vtkm::cont::DynamicCellSet GetCellSet() const { return CellSet; }
void SetCellSet(const vtkm::cont::DynamicCellSet& cellSet)
{
CellSet = cellSet;
Dirty = true;
}
vtkm::cont::CoordinateSystem GetCoords() const { return Coords; }
void SetCoords(const vtkm::cont::CoordinateSystem& coords)
{
Coords = coords;
Dirty = true;
}
//This is going to need a TryExecute
virtual void Build() = 0;
void Update()
{
if (Dirty)
Build();
Dirty = false;
}
template <typename DeviceAdapter>
VTKM_CONT std::shared_ptr<vtkm::exec::CellLocator> PrepareForExecution(DeviceAdapter) const
{
vtkm::cont::DeviceAdapterId deviceId = vtkm::cont::DeviceAdapterTraits<DeviceAdapter>::GetId();
return PrepareForExecutionOnDevice(deviceId);
}
protected:
VTKM_CONT virtual std::shared_ptr<vtkm::exec::CellLocator> PrepareForExecutionOnDevice(
vtkm::cont::DeviceAdapterId& device) const = 0;
private:
vtkm::cont::DynamicCellSet CellSet;
vtkm::cont::CoordinateSystem Coords;
bool Dirty;
};
} // namespace cont
} // namespace vtkm
#endif // vtk_m_cont_CellLocator_h