Accelerators/Vtkm/vtkmlib/CellSetConverters.cxx
// convert a cell array of a single type to a vtkm CellSetSingleType
convert a cell array of a single type to a vtkm CellSetSingleType
convert a cell array of a single type to a vtkm CellSetSingleType
vtkm::cont::DynamicCellSet ConvertSingleType(vtkCellArray* cells, int cellType,
                                             vtkIdType numberOfPoints)
{
  vtkm::cont::internal::Storage<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
      storage(cells);
  vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag> handle(
      storage);
  typedef vtkm::cont::vtkmCellSetSingleType CellSetType;
  switch (cellType)
  {
  case VTK_LINE:
  {
    CellSetType c(vtkm::CellShapeTagLine{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_HEXAHEDRON:
  {
    CellSetType c(vtkm::CellShapeTagHexahedron{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_VOXEL:
  {
    using SMPTypes = vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagTBB,
                                       vtkm::cont::DeviceAdapterTagOpenMP,
                                       vtkm::cont::DeviceAdapterTagSerial>;
    vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>
        fixedCells;
    fixedCells.Allocate(cells->GetSize());
    fixedCells.GetStorage().VTKArray()->DeepCopy(cells);
    RunReorder run(fixedCells.GetStorage().VTKArray(), cells->GetNumberOfCells());
    vtkm::cont::TryExecute(run, SMPTypes());
    CellSetType c(vtkm::CellShapeTagHexahedron{});
    c.Fill(numberOfPoints, fixedCells);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_QUAD:
  {
    CellSetType c(vtkm::CellShapeTagQuad{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_TETRA:
  {
    CellSetType c(vtkm::CellShapeTagTetra{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_TRIANGLE:
  {
    CellSetType c(vtkm::CellShapeTagTriangle{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_VERTEX:
  {
    CellSetType c(vtkm::CellShapeTagVertex{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_WEDGE:
  {
    CellSetType c(vtkm::CellShapeTagWedge{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  case VTK_PYRAMID:
  {
    CellSetType c(vtkm::CellShapeTagPyramid{});
    c.Fill(numberOfPoints, handle);
    return vtkm::cont::DynamicCellSet(c);
  }
  default:
    break;
  }
  return vtkm::cont::DynamicCellSet((CellSetType()));
}
vtkm :: cont :: DynamicCellSet ConvertSingleType ( vtkCellArray * cells , int cellType , vtkIdType numberOfPoints ) { vtkm :: cont :: internal :: Storage < vtkm :: Id , tovtkm :: vtkCellArrayContainerTag > storage ( cells ) ; vtkm :: cont :: ArrayHandle < vtkm :: Id , tovtkm :: vtkCellArrayContainerTag > handle ( storage ) ; typedef vtkm :: cont :: vtkmCellSetSingleType CellSetType ; switch ( cellType ) { case VTK_LINE : { CellSetType c ( vtkm :: CellShapeTagLine { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_HEXAHEDRON : { CellSetType c ( vtkm :: CellShapeTagHexahedron { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_VOXEL : { using SMPTypes = vtkm :: ListTagBase < vtkm :: cont :: DeviceAdapterTagTBB , vtkm :: cont :: DeviceAdapterTagOpenMP , vtkm :: cont :: DeviceAdapterTagSerial > ; vtkm :: cont :: ArrayHandle < vtkm :: Id , tovtkm :: vtkCellArrayContainerTag > fixedCells ; fixedCells . Allocate ( cells -> GetSize ( ) ) ; fixedCells . GetStorage ( ) . VTKArray ( ) -> DeepCopy ( cells ) ; RunReorder run ( fixedCells . GetStorage ( ) . VTKArray ( ) , cells -> GetNumberOfCells ( ) ) ; vtkm :: cont :: TryExecute ( run , SMPTypes ( ) ) ; CellSetType c ( vtkm :: CellShapeTagHexahedron { } ) ; c . Fill ( numberOfPoints , fixedCells ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_QUAD : { CellSetType c ( vtkm :: CellShapeTagQuad { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_TETRA : { CellSetType c ( vtkm :: CellShapeTagTetra { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_TRIANGLE : { CellSetType c ( vtkm :: CellShapeTagTriangle { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_VERTEX : { CellSetType c ( vtkm :: CellShapeTagVertex { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_WEDGE : { CellSetType c ( vtkm :: CellShapeTagWedge { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } case VTK_PYRAMID : { CellSetType c ( vtkm :: CellShapeTagPyramid { } ) ; c . Fill ( numberOfPoints , handle ) ; return vtkm :: cont :: DynamicCellSet ( c ) ; } default : break ; } return vtkm :: cont :: DynamicCellSet ( ( CellSetType ( ) ) ) ; }
convert a cell array of a single type to a vtkm CellSetSingleType
convert a cell array of a single type to a vtkm CellSetSingleType
// step 1, convert the integer into a tag type // step 2, wrap vtkCellArray in a custom array handle. The reason for the // wrapping is the stupid padding in the vtkCellArray that we need to work // around // need to switch on cellType //This is encountered when you have an unstructured grid that was //cleaned / thresholded from an image data. At that point VTK should //have converted to hex's as downstream the point coordinates can be //transformed and invalidate the voxel requirements //We need to construct a new array that has the correct ordering //divide the array by 4, gets the number of times we need to flip values // construct through vtkm so that the memory is properly // de-allocated when the DynamicCellSet is destroyed