Viskores  1.0
ConvertNumComponentsToOffsetsTemplate.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
19 #define viskores_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
20 
21 
24 
25 namespace viskores
26 {
27 namespace cont
28 {
29 namespace internal
30 {
31 
39 template <typename NumComponentsArrayType, typename OffsetsStorage>
40 VISKORES_CONT void ConvertNumComponentsToOffsetsTemplate(
41  const NumComponentsArrayType& numComponentsArray,
43  viskores::Id& componentsArraySize,
45 {
46  using namespace viskores::cont;
47  VISKORES_IS_ARRAY_HANDLE(NumComponentsArrayType);
48 
50 
52  device, make_ArrayHandleCast<viskores::Id>(numComponentsArray), offsetsArray);
53 
54  componentsArraySize =
55  viskores::cont::ArrayGetValue(offsetsArray.GetNumberOfValues() - 1, offsetsArray);
56 }
57 
58 template <typename NumComponentsArrayType, typename OffsetsStorage>
59 VISKORES_CONT void ConvertNumComponentsToOffsetsTemplate(
60  const NumComponentsArrayType& numComponentsArray,
63 {
64  VISKORES_IS_ARRAY_HANDLE(NumComponentsArrayType);
65 
67 
69  device, viskores::cont::make_ArrayHandleCast<viskores::Id>(numComponentsArray), offsetsArray);
70 }
71 
72 template <typename NumComponentsArrayType>
73 VISKORES_CONT viskores::cont::ArrayHandle<viskores::Id> ConvertNumComponentsToOffsetsTemplate(
74  const NumComponentsArrayType& numComponentsArray,
75  viskores::Id& componentsArraySize,
77 {
78  VISKORES_IS_ARRAY_HANDLE(NumComponentsArrayType);
79 
81  viskores::cont::internal::ConvertNumComponentsToOffsetsTemplate(
82  numComponentsArray, offsetsArray, componentsArraySize, device);
83  return offsetsArray;
84 }
85 
86 template <typename NumComponentsArrayType>
87 VISKORES_CONT viskores::cont::ArrayHandle<viskores::Id> ConvertNumComponentsToOffsetsTemplate(
88  const NumComponentsArrayType& numComponentsArray,
90 {
91  VISKORES_IS_ARRAY_HANDLE(NumComponentsArrayType);
92 
94  viskores::cont::internal::ConvertNumComponentsToOffsetsTemplate(
95  numComponentsArray, offsetsArray, device);
96  return offsetsArray;
97 }
98 
99 
101 
102 } // namespace viskores::cont::internal
103 } // namespace viskores::cont
104 } // namespace viskores
105 
106 #endif // viskores_cont_internal_ConvertNumComponentsToOffsetsTemplate_h
VISKORES_IS_ARRAY_HANDLE
#define VISKORES_IS_ARRAY_HANDLE(T)
Checks that the given type is a viskores::cont::ArrayHandle.
Definition: ArrayHandle.h:145
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::cont::DeviceAdapterTagAny
Tag for a device adapter used to specify that any device may be used for an operation.
Definition: DeviceAdapterTag.h:194
viskores::cont::ArrayGetValue
T ArrayGetValue(viskores::Id id, const viskores::cont::ArrayHandle< T, S > &data)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:270
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
Algorithm.h
viskores::cont
Viskores Control Environment.
Definition: Algorithm.h:33
viskores::cont::ArrayHandle::GetNumberOfValues
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
ArrayGetValues.h
viskores::cont::Algorithm::ScanExtended
static void ScanExtended(viskores::cont::DeviceAdapterId devId, const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:921
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
VISKORES_LOG_SCOPE_FUNCTION
#define VISKORES_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:225
viskores::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...