Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayExtractComponent_h
11 #define vtk_m_cont_ArrayExtractComponent_h
22 #include <vtkmstd/integer_sequence.h>
39 template <
typename T,
typename S>
52 "Extracting component " << componentIndex <<
" of "
54 <<
" requires an inefficient memory copy.");
62 for (
vtkm::Id arrayIndex = 0; arrayIndex < numValues; ++arrayIndex)
64 destPortal.Set(arrayIndex,
65 vtkm::internal::GetFlatVecComponent(srcPortal.Get(arrayIndex), componentIndex));
73 struct ArrayExtractComponentImplInefficient
78 struct ArrayExtractComponentImpl : ArrayExtractComponentImplInefficient
88 return vtkm::cont::internal::ArrayExtractComponentFallback(src, componentIndex, allowCopy);
93 struct ArrayExtractComponentImpl<
vtkm::cont::StorageTagStride>
101 return this->DoExtract(
106 template <
typename T>
114 using TBase =
typename VTraits::BaseComponentType;
123 array.GetNumberOfValues(),
130 template <
typename VecType>
137 using T =
typename VTraits::ComponentType;
140 constexpr
vtkm::IdComponent subStride = vtkm::internal::TotalNumComponents<T>::value;
143 array.GetNumberOfValues(),
144 array.GetStride() * N,
145 (array.GetOffset() * N) + (componentIndex / subStride),
146 array.GetModulo() * N,
148 return (*
this)(tmpIn, componentIndex % subStride, allowCopy);
153 struct ArrayExtractComponentImpl<
vtkm::cont::StorageTagBasic>
155 template <
typename T>
164 return ArrayExtractComponentImpl<vtkm::cont::StorageTagStride>{}(
174 template <std::
size_t,
typename Super>
175 struct ForwardSuper : Super
179 template <
typename sequence,
typename... Supers>
180 struct SharedSupersImpl;
182 template <std::size_t... Indices,
typename... Supers>
183 struct SharedSupersImpl<vtkmstd::index_sequence<Indices...>, Supers...>
184 : ForwardSuper<Indices, Supers>...
196 template <
typename... Supers>
197 using DuplicatedSuperclasses =
198 detail::SharedSupersImpl<vtkmstd::make_index_sequence<
sizeof...(Supers)>, Supers...>;
200 template <typename... StorageTags>
201 using ArrayExtractComponentImplInherit =
202 DuplicatedSuperclasses<vtkm::cont::internal::ArrayExtractComponentImpl<StorageTags>...>;
206 template <typename ArrayHandleType>
207 using ArrayExtractComponentIsInefficient =
typename std::is_base_of<
208 vtkm::cont::internal::ArrayExtractComponentImplInefficient,
209 vtkm::cont::internal::ArrayExtractComponentImpl<typename ArrayHandleType::StorageTag>>::type;
254 template <
typename T,
typename S>
260 return internal::ArrayExtractComponentImpl<S>{}(src, componentIndex, allowCopy);
266 #endif //vtk_m_cont_ArrayExtractComponent_h
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::cont::ArrayHandleStride< typename vtkm::VecTraits< T >::BaseComponentType > ArrayExtractComponent(const vtkm::cont::ArrayHandle< T, S > &src, vtkm::IdComponent componentIndex, vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On)
Pulls a component out of an ArrayHandle.
Definition: ArrayExtractComponent.h:255
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:23
Groups connected points that have the same field value.
Definition: Atomic.h:19
@ Warn
Less important user errors, such as out-of-bounds parameters.
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:332
T BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:78
#define VTKM_STATIC_ASSERT(condition)
Definition: StaticAssert.h:16
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
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:208
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
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
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454