Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayGetValues_h
19 #define viskores_cont_ArrayGetValues_h
26 #include <initializer_list>
35 class UnknownArrayHandle;
43 std::false_type extractComponentInefficient);
45 template <
typename IdsArrayHandle,
typename DataArrayHandle,
typename OutputArrayHandle>
46 void ArrayGetValuesImpl(
const IdsArrayHandle& ids,
47 const DataArrayHandle& data,
48 const OutputArrayHandle& output,
57 output.Allocate(outputSize);
58 auto idsPortal = ids.ReadPortal();
59 auto dataPortal = data.ReadPortal();
60 auto outputPortal = output.WritePortal();
61 for (
viskores::Id index = 0; index < outputSize; ++index)
63 outputPortal.Set(index, dataPortal.Get(idsPortal.Get(index)));
126 template <
typename SIds,
typename T,
typename SData,
typename SOut>
132 using InefficientExtract =
133 viskores::cont::internal::ArrayExtractComponentIsInefficient<DataArrayHandle>;
134 internal::ArrayGetValuesImpl(ids, data, output, InefficientExtract{});
139 template <
typename SIds,
typename TIn,
typename SData,
typename TOut,
typename SOut>
157 outp.Set(i,
static_cast<TOut
>(inp.Get(i)));
161 template <
typename SIds,
typename T,
typename SData,
typename Alloc>
164 std::vector<T, Alloc>& output)
169 output.resize(numVals);
174 result.SyncControlArray();
177 template <
typename SIds,
typename T,
typename SData>
182 std::vector<T> result;
187 template <
typename T,
typename Alloc,
typename SData,
typename SOut>
196 template <
typename T,
typename AllocId,
typename SData,
typename AllocOut>
199 std::vector<T, AllocOut>& output)
205 template <
typename T,
typename Alloc,
typename SData>
213 template <
typename T,
typename SData,
typename SOut>
223 template <
typename T,
typename SData,
typename Alloc>
226 std::vector<T, Alloc>& output)
232 template <
typename T,
typename SData>
241 template <
typename T,
typename SData,
typename SOut>
251 template <
typename T,
typename SData,
typename Alloc>
255 std::vector<T, Alloc>& output)
260 template <
typename T,
typename SData>
269 template <
typename T,
typename S>
277 template <
typename T,
typename S>
288 #endif //viskores_cont_ArrayGetValues_h
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
Definition: ArrayHandleCast.h:36
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:151
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
Manages an array-worth of data.
Definition: ArrayHandle.h:313
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
ArrayHandleType GetSourceArray() const
Returns the ArrayHandle that is being transformed.
Definition: ArrayHandleCast.h:179
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
Basic array storage for an array handle.
Definition: ArrayHandleBasic.h:120
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
void ArrayGetValues(const viskores::cont::ArrayHandle< viskores::Id, SIds > &ids, const viskores::cont::ArrayHandle< T, SData > &data, viskores::cont::ArrayHandle< T, SOut > &output)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:127
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285