Viskores  1.0
ScatterCounting.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_ScatterCounting_h
19 #define viskores_worklet_ScatterCounting_h
20 
23 
25 
26 #include <sstream>
27 
28 namespace viskores
29 {
30 namespace worklet
31 {
32 
33 namespace detail
34 {
35 
36 struct ScatterCountingBuilder;
37 
38 } // namespace detail
39 
52 struct VISKORES_WORKLET_EXPORT ScatterCounting : internal::ScatterBase
53 {
62 
71  const viskores::cont::UnknownArrayHandle& countArray,
73  bool saveInputToOutputMap = false)
74  {
75  this->BuildArrays(countArray, device, saveInputToOutputMap);
76  }
78  bool saveInputToOutputMap)
79  {
80  this->BuildArrays(countArray, viskores::cont::DeviceAdapterTagAny(), saveInputToOutputMap);
81  }
82 
84 
85  template <typename RangeType>
87  {
88  return this->OutputToInputMap;
89  }
90 
92  template <typename RangeType>
94  {
95  return this->VisitArray;
96  }
97 
100  {
101  if (inputRange != this->InputRange)
102  {
103  std::stringstream msg;
104  msg << "ScatterCounting initialized with input domain of size " << this->InputRange
105  << " but used with a worklet invoke of size " << inputRange << std::endl;
106  throw viskores::cont::ErrorBadValue(msg.str());
107  }
108  return this->VisitArray.GetNumberOfValues();
109  }
112  {
113  return this->GetOutputRange(inputRange[0] * inputRange[1] * inputRange[2]);
114  }
115 
117  OutputToInputMapType GetOutputToInputMap() const { return this->OutputToInputMap; }
118 
124  {
125  return this->InputToOutputMap;
126  }
127 
128 private:
133 
134  friend struct detail::ScatterCountingBuilder;
135 
136  VISKORES_CONT void BuildArrays(const viskores::cont::UnknownArrayHandle& countArray,
138  bool saveInputToOutputMap);
139 };
140 }
141 } // namespace viskores::worklet
142 
143 #endif //viskores_worklet_ScatterCounting_h
viskores::Int16
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:181
ScatterBase.h
viskores::Int8
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:173
viskores::cont::ArrayHandle< viskores::Id >
viskores::worklet::ScatterCounting::VisitArray
VisitArrayType VisitArray
Definition: ScatterCounting.h:132
viskores::UInt16
uint16_t UInt16
Base type to use for 16-bit unsigned integer numbers.
Definition: Types.h:185
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_worklet_export.h
viskores::List
A template used to hold a list of types.
Definition: List.h:47
viskores::Int64
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:212
viskores::worklet::ScatterCounting::GetOutputRange
viskores::Id GetOutputRange(viskores::Id inputRange) const
Definition: ScatterCounting.h:99
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
UnknownArrayHandle.h
viskores::worklet::ScatterCounting::GetVisitArray
VisitArrayType GetVisitArray(RangeType) const
Definition: ScatterCounting.h:93
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::worklet::ScatterCounting::InputToOutputMap
viskores::cont::ArrayHandle< viskores::Id > InputToOutputMap
Definition: ScatterCounting.h:130
viskores::worklet::ScatterCounting::ScatterCounting
ScatterCounting(const viskores::cont::UnknownArrayHandle &countArray, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny(), bool saveInputToOutputMap=false)
Construct a ScatterCounting object using an array of counts for the number of outputs for each input.
Definition: ScatterCounting.h:70
viskores::worklet::ScatterCounting::OutputToInputMap
OutputToInputMapType OutputToInputMap
Definition: ScatterCounting.h:131
viskores::worklet::ScatterCounting::GetOutputRange
viskores::Id GetOutputRange(viskores::Id3 inputRange) const
Definition: ScatterCounting.h:111
viskores::UInt64
unsigned long long UInt64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:215
viskores::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::worklet::ScatterCounting::ScatterCounting
ScatterCounting(const viskores::cont::UnknownArrayHandle &countArray, bool saveInputToOutputMap)
Definition: ScatterCounting.h:77
viskores::cont::ErrorBadValue
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
viskores::worklet::ScatterCounting::GetInputToOutputMap
viskores::cont::ArrayHandle< viskores::Id > GetInputToOutputMap() const
This array will not be valid unless explicitly instructed to be saved.
Definition: ScatterCounting.h:123
viskores::worklet::ScatterCounting
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:52
viskores::worklet::ScatterCounting::GetOutputToInputMap
OutputToInputMapType GetOutputToInputMap(RangeType) const
Definition: ScatterCounting.h:86
viskores::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::worklet::ScatterCounting::InputRange
viskores::Id InputRange
Definition: ScatterCounting.h:129
viskores::Vec< viskores::Id, 3 >
viskores::UInt32
uint32_t UInt32
Base type to use for 32-bit unsigned integer numbers.
Definition: Types.h:193
viskores::worklet::ScatterCounting::GetOutputToInputMap
OutputToInputMapType GetOutputToInputMap() const
Definition: ScatterCounting.h:117