Viskores  1.0
ScatterUniform.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_worklet_ScatterUniform_h
19 #define viskores_worklet_ScatterUniform_h
20 
25 
26 namespace viskores
27 {
28 namespace worklet
29 {
30 
31 namespace detail
32 {
33 
34 template <viskores::IdComponent Modulus>
35 struct FunctorModulus
36 {
38  viskores::IdComponent operator()(viskores::Id index) const
39  {
40  return static_cast<viskores::IdComponent>(index % Modulus);
41  }
42 };
43 
44 template <viskores::IdComponent Divisor>
45 struct FunctorDiv
46 {
48  viskores::Id operator()(viskores::Id index) const { return index / Divisor; }
49 };
50 }
51 
60 template <viskores::IdComponent NumOutputsPerInput>
61 struct ScatterUniform : internal::ScatterBase
62 {
63  VISKORES_CONT ScatterUniform() = default;
64 
67  {
68  return inputRange * NumOutputsPerInput;
69  }
72  {
73  return this->GetOutputRange(inputRange[0] * inputRange[1] * inputRange[2]);
74  }
75 
76  using OutputToInputMapType =
78  template <typename RangeType>
80  {
81  return OutputToInputMapType(detail::FunctorDiv<NumOutputsPerInput>(),
82  this->GetOutputRange(inputRange));
83  }
84 
85  using VisitArrayType =
87  template <typename RangeType>
88  VISKORES_CONT VisitArrayType GetVisitArray(RangeType inputRange) const
89  {
90  return VisitArrayType(detail::FunctorModulus<NumOutputsPerInput>(),
91  this->GetOutputRange(inputRange));
92  }
93 };
94 }
95 } // namespace viskores::worklet
96 
97 #endif //viskores_worklet_ScatterUniform_h
viskores::worklet::ScatterUniform::GetVisitArray
VisitArrayType GetVisitArray(RangeType inputRange) const
Definition: ScatterUniform.h:88
ArrayHandle.h
viskores::worklet::ScatterUniform::GetOutputRange
viskores::Id GetOutputRange(viskores::Id inputRange) const
Definition: ScatterUniform.h:66
ScatterBase.h
viskores::worklet::ScatterUniform::GetOutputRange
viskores::Id GetOutputRange(viskores::Id3 inputRange) const
Definition: ScatterUniform.h:71
viskores::worklet::ScatterUniform::GetOutputToInputMap
OutputToInputMapType GetOutputToInputMap(RangeType inputRange) const
Definition: ScatterUniform.h:79
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::worklet::ScatterUniform::ScatterUniform
ScatterUniform()=default
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
viskores::worklet::ScatterUniform::OutputToInputMapType
viskores::cont::ArrayHandleImplicit< detail::FunctorDiv< NumOutputsPerInput > > OutputToInputMapType
Definition: ScatterUniform.h:77
ArrayHandleCounting.h
viskores::cont::ArrayHandleImplicit
An ArrayHandle that computes values on the fly.
Definition: ArrayHandleImplicit.h:186
viskores::worklet::ScatterUniform::VisitArrayType
viskores::cont::ArrayHandleImplicit< detail::FunctorModulus< NumOutputsPerInput > > VisitArrayType
Definition: ScatterUniform.h:86
ArrayHandleImplicit.h
viskores::worklet::ScatterUniform
A scatter that maps input to some constant numbers of output.
Definition: ScatterUniform.h:61
viskores::Vec< viskores::Id, 3 >