VTK-m  2.0
CellDeepCopy.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_worklet_CellDeepCopy_h
11 #define vtk_m_worklet_CellDeepCopy_h
12 
18 
21 
22 namespace vtkm
23 {
24 namespace worklet
25 {
26 
31 {
33  {
34  using ControlSignature = void(CellSetIn inputTopology, FieldOut numPointsInCell);
36 
37  VTKM_EXEC
38  vtkm::IdComponent operator()(vtkm::IdComponent numPoints) const { return numPoints; }
39  };
40 
42  {
43  using ControlSignature = void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices);
44  using ExecutionSignature = void(CellShape, PointIndices, _2, _3);
45 
46  template <typename CellShape, typename InPointIndexType, typename OutPointIndexType>
47  VTKM_EXEC void operator()(const CellShape& inShape,
48  const InPointIndexType& inPoints,
49  vtkm::UInt8& outShape,
50  OutPointIndexType& outPoints) const
51  {
52  (void)inShape; //C4100 false positive workaround
53  outShape = inShape.Id;
54 
55  vtkm::IdComponent numPoints = inPoints.GetNumberOfComponents();
56  VTKM_ASSERT(numPoints == outPoints.GetNumberOfComponents());
57  for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
58  {
59  outPoints[pointIndex] = inPoints[pointIndex];
60  }
61  }
62  };
63 
64  template <typename InCellSetType,
65  typename ShapeStorage,
66  typename ConnectivityStorage,
67  typename OffsetsStorage>
68  VTKM_CONT static void Run(
69  const InCellSetType& inCellSet,
71  vtkm::Id numberOfPoints)
72  {
73  VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(InCellSetType);
74 
76 
78  countDispatcher.Invoke(inCellSet, numIndices);
79 
82 
84  vtkm::Id connectivitySize;
85  vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
86  connectivity.Allocate(connectivitySize);
87 
89  passDispatcher.Invoke(
90  inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
91 
93  newCellSet.Fill(numberOfPoints, shapes, connectivity, offsets);
94  outCellSet = newCellSet;
95  }
96 
97  template <typename InCellSetType,
98  typename ShapeStorage,
99  typename ConnectivityStorage,
100  typename OffsetsStorage>
101  VTKM_CONT static void Run(
102  const InCellSetType& inCellSet,
104  {
105  Run(inCellSet, outCellSet, inCellSet.GetNumberOfPoints());
106  }
107 
108  template <typename InCellSetType>
109  VTKM_CONT static vtkm::cont::CellSetExplicit<> Run(const InCellSetType& inCellSet)
110  {
111  VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(InCellSetType);
112 
114  Run(inCellSet, outCellSet);
115 
116  return outCellSet;
117  }
118 };
119 }
120 } // namespace vtkm::worklet
121 
122 #endif //vtk_m_worklet_CellDeepCopy_h
vtkm::cont::ArrayHandle< vtkm::IdComponent >
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
CellSetExplicit.h
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET
#define VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(T)
Definition: UnknownCellSet.h:313
UnknownCellSet.h
vtkm::worklet::WorkletVisitCellsWithPoints::PointCount
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
vtkm::worklet::CellDeepCopy::CountCellPoints::ControlSignature
void(CellSetIn inputTopology, FieldOut numPointsInCell) ControlSignature
Definition: CellDeepCopy.h:34
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::worklet::CellDeepCopy::PassCellStructure::operator()
VTKM_EXEC void operator()(const CellShape &inShape, const InPointIndexType &inPoints, vtkm::UInt8 &outShape, OutPointIndexType &outPoints) const
Definition: CellDeepCopy.h:47
ArrayHandleConstant.h
vtkm::worklet::WorkletVisitCellsWithPoints::PointIndices
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::CellDeepCopy::PassCellStructure::ExecutionSignature
void(CellShape, PointIndices, _2, _3) ExecutionSignature
Definition: CellDeepCopy.h:44
vtkm::worklet::CellDeepCopy::CountCellPoints
Definition: CellDeepCopy.h:32
vtkm::worklet::DispatcherMapTopology
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
vtkm::worklet::WorkletVisitCellsWithPoints
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
vtkm::worklet::CellDeepCopy::Run
static VTKM_CONT void Run(const InCellSetType &inCellSet, vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet)
Definition: CellDeepCopy.h:101
vtkm::cont::make_ArrayHandleGroupVecVariable
VTKM_CONT vtkm::cont::ArrayHandleGroupVecVariable< ComponentsArrayHandleType, OffsetsArrayHandleType > make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType &componentsArray, const OffsetsArrayHandleType &offsetsArray)
make_ArrayHandleGroupVecVariable is convenience function to generate an ArrayHandleGroupVecVariable.
Definition: ArrayHandleGroupVecVariable.h:308
vtkm::worklet::CellDeepCopy::CountCellPoints::operator()
VTKM_EXEC vtkm::IdComponent operator()(vtkm::IdComponent numPoints) const
Definition: CellDeepCopy.h:38
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::CellSetExplicit::Fill
VTKM_CONT void Fill(vtkm::Id numPoints, const vtkm::cont::ArrayHandle< vtkm::UInt8, ShapesStorageTag > &cellTypes, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity, const vtkm::cont::ArrayHandle< vtkm::Id, OffsetsStorageTag > &offsets)
Second method to add cells – all at once.
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::worklet::CellDeepCopy::CountCellPoints::ExecutionSignature
_2(PointCount) ExecutionSignature
Definition: CellDeepCopy.h:35
vtkm::worklet::CellDeepCopy::Run
static VTKM_CONT void Run(const InCellSetType &inCellSet, vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &outCellSet, vtkm::Id numberOfPoints)
Definition: CellDeepCopy.h:68
vtkm::cont::CellSetExplicit::GetNumberOfPoints
VTKM_CONT vtkm::Id GetNumberOfPoints() const override
vtkm::cont::ConvertNumComponentsToOffsets
VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
vtkm::worklet::CellDeepCopy::PassCellStructure
Definition: CellDeepCopy.h:41
vtkm::worklet::CellDeepCopy
Container for worklets and helper methods to copy a cell set to a new CellSetExplicit structure.
Definition: CellDeepCopy.h:30
ConvertNumComponentsToOffsets.h
vtkm::cont::CellSetExplicit
Definition: CastAndCall.h:36
ArrayHandleGroupVecVariable.h
vtkm::worklet::CellDeepCopy::Run
static VTKM_CONT vtkm::cont::CellSetExplicit Run(const InCellSetType &inCellSet)
Definition: CellDeepCopy.h:109
DispatcherMapTopology.h
WorkletMapTopology.h
vtkm::worklet::CellDeepCopy::PassCellStructure::ControlSignature
void(CellSetIn inputTopology, FieldOut shapes, FieldOut pointIndices) ControlSignature
Definition: CellDeepCopy.h:43