mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 18:45:43 +00:00
CellSetExplicit has userdefined offset storage.
This commit is contained in:
parent
45ad63c770
commit
f04ea6d72e
@ -21,10 +21,10 @@
|
||||
#define vtk_m_cont_CellSetExplicit_h
|
||||
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
|
||||
#include <vtkm/exec/ConnectivityExplicit.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
@ -56,17 +56,25 @@ struct CellSetExplicitConnectivityChooser
|
||||
#define VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
||||
#endif
|
||||
|
||||
#ifndef VTKM_DEFAULT_OFFSETS_STORAGE_TAG
|
||||
#define VTKM_DEFAULT_OFFSETS_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
||||
#endif
|
||||
|
||||
template<typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
|
||||
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG,
|
||||
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG >
|
||||
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
|
||||
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG >
|
||||
class CellSetExplicit : public CellSet
|
||||
{
|
||||
template<typename FromTopology, typename ToTopology>
|
||||
struct ConnectivityChooser
|
||||
{
|
||||
typedef CellSetExplicit< ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag > CellSetExplicitType;
|
||||
typedef typename detail::CellSetExplicitConnectivityChooser<
|
||||
CellSetExplicit<
|
||||
ShapeStorageTag,NumIndicesStorageTag,ConnectivityStorageTag>,
|
||||
CellSetExplicitType,
|
||||
FromTopology,
|
||||
ToTopology>::ConnectivityType ConnectivityType;
|
||||
};
|
||||
@ -185,7 +193,8 @@ public:
|
||||
VTKM_CONT_EXPORT
|
||||
void FillViaCopy(const std::vector<vtkm::UInt8> &cellTypes,
|
||||
const std::vector<vtkm::IdComponent> &numIndices,
|
||||
const std::vector<vtkm::Id> &connectivity)
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::vector<vtkm::Id> &offsets = std::vector<vtkm::Id>() )
|
||||
{
|
||||
|
||||
this->PointToCell.Shapes.Allocate( static_cast<vtkm::UInt8>(cellTypes.size()) );
|
||||
@ -204,6 +213,20 @@ public:
|
||||
this->PointToCell.Connectivity.GetPortalControl()));
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
|
||||
if(offsets.size() == cellTypes.size())
|
||||
{
|
||||
this->PointToCell.IndexOffsets.Allocate( static_cast<vtkm::Id>(offsets.size()) );
|
||||
std::copy(offsets.begin(), offsets.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.IndexOffsets.GetPortalControl()));
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
}
|
||||
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
}
|
||||
|
||||
@ -212,15 +235,26 @@ public:
|
||||
/// the way you can fill the memory from another system without copying
|
||||
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity)
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag> &offsets
|
||||
= vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>() )
|
||||
{
|
||||
this->PointToCell.Shapes = cellTypes;
|
||||
this->PointToCell.NumIndices = numIndices;
|
||||
this->PointToCell.Connectivity = connectivity;
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
|
||||
if(offsets.GetNumberOfValues() == cellTypes.GetNumberOfValues())
|
||||
{
|
||||
this->PointToCell.IndexOffsets = offsets;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||
struct ExecutionTypes
|
||||
@ -272,7 +306,8 @@ public:
|
||||
{
|
||||
typedef CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag> CSE;
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag> CSE;
|
||||
CSE *self = const_cast<CSE*>(this);
|
||||
|
||||
self->CreateConnectivity(FromTopology(), ToTopology());
|
||||
@ -398,7 +433,7 @@ public:
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
typename ConnectivityChooser<
|
||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::
|
||||
ConnectivityType PointToCell;
|
||||
@ -408,6 +443,7 @@ private:
|
||||
typename ConnectivityChooser<
|
||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint>::
|
||||
ConnectivityType CellToPoint;
|
||||
private:
|
||||
|
||||
// A set of overloaded methods to get the connectivity from a pair of
|
||||
// topology element types.
|
||||
@ -445,14 +481,14 @@ private:
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Storage1, typename Storage2, typename Storage3>
|
||||
template<typename Storage1, typename Storage2, typename Storage3, typename Storage4>
|
||||
struct CellSetExplicitConnectivityChooser<
|
||||
vtkm::cont::CellSetExplicit<Storage1,Storage2,Storage3>,
|
||||
vtkm::cont::CellSetExplicit<Storage1,Storage2,Storage3,Storage4>,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>
|
||||
{
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<
|
||||
Storage1,Storage2,Storage3> ConnectivityType;
|
||||
Storage1,Storage2,Storage3,Storage4> ConnectivityType;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
Loading…
Reference in New Issue
Block a user