ExplicitConnectivity can now use different storage backends.
ExplicitConnectivity can now use different storage backends to allow for cheaper representations of the data. For example a pool of triangles can now implicit handles for shape and num indices.
This commit is contained in:
parent
9eb84295fa
commit
ecec6945bf
@ -24,7 +24,7 @@ public:
|
||||
return nodesOfCellsConnectivity.GetNumberOfElements();
|
||||
}
|
||||
|
||||
ExplicitConnectivity &GetNodeToCellConnectivity()
|
||||
ExplicitConnectivity<> &GetNodeToCellConnectivity()
|
||||
{
|
||||
return nodesOfCellsConnectivity;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ExplicitConnectivity nodesOfCellsConnectivity;
|
||||
ExplicitConnectivity<> nodesOfCellsConnectivity;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,9 @@
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
template<typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
||||
typename IndiceStorageTag = VTKM_DEFAULT_STORAGE_TAG,
|
||||
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG >
|
||||
class ExplicitConnectivity
|
||||
{
|
||||
public:
|
||||
@ -135,9 +138,9 @@ public:
|
||||
/// Second method to add cells -- all at once.
|
||||
/// Assigns the array handles to the explicit connectivity. This is
|
||||
/// the way you can fill the memory from another system without copying
|
||||
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id> &cellTypes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity)
|
||||
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> &cellTypes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, IndiceStorageTag> &numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity)
|
||||
{
|
||||
this->Shapes = cellTypes;
|
||||
this->NumIndices = numIndices;
|
||||
@ -159,20 +162,32 @@ public:
|
||||
template <typename DeviceAdapterTag>
|
||||
struct ExecutionTypes
|
||||
{
|
||||
typedef vtkm::exec::ExplicitConnectivity<DeviceAdapterTag> ExecObjectType;
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> ShapeHandle;
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, IndiceStorageTag> IndiceHandle;
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> ConnectivityHandle;
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Id> MapCellToConnectivityHandle;
|
||||
|
||||
typedef typename ShapeHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst ShapePortalType;
|
||||
typedef typename IndiceHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst IndicePortalType;
|
||||
typedef typename ConnectivityHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst ConnectivityPortalType;
|
||||
typedef typename MapCellToConnectivityHandle::template ExecutionTypes<DeviceAdapterTag>::PortalConst MapConnectivityPortalType;
|
||||
|
||||
typedef vtkm::exec::ExplicitConnectivity<ShapePortalType,
|
||||
IndicePortalType,
|
||||
ConnectivityPortalType,
|
||||
MapConnectivityPortalType
|
||||
> ExecObjectType;
|
||||
};
|
||||
|
||||
template<typename DeviceAdapterTag>
|
||||
typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType
|
||||
PrepareForInput(DeviceAdapterTag tag) const
|
||||
{
|
||||
vtkm::exec::ExplicitConnectivity<DeviceAdapterTag> obj;
|
||||
obj.Shapes = Shapes.PrepareForInput(tag);
|
||||
obj.NumIndices = NumIndices.PrepareForInput(tag);
|
||||
obj.Connectivity = Connectivity.PrepareForInput(tag);
|
||||
obj.MapCellToConnectivityIndex = MapCellToConnectivityIndex.PrepareForInput(tag);
|
||||
|
||||
return obj;
|
||||
typedef typename ExecutionTypes<DeviceAdapterTag>::ExecObjectType ExecObjType;
|
||||
return ExecObjType(this->Shapes.PrepareForInput(tag),
|
||||
this->NumIndices.PrepareForInput(tag),
|
||||
this->Connectivity.PrepareForInput(tag),
|
||||
this->MapCellToConnectivityIndex.PrepareForInput(tag));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -194,10 +209,10 @@ public:
|
||||
private:
|
||||
vtkm::Id ConnectivityLength;
|
||||
vtkm::Id NumShapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> Shapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> NumIndices;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> Connectivity;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> MapCellToConnectivityIndex;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, ShapeStorageTag> Shapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, IndiceStorageTag> NumIndices;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> Connectivity;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> MapCellToConnectivityIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ MakeTestDataSet::Make3DExplicitDataSet0()
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetExplicit > cs(
|
||||
new vtkm::cont::CellSetExplicit("cells", 2));
|
||||
vtkm::cont::ExplicitConnectivity &ec = cs->nodesOfCellsConnectivity;
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->nodesOfCellsConnectivity;
|
||||
ec.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
@ -189,7 +189,7 @@ MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetExplicit > cs(
|
||||
new vtkm::cont::CellSetExplicit("cells", 2));
|
||||
vtkm::cont::ExplicitConnectivity &ec = cs->nodesOfCellsConnectivity;
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->nodesOfCellsConnectivity;
|
||||
|
||||
ec.PrepareToAddCells(2, 7);
|
||||
ec.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
||||
|
@ -27,12 +27,29 @@
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
|
||||
template<typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
template<typename ShapePortalType,
|
||||
typename IndicePortalType,
|
||||
typename ConnectivityPortalType,
|
||||
typename MapConnectivityPortalType
|
||||
>
|
||||
class ExplicitConnectivity
|
||||
{
|
||||
public:
|
||||
ExplicitConnectivity() {}
|
||||
|
||||
ExplicitConnectivity(const ShapePortalType& shapePortal,
|
||||
const IndicePortalType& indicePortal,
|
||||
const ConnectivityPortalType& connPortal,
|
||||
const MapConnectivityPortalType& mapConnPortal
|
||||
)
|
||||
: Shapes(shapePortal),
|
||||
NumIndices(indicePortal),
|
||||
Connectivity(connPortal),
|
||||
MapCellToConnectivityIndex(mapConnPortal)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Id GetNumberOfElements()
|
||||
{
|
||||
@ -61,11 +78,11 @@ public:
|
||||
ids[i] = Connectivity.Get(start+i);
|
||||
}
|
||||
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id>::template ExecutionTypes<Device>::PortalConst PortalType;
|
||||
PortalType Shapes;
|
||||
PortalType NumIndices;
|
||||
PortalType Connectivity;
|
||||
PortalType MapCellToConnectivityIndex;
|
||||
private:
|
||||
ShapePortalType Shapes;
|
||||
IndicePortalType NumIndices;
|
||||
ConnectivityPortalType Connectivity;
|
||||
MapConnectivityPortalType MapCellToConnectivityIndex;
|
||||
};
|
||||
|
||||
} // namespace exec
|
||||
|
Loading…
Reference in New Issue
Block a user