Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayExtractComponent_h
19 #define viskores_cont_ArrayExtractComponent_h
30 #include <viskoresstd/integer_sequence.h>
47 template <
typename T,
typename S>
56 "Cannot extract component of " +
60 "Extracting component "
61 << componentIndex <<
" of "
63 <<
" requires an inefficient memory copy.");
71 for (
viskores::Id arrayIndex = 0; arrayIndex < numValues; ++arrayIndex)
75 viskores::internal::GetFlatVecComponent(srcPortal.Get(arrayIndex), componentIndex));
83 struct ArrayExtractComponentImplInefficient
88 struct ArrayExtractComponentImpl : ArrayExtractComponentImplInefficient
98 return viskores::cont::internal::ArrayExtractComponentFallback(src, componentIndex, allowCopy);
103 struct ArrayExtractComponentImpl<
viskores::cont::StorageTagStride>
105 template <
typename T>
111 return this->DoExtract(
116 template <
typename T>
124 using TBase =
typename VTraits::BaseComponentType;
133 array.GetNumberOfValues(),
140 template <
typename VecType>
147 using T =
typename VTraits::ComponentType;
153 array.GetNumberOfValues(),
154 array.GetStride() * N,
155 (array.GetOffset() * N) +
156 (componentIndex / subStride),
157 array.GetModulo() * N,
159 return (*
this)(tmpIn, componentIndex % subStride, allowCopy);
164 struct ArrayExtractComponentImpl<
viskores::cont::StorageTagBasic>
166 template <
typename T>
170 -> decltype(ArrayExtractComponentImpl<viskores::cont::StorageTagStride>{}(
175 return ArrayExtractComponentImpl<viskores::cont::StorageTagStride>{}(
185 template <std::
size_t,
typename Super>
186 struct ForwardSuper : Super
190 template <
typename sequence,
typename... Supers>
191 struct SharedSupersImpl;
193 template <std::size_t... Indices,
typename... Supers>
194 struct SharedSupersImpl<viskoresstd::index_sequence<Indices...>, Supers...>
195 : ForwardSuper<Indices, Supers>...
207 template <
typename... Supers>
208 using DuplicatedSuperclasses =
209 detail::SharedSupersImpl<viskoresstd::make_index_sequence<
sizeof...(Supers)>, Supers...>;
211 template <typename... StorageTags>
212 using ArrayExtractComponentImplInherit =
213 DuplicatedSuperclasses<viskores::cont::internal::ArrayExtractComponentImpl<StorageTags>...>;
217 template <typename ArrayHandleType>
218 using ArrayExtractComponentIsInefficient =
typename std::is_base_of<
219 viskores::cont::internal::ArrayExtractComponentImplInefficient,
220 viskores::cont::internal::ArrayExtractComponentImpl<typename ArrayHandleType::StorageTag>>::type;
265 template <
typename T,
typename S>
271 return internal::ArrayExtractComponentImpl<S>{}(src, componentIndex, allowCopy);
277 #endif //viskores_cont_ArrayExtractComponent_h
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
@ Warn
Less important user errors, such as out-of-bounds parameters.
#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
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:31
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:343
viskores::cont::ArrayHandleStride< typename viskores::VecTraits< T >::BaseComponentType > ArrayExtractComponent(const viskores::cont::ArrayHandle< T, S > &src, viskores::IdComponent componentIndex, viskores::CopyFlag allowCopy=viskores::CopyFlag::On)
Pulls a component out of an ArrayHandle.
Definition: ArrayExtractComponent.h:267
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
Groups connected points that have the same field value.
Definition: Atomic.h:27
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
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
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
#define VISKORES_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:216
T BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:86
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
#define VISKORES_STATIC_ASSERT(condition)
Definition: StaticAssert.h:24