Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayGetValues_h
11 #define vtk_m_cont_ArrayGetValues_h
18 #include <initializer_list>
27 class UnknownArrayHandle;
35 std::false_type extractComponentInefficient);
37 template <
typename IdsArrayHandle,
typename DataArrayHandle,
typename OutputArrayHandle>
38 void ArrayGetValuesImpl(
const IdsArrayHandle& ids,
39 const DataArrayHandle& data,
40 const OutputArrayHandle& output,
41 std::true_type
vtkmNotUsed(extractComponentInefficient))
48 vtkm::Id outputSize = ids.GetNumberOfValues();
49 output.Allocate(outputSize);
50 auto idsPortal = ids.ReadPortal();
51 auto dataPortal = data.ReadPortal();
52 auto outputPortal = output.WritePortal();
53 for (
vtkm::Id index = 0; index < outputSize; ++index)
55 outputPortal.Set(index, dataPortal.Get(idsPortal.Get(index)));
118 template <
typename SIds,
typename T,
typename SData,
typename SOut>
124 using InefficientExtract =
125 vtkm::cont::internal::ArrayExtractComponentIsInefficient<DataArrayHandle>;
126 internal::ArrayGetValuesImpl(ids, data, output, InefficientExtract{});
131 template <
typename SIds,
typename TIn,
typename SData,
typename TOut,
typename SOut>
147 for (
vtkm::Id i = 0; i < numExtracted; ++i)
149 outp.Set(i,
static_cast<TOut
>(inp.Get(i)));
153 template <
typename SIds,
typename T,
typename SData,
typename Alloc>
156 std::vector<T, Alloc>& output)
161 output.resize(numVals);
166 result.SyncControlArray();
169 template <
typename SIds,
typename T,
typename SData>
173 std::vector<T> result;
178 template <
typename T,
typename Alloc,
typename SData,
typename SOut>
187 template <
typename T,
typename AllocId,
typename SData,
typename AllocOut>
190 std::vector<T, AllocOut>& output)
196 template <
typename T,
typename Alloc,
typename SData>
204 template <
typename T,
typename SData,
typename SOut>
214 template <
typename T,
typename SData,
typename Alloc>
217 std::vector<T, Alloc>& output)
223 template <
typename T,
typename SData>
232 template <
typename T,
typename SData,
typename SOut>
242 template <
typename T,
typename SData,
typename Alloc>
246 std::vector<T, Alloc>& output)
251 template <
typename T,
typename SData>
260 template <
typename T,
typename S>
268 template <
typename T,
typename S>
277 #endif //vtk_m_cont_ArrayGetValues_h
Manages an array-worth of data.
Definition: ArrayHandle.h:300
Groups connected points that have the same field value.
Definition: Atomic.h:19
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
Definition: ArrayHandleCast.h:28
ArrayHandleType GetSourceArray() const
Returns the ArrayHandle that is being transformed.
Definition: ArrayHandleCast.h:169
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
void ArrayGetValues(const vtkm::cont::ArrayHandle< vtkm::Id, SIds > &ids, const vtkm::cont::ArrayHandle< T, SData > &data, vtkm::cont::ArrayHandle< T, SOut > &output)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:119
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
Basic array storage for an array handle.
Definition: ArrayHandleBasic.h:111
vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:270
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454
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:261