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
|
#define vtk_m_cont_CellSetExplicit_h
|
||||||
|
|
||||||
#include <vtkm/CellShape.h>
|
#include <vtkm/CellShape.h>
|
||||||
#include <vtkm/TopologyElementTag.h>
|
|
||||||
#include <vtkm/cont/CellSet.h>
|
#include <vtkm/cont/CellSet.h>
|
||||||
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
|
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
|
||||||
#include <vtkm/exec/ConnectivityExplicit.h>
|
#include <vtkm/exec/ConnectivityExplicit.h>
|
||||||
|
#include <vtkm/TopologyElementTag.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -56,17 +56,25 @@ struct CellSetExplicitConnectivityChooser
|
|||||||
#define VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
#define VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
||||||
#endif
|
#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,
|
template<typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
|
||||||
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_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
|
class CellSetExplicit : public CellSet
|
||||||
{
|
{
|
||||||
template<typename FromTopology, typename ToTopology>
|
template<typename FromTopology, typename ToTopology>
|
||||||
struct ConnectivityChooser
|
struct ConnectivityChooser
|
||||||
{
|
{
|
||||||
|
typedef CellSetExplicit< ShapeStorageTag,
|
||||||
|
NumIndicesStorageTag,
|
||||||
|
ConnectivityStorageTag,
|
||||||
|
OffsetsStorageTag > CellSetExplicitType;
|
||||||
typedef typename detail::CellSetExplicitConnectivityChooser<
|
typedef typename detail::CellSetExplicitConnectivityChooser<
|
||||||
CellSetExplicit<
|
CellSetExplicitType,
|
||||||
ShapeStorageTag,NumIndicesStorageTag,ConnectivityStorageTag>,
|
|
||||||
FromTopology,
|
FromTopology,
|
||||||
ToTopology>::ConnectivityType ConnectivityType;
|
ToTopology>::ConnectivityType ConnectivityType;
|
||||||
};
|
};
|
||||||
@ -185,7 +193,8 @@ public:
|
|||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void FillViaCopy(const std::vector<vtkm::UInt8> &cellTypes,
|
void FillViaCopy(const std::vector<vtkm::UInt8> &cellTypes,
|
||||||
const std::vector<vtkm::IdComponent> &numIndices,
|
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()) );
|
this->PointToCell.Shapes.Allocate( static_cast<vtkm::UInt8>(cellTypes.size()) );
|
||||||
@ -204,6 +213,20 @@ public:
|
|||||||
this->PointToCell.Connectivity.GetPortalControl()));
|
this->PointToCell.Connectivity.GetPortalControl()));
|
||||||
|
|
||||||
this->PointToCell.ElementsValid = true;
|
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;
|
this->PointToCell.IndexOffsetsValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,14 +235,25 @@ public:
|
|||||||
/// the way you can fill the memory from another system without copying
|
/// the way you can fill the memory from another system without copying
|
||||||
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
|
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
|
||||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
|
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.Shapes = cellTypes;
|
||||||
this->PointToCell.NumIndices = numIndices;
|
this->PointToCell.NumIndices = numIndices;
|
||||||
this->PointToCell.Connectivity = connectivity;
|
this->PointToCell.Connectivity = connectivity;
|
||||||
|
|
||||||
this->PointToCell.ElementsValid = true;
|
this->PointToCell.ElementsValid = true;
|
||||||
this->PointToCell.IndexOffsetsValid = false;
|
|
||||||
|
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>
|
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||||
@ -271,8 +305,9 @@ public:
|
|||||||
void BuildConnectivity(FromTopology, ToTopology) const
|
void BuildConnectivity(FromTopology, ToTopology) const
|
||||||
{
|
{
|
||||||
typedef CellSetExplicit<ShapeStorageTag,
|
typedef CellSetExplicit<ShapeStorageTag,
|
||||||
NumIndicesStorageTag,
|
NumIndicesStorageTag,
|
||||||
ConnectivityStorageTag> CSE;
|
ConnectivityStorageTag,
|
||||||
|
OffsetsStorageTag> CSE;
|
||||||
CSE *self = const_cast<CSE*>(this);
|
CSE *self = const_cast<CSE*>(this);
|
||||||
|
|
||||||
self->CreateConnectivity(FromTopology(), ToTopology());
|
self->CreateConnectivity(FromTopology(), ToTopology());
|
||||||
@ -398,7 +433,7 @@ public:
|
|||||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
typename ConnectivityChooser<
|
typename ConnectivityChooser<
|
||||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::
|
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::
|
||||||
ConnectivityType PointToCell;
|
ConnectivityType PointToCell;
|
||||||
@ -408,6 +443,7 @@ private:
|
|||||||
typename ConnectivityChooser<
|
typename ConnectivityChooser<
|
||||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint>::
|
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint>::
|
||||||
ConnectivityType CellToPoint;
|
ConnectivityType CellToPoint;
|
||||||
|
private:
|
||||||
|
|
||||||
// A set of overloaded methods to get the connectivity from a pair of
|
// A set of overloaded methods to get the connectivity from a pair of
|
||||||
// topology element types.
|
// topology element types.
|
||||||
@ -445,14 +481,14 @@ private:
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<typename Storage1, typename Storage2, typename Storage3>
|
template<typename Storage1, typename Storage2, typename Storage3, typename Storage4>
|
||||||
struct CellSetExplicitConnectivityChooser<
|
struct CellSetExplicitConnectivityChooser<
|
||||||
vtkm::cont::CellSetExplicit<Storage1,Storage2,Storage3>,
|
vtkm::cont::CellSetExplicit<Storage1,Storage2,Storage3,Storage4>,
|
||||||
vtkm::TopologyElementTagPoint,
|
vtkm::TopologyElementTagPoint,
|
||||||
vtkm::TopologyElementTagCell>
|
vtkm::TopologyElementTagCell>
|
||||||
{
|
{
|
||||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<
|
typedef vtkm::cont::internal::ConnectivityExplicitInternals<
|
||||||
Storage1,Storage2,Storage3> ConnectivityType;
|
Storage1,Storage2,Storage3,Storage4> ConnectivityType;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
Loading…
Reference in New Issue
Block a user