VTK-m  2.0
ConvertNumComponentsToOffsetsTemplate.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_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
11 #define vtk_m_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
12 
13 
14 #include <vtkm/cont/Algorithm.h>
16 
17 namespace vtkm
18 {
19 namespace cont
20 {
21 namespace internal
22 {
23 
31 template <typename NumComponentsArrayType, typename OffsetsStorage>
32 VTKM_CONT void ConvertNumComponentsToOffsetsTemplate(
33  const NumComponentsArrayType& numComponentsArray,
35  vtkm::Id& componentsArraySize,
36  vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
37 {
38  using namespace vtkm::cont;
39  VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
40 
42 
43  Algorithm::ScanExtended(device, make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
44 
45  componentsArraySize =
46  vtkm::cont::ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray);
47 }
48 
49 template <typename NumComponentsArrayType, typename OffsetsStorage>
50 VTKM_CONT void ConvertNumComponentsToOffsetsTemplate(
51  const NumComponentsArrayType& numComponentsArray,
53  vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
54 {
55  VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
56 
58 
60  device, vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray);
61 }
62 
63 template <typename NumComponentsArrayType>
64 VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsetsTemplate(
65  const NumComponentsArrayType& numComponentsArray,
66  vtkm::Id& componentsArraySize,
67  vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
68 {
69  VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
70 
72  vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(
73  numComponentsArray, offsetsArray, componentsArraySize, device);
74  return offsetsArray;
75 }
76 
77 template <typename NumComponentsArrayType>
78 VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsetsTemplate(
79  const NumComponentsArrayType& numComponentsArray,
80  vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
81 {
82  VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
83 
85  vtkm::cont::internal::ConvertNumComponentsToOffsetsTemplate(
86  numComponentsArray, offsetsArray, device);
87  return offsetsArray;
88 }
89 
90 
92 
93 } // namespace vtkm::cont::internal
94 } // namespace vtkm::cont
95 } // namespace vtkm
96 
97 #endif // vtk_m_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ArrayGetValue
VTKM_CONT T ArrayGetValue(vtkm::Id id, const vtkm::cont::ArrayHandle< T, S > &data)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:264
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
Algorithm.h
VTKM_IS_ARRAY_HANDLE
#define VTKM_IS_ARRAY_HANDLE(T)
Definition: ArrayHandle.h:132
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
VTKM_LOG_SCOPE_FUNCTION
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:266
ArrayGetValues.h
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::cont
VTK-m Control Environment.
Definition: Algorithm.h:24
vtkm::cont::Algorithm::ScanExtended
static VTKM_CONT void ScanExtended(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:901
vtkm::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...