Fetch explicit indices as vec-like

Previously when you fetched the indices from an explicit cell set, you
would get back a Vec of a fixed length an expected to use a subset of
it. Now you get back a Vec-like object that reports the exact length.

This Vec-like is implemented with VecFromPortal, so that the data does
not need to be copied to the stack. Rather, it is pulled from memory as
requested.
This commit is contained in:
Kenneth Moreland 2015-08-13 18:10:24 -06:00
parent c9d95298b0
commit 2394de8c95
2 changed files with 18 additions and 18 deletions

@ -20,9 +20,10 @@
#ifndef vtk_m_exec_ConnectivityExplicit_h
#define vtk_m_exec_ConnectivityExplicit_h
#include <vtkm/CellType.h>
#include <vtkm/Types.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/exec/internal/VecFromPortal.h>
namespace vtkm {
namespace exec {
@ -53,35 +54,34 @@ public:
VTKM_EXEC_EXPORT
vtkm::Id GetNumberOfElements() const
{
return Shapes.GetNumberOfValues();
return this->Shapes.GetNumberOfValues();
}
VTKM_EXEC_EXPORT
vtkm::Id GetNumberOfIndices(vtkm::Id index) const
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const
{
return NumIndices.Get(index);
// Should the NumIndices array be typed as vtkm::IdComponent instead of
// vtkm::Id? (NumIndices is really defined in
// vtkm::cont::internal::ConnectivityExplicitInternals.)
return static_cast<vtkm::IdComponent>(this->NumIndices.Get(index));
}
VTKM_EXEC_EXPORT
vtkm::Id GetCellShape(vtkm::Id index) const
vtkm::CellType GetCellShape(vtkm::Id index) const
{
return Shapes.Get(index);
// Likewise, should Shapes be vtkm::Id or something smaller?
return static_cast<vtkm::CellType>(this->Shapes.Get(index));
}
// TODO: This becomes a Vec-like
typedef vtkm::Vec<vtkm::Id,8> IndicesType;
typedef vtkm::exec::internal::VecFromPortal<ConnectivityPortalType>
IndicesType;
VTKM_EXEC_EXPORT
IndicesType GetIndices(vtkm::Id index) const
{
vtkm::Id n = GetNumberOfIndices(index);
IndicesType ids;
vtkm::Id start = IndexOffset.Get(index);
for (vtkm::IdComponent i=0; i<n && i<8; i++)
{
ids[i] = Connectivity.Get(start+i);
}
return ids;
vtkm::Id offset = this->IndexOffset.Get(index);
vtkm::IdComponent length = this->GetNumberOfIndices(index);
return IndicesType(this->Connectivity, length, offset);
}
private:

@ -65,7 +65,7 @@ public:
}
VTKM_EXEC_EXPORT
vtkm::Id GetNumberOfIndices(vtkm::Id index) const {
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const {
return Helper::GetNumberOfIndices(this->Internals, index);
}
// This needs some thought. What does cell shape mean when the to topology