Commit 5a0333fe authored by Roxana Bujack's avatar Roxana Bujack
Browse files

provide the function getcellshapes to the cellsets except permutations

parent 7459bd94
......@@ -171,6 +171,8 @@ public:
VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id cellid) const override;
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapesStorageTag> GetCellShapes() const;
template <vtkm::IdComponent NumIndices>
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, NumIndices>& ids) const;
......
......@@ -190,6 +190,13 @@ vtkm::UInt8 CellSetExplicit<SST, CST, OST>
return this->ShapesReadPortal().Get(cellid);
}
template <typename SST, typename CST, typename OST>
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::UInt8, SST> CellSetExplicit<SST, CST, OST>
::GetCellShapes() const
{
return this->Data->CellPointIds.Shapes;
  • Since you are already ArrayCopy to ArrayHandle in other cases, why don't you do that here as well. Then the return type will be the same.

  • Yes! Great idea! I did that. Now we have a consistent function.

    From your comment, I read that you think it is worth following this path, right? Then I will untangle the CellSetPermutation and repeat the same for the other necessary arrays (numIndices, offset) now, OK?

    Best, Roxana

  • See the email thread on this top (GetCellShapes) with Ken and his feedback.

Please register or sign in to reply
}
template <typename SST, typename CST, typename OST>
template <vtkm::IdComponent NumVecIndices>
......
......@@ -163,6 +163,13 @@ vtkm::UInt8 CellSetExtrude::GetCellShape(vtkm::Id) const
return vtkm::CellShapeTagWedge::Id;
}
vtkm::cont::ArrayHandle<vtkm::UInt8> CellSetExtrude::GetCellShapes() const
{
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleConstant <vtkm::UInt8> (vtkm::CellShapeTagWedge::Id, this->GetNumberOfCells()), shapes);
return shapes;
}
vtkm::IdComponent CellSetExtrude::GetNumberOfPointsInCell(vtkm::Id) const
{
return 6;
......
......@@ -80,6 +80,8 @@ public:
VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const;
vtkm::UInt8 GetCellShape(vtkm::Id id) const override;
vtkm::cont::ArrayHandle<vtkm::UInt8> GetCellShapes() const;
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id id) const override;
void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override;
......
......@@ -12,7 +12,10 @@
#include <vtkm/cont/vtkm_cont_export.h>
#include <vtkm/TopologyElementTag.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/ErrorBadType.h>
......@@ -76,6 +79,13 @@ public:
return static_cast<vtkm::UInt8>(this->Structure.GetCellShape());
}
vtkm::cont::ArrayHandle<vtkm::UInt8> GetCellShapes() const
{
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleConstant <vtkm::UInt8> (static_cast<vtkm::UInt8>(this->Structure.GetCellShape()), this->GetNumberOfCells()), shapes);
return shapes;
}
void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override
{
auto asVec = this->Structure.GetPointsOfCell(id);
......
......@@ -65,16 +65,20 @@ struct TransferCellsFunctor
template <typename T>
VTKM_CONT void operator()(const T& cellSetIn, vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes, vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices, vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, vtkm::Id pointStartIndex) const
{
auto shapes2 = cellSetIn.GetCellShapes();
vtkm::Id cellStartIndex = shapes.GetNumberOfValues();
vtkm::Id connectivityStartIndex = connectivity.GetNumberOfValues();
shapes.Allocate(cellStartIndex + cellSetIn.GetNumberOfCells(), vtkm::CopyFlag::On);
numIndices.Allocate(cellStartIndex + cellSetIn.GetNumberOfCells(), vtkm::CopyFlag::On);
vtkm::cont::Invoker invoke;
invoke(vtkm::worklet::TransferArrayWorklet{cellStartIndex}, cellSetIn.GetCellShapes(), shapes);
// transfer shapes and numIndizes
vtkm::Id numberOfConnectivity = connectivityStartIndex;
for (unsigned int c = 0; c < cellSetIn.GetNumberOfCells(); c++)
{
shapes.WritePortal().Set(cellStartIndex + c, cellSetIn.GetCellShape(c));
// shapes.WritePortal().Set(cellStartIndex + c, cellSetIn.GetCellShape(c));
numIndices.WritePortal().Set(cellStartIndex + c, cellSetIn.GetNumberOfPointsInCell(c));
numberOfConnectivity += cellSetIn.GetNumberOfPointsInCell(c);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment