2016-11-05 03:23:07 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2016-11-05 03:23:07 +00:00
|
|
|
// Copyright 2016 UT-Battelle, LLC.
|
|
|
|
// Copyright 2016 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2016-11-05 03:23:07 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_worklet_CellDeepCopy_h
|
|
|
|
#define vtk_m_worklet_CellDeepCopy_h
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandleConstant.h>
|
|
|
|
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
|
|
|
|
#include <vtkm/cont/CellSetExplicit.h>
|
2016-11-06 22:15:22 +00:00
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
2016-11-05 03:23:07 +00:00
|
|
|
|
|
|
|
#include <vtkm/worklet/DispatcherMapTopology.h>
|
|
|
|
#include <vtkm/worklet/WorkletMapTopology.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2016-11-05 03:23:07 +00:00
|
|
|
|
|
|
|
/// Container for worklets and helper methods to copy a cell set to a new
|
|
|
|
/// \c CellSetExplicit structure
|
|
|
|
///
|
|
|
|
struct CellDeepCopy
|
|
|
|
{
|
|
|
|
struct CountCellPoints : vtkm::worklet::WorkletMapPointToCell
|
|
|
|
{
|
2018-05-25 21:18:41 +00:00
|
|
|
using ControlSignature = void(CellSetIn inputTopology, FieldOut<> numPointsInCell);
|
|
|
|
using ExecutionSignature = _2(PointCount);
|
2016-11-05 03:23:07 +00:00
|
|
|
|
|
|
|
VTKM_EXEC
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::IdComponent operator()(vtkm::IdComponent numPoints) const { return numPoints; }
|
2016-11-05 03:23:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PassCellStructure : vtkm::worklet::WorkletMapPointToCell
|
|
|
|
{
|
2018-05-25 21:18:41 +00:00
|
|
|
using ControlSignature = void(CellSetIn inputTopology,
|
2017-05-26 17:53:28 +00:00
|
|
|
FieldOut<> shapes,
|
2016-11-05 03:23:07 +00:00
|
|
|
FieldOut<> pointIndices);
|
2018-05-25 21:18:41 +00:00
|
|
|
using ExecutionSignature = void(CellShape, PointIndices, _2, _3);
|
2016-11-05 03:23:07 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellShape, typename InPointIndexType, typename OutPointIndexType>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_EXEC void operator()(const CellShape& inShape,
|
|
|
|
const InPointIndexType& inPoints,
|
|
|
|
vtkm::UInt8& outShape,
|
|
|
|
OutPointIndexType& outPoints) const
|
2016-11-05 03:23:07 +00:00
|
|
|
{
|
2017-09-21 14:33:17 +00:00
|
|
|
(void)inShape; //C4100 false positive workaround
|
2016-11-05 03:23:07 +00:00
|
|
|
outShape = inShape.Id;
|
|
|
|
|
|
|
|
vtkm::IdComponent numPoints = inPoints.GetNumberOfComponents();
|
|
|
|
VTKM_ASSERT(numPoints == outPoints.GetNumberOfComponents());
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
2016-11-05 03:23:07 +00:00
|
|
|
{
|
|
|
|
outPoints[pointIndex] = inPoints[pointIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
template <typename InCellSetType,
|
|
|
|
typename ShapeStorage,
|
|
|
|
typename NumIndicesStorage,
|
|
|
|
typename ConnectivityStorage,
|
|
|
|
typename OffsetsStorage,
|
|
|
|
typename Device>
|
|
|
|
VTKM_CONT static void Run(const InCellSetType& inCellSet,
|
|
|
|
vtkm::cont::CellSetExplicit<ShapeStorage,
|
|
|
|
NumIndicesStorage,
|
|
|
|
ConnectivityStorage,
|
|
|
|
OffsetsStorage>& outCellSet,
|
|
|
|
Device)
|
2016-11-05 03:23:07 +00:00
|
|
|
{
|
2016-11-06 22:15:22 +00:00
|
|
|
VTKM_IS_DYNAMIC_OR_STATIC_CELL_SET(InCellSetType);
|
2016-11-05 03:23:07 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorage> numIndices;
|
2016-11-05 03:23:07 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::worklet::DispatcherMapTopology<CountCellPoints, Device> countDispatcher;
|
2016-11-05 03:23:07 +00:00
|
|
|
countDispatcher.Invoke(inCellSet, numIndices);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorage> shapes;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorage> connectivity;
|
2016-11-05 03:23:07 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage> offsets;
|
2016-11-05 03:23:07 +00:00
|
|
|
vtkm::Id connectivitySize;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
|
2016-11-05 03:23:07 +00:00
|
|
|
connectivity.Allocate(connectivitySize);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::worklet::DispatcherMapTopology<PassCellStructure, Device> passDispatcher;
|
2017-05-26 17:53:28 +00:00
|
|
|
passDispatcher.Invoke(
|
|
|
|
inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
vtkm::cont::
|
|
|
|
CellSetExplicit<ShapeStorage, NumIndicesStorage, ConnectivityStorage, OffsetsStorage>
|
|
|
|
newCellSet(inCellSet.GetName());
|
2017-05-18 14:29:41 +00:00
|
|
|
newCellSet.Fill(inCellSet.GetNumberOfPoints(), shapes, numIndices, connectivity, offsets);
|
2016-11-05 03:23:07 +00:00
|
|
|
outCellSet = newCellSet;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename InCellSetType, typename Device>
|
|
|
|
VTKM_CONT static vtkm::cont::CellSetExplicit<> Run(const InCellSetType& inCellSet, Device)
|
2016-11-05 03:23:07 +00:00
|
|
|
{
|
2016-11-06 22:15:22 +00:00
|
|
|
VTKM_IS_DYNAMIC_OR_STATIC_CELL_SET(InCellSetType);
|
2016-11-05 03:23:07 +00:00
|
|
|
|
|
|
|
vtkm::cont::CellSetExplicit<> outCellSet;
|
|
|
|
Run(inCellSet, outCellSet, Device());
|
|
|
|
|
|
|
|
return outCellSet;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif //vtk_m_worklet_CellDeepCopy_h
|