VTK-m  2.2
UnknownArrayHandle.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_UnknownArrayHandle_h
11 #define vtk_m_cont_UnknownArrayHandle_h
12 
14 
16 #include <vtkm/cont/ArrayHandle.h>
22 #include <vtkm/cont/StorageList.h>
23 
24 #include <vtkm/Deprecated.h>
25 #include <vtkm/TypeList.h>
26 #include <vtkm/VecTraits.h>
27 
28 #include <memory>
29 #include <typeindex>
30 
31 namespace vtkm
32 {
33 namespace cont
34 {
35 
36 namespace detail
37 {
38 
39 template <typename T, typename S>
40 void UnknownAHDelete(void* mem)
41 {
43  AH* arrayHandle = reinterpret_cast<AH*>(mem);
44  delete arrayHandle;
45 }
46 
47 template <typename T, typename S>
48 const std::vector<vtkm::cont::internal::Buffer>& UnknownAHBuffers(void* mem)
49 {
51  AH* arrayHandle = reinterpret_cast<AH*>(mem);
52  return arrayHandle->GetBuffers();
53 }
54 
55 template <typename T, typename S>
56 void* UnknownAHNewInstance()
57 {
59 }
60 
61 template <typename T, typename S>
62 vtkm::Id UnknownAHNumberOfValues(void* mem)
63 {
65  AH* arrayHandle = reinterpret_cast<AH*>(mem);
66  return arrayHandle->GetNumberOfValues();
67 }
68 
69 template <typename T, typename S>
70 vtkm::IdComponent UnknownAHNumberOfComponentsFlat(void* mem)
71 {
73  AH* arrayHandle = reinterpret_cast<AH*>(mem);
74  return arrayHandle->GetNumberOfComponentsFlat();
75 }
76 
77 // Uses SFINAE to use Storage<>::GetNumberOfComponents if it exists, or the VecTraits otherwise
78 template <typename T, typename S>
79 inline auto UnknownAHNumberOfComponentsImpl(void* mem)
80  -> decltype(vtkm::cont::internal::Storage<T, S>::GetNumberOfComponents(
81  std::vector<vtkm::cont::internal::Buffer>()))
82 {
84  AH* arrayHandle = reinterpret_cast<AH*>(mem);
85  return vtkm::cont::internal::Storage<T, S>::GetNumberOfComponents(arrayHandle->GetBuffers());
86 }
87 
88 // Uses static vec size.
89 template <typename T, typename S>
90 inline vtkm::IdComponent UnknownAHNumberOfComponentsImpl(void*, vtkm::VecTraitsTagSizeStatic)
91 {
93 }
94 
95 // The size of the vecs are not defined at compile time. Assume that the components are not
96 // nested and use the flat components query.
97 template <typename T, typename S>
98 inline vtkm::IdComponent UnknownAHNumberOfComponentsImpl(void* mem, vtkm::VecTraitsTagSizeVariable)
99 {
100  return UnknownAHNumberOfComponentsFlat<T, S>(mem);
101 }
102 
103 template <typename T, typename S>
104 vtkm::IdComponent UnknownAHNumberOfComponents(void* mem)
105 {
106  return UnknownAHNumberOfComponentsImpl<T, S>(mem, typename vtkm::VecTraits<T>::IsSizeStatic{});
107 }
108 
109 template <typename T, typename S>
110 void UnknownAHAllocate(void* mem,
111  vtkm::Id numValues,
112  vtkm::CopyFlag preserve,
113  vtkm::cont::Token& token)
114 {
116  AH* arrayHandle = reinterpret_cast<AH*>(mem);
117  arrayHandle->Allocate(numValues, preserve, token);
118 }
119 
120 template <typename T, typename S>
121 void UnknownAHShallowCopy(const void* sourceMem, void* destinationMem)
122 {
124  const AH* source = reinterpret_cast<const AH*>(sourceMem);
125  AH* destination = reinterpret_cast<AH*>(destinationMem);
126  *destination = *source;
127 }
128 
129 template <typename T, typename S>
130 void UnknownAHDeepCopy(const void* sourceMem, void* destinationMem)
131 {
133  const AH* source = reinterpret_cast<const AH*>(sourceMem);
134  AH* destination = reinterpret_cast<AH*>(destinationMem);
135  destination->DeepCopyFrom(*source);
136 }
137 
138 template <typename T, typename S>
139 std::vector<vtkm::cont::internal::Buffer>
140 UnknownAHExtractComponent(void* mem, vtkm::IdComponent componentIndex, vtkm::CopyFlag allowCopy)
141 {
143  AH* arrayHandle = reinterpret_cast<AH*>(mem);
144  auto componentArray = vtkm::cont::ArrayExtractComponent(*arrayHandle, componentIndex, allowCopy);
145  return componentArray.GetBuffers();
146 }
147 
148 template <typename T, typename S>
149 void UnknownAHReleaseResources(void* mem)
150 {
152  AH* arrayHandle = reinterpret_cast<AH*>(mem);
153  arrayHandle->ReleaseResources();
154 }
155 
156 template <typename T, typename S>
157 void UnknownAHReleaseResourcesExecution(void* mem)
158 {
160  AH* arrayHandle = reinterpret_cast<AH*>(mem);
161  arrayHandle->ReleaseResourcesExecution();
162 }
163 
164 template <typename T, typename S>
165 void UnknownAHPrintSummary(void* mem, std::ostream& out, bool full)
166 {
168  AH* arrayHandle = reinterpret_cast<AH*>(mem);
169  vtkm::cont::printSummary_ArrayHandle(*arrayHandle, out, full);
170 }
171 
172 struct VTKM_CONT_EXPORT UnknownAHContainer;
173 
174 struct MakeUnknownAHContainerFunctor
175 {
176  template <typename T, typename S>
177  std::shared_ptr<UnknownAHContainer> operator()(const vtkm::cont::ArrayHandle<T, S>& array) const;
178 };
179 
180 struct VTKM_CONT_EXPORT UnknownAHComponentInfo
181 {
182  std::type_index Type;
183  bool IsIntegral;
184  bool IsFloat;
185  bool IsSigned;
186  std::size_t Size;
187 
188  UnknownAHComponentInfo() = delete;
189 
190  bool operator==(const UnknownAHComponentInfo& rhs);
191 
192  template <typename T>
193  static UnknownAHComponentInfo Make()
194  {
195  return UnknownAHComponentInfo{ typeid(T),
196  std::is_integral<T>::value,
197  std::is_floating_point<T>::value,
198  std::is_signed<T>::value,
199  sizeof(T) };
200  }
201 
202 private:
203  UnknownAHComponentInfo(std::type_index&& type,
204  bool isIntegral,
205  bool isFloat,
206  bool isSigned,
207  std::size_t size)
208  : Type(std::move(type))
209  , IsIntegral(isIntegral)
210  , IsFloat(isFloat)
211  , IsSigned(isSigned)
212  , Size(size)
213  {
214  }
215 };
216 
217 struct VTKM_CONT_EXPORT UnknownAHContainer
218 {
219  void* ArrayHandlePointer;
220 
221  std::type_index ValueType;
222  std::type_index StorageType;
223  UnknownAHComponentInfo BaseComponentType;
224 
225  using DeleteType = void(void*);
226  DeleteType* DeleteFunction;
227 
228  using BuffersType = const std::vector<vtkm::cont::internal::Buffer>&(void*);
229  BuffersType* Buffers;
230 
231  using NewInstanceType = void*();
232  NewInstanceType* NewInstance;
233 
234  using NewInstanceBasicType = std::shared_ptr<UnknownAHContainer>(void*);
235  NewInstanceBasicType* NewInstanceBasic;
236  NewInstanceBasicType* NewInstanceFloatBasic;
237 
238  using NumberOfValuesType = vtkm::Id(void*);
239  NumberOfValuesType* NumberOfValues;
240 
241  using NumberOfComponentsType = vtkm::IdComponent(void*);
242  NumberOfComponentsType* NumberOfComponents;
243  NumberOfComponentsType* NumberOfComponentsFlat;
244 
245  using AllocateType = void(void*, vtkm::Id, vtkm::CopyFlag, vtkm::cont::Token&);
246  AllocateType* Allocate;
247 
248  using ShallowCopyType = void(const void*, void*);
249  ShallowCopyType* ShallowCopy;
250 
251  using DeepCopyType = void(const void*, void*);
252  DeepCopyType* DeepCopy;
253 
254  using ExtractComponentType = std::vector<vtkm::cont::internal::Buffer>(void*,
257  ExtractComponentType* ExtractComponent;
258 
259  using ReleaseResourcesType = void(void*);
260  ReleaseResourcesType* ReleaseResources;
261  ReleaseResourcesType* ReleaseResourcesExecution;
262 
263  using PrintSummaryType = void(void*, std::ostream&, bool);
264  PrintSummaryType* PrintSummary;
265 
266  void operator=(const UnknownAHContainer&) = delete;
267 
268  ~UnknownAHContainer() { this->DeleteFunction(this->ArrayHandlePointer); }
269 
270  std::shared_ptr<UnknownAHContainer> MakeNewInstance() const;
271 
272  template <typename T, typename S>
273  static std::shared_ptr<UnknownAHContainer> Make(const vtkm::cont::ArrayHandle<T, S>& array)
274  {
275  return std::shared_ptr<UnknownAHContainer>(new UnknownAHContainer(array));
276  }
277 
278  template <typename TargetT, typename SourceT, typename SourceS>
279  static std::shared_ptr<UnknownAHContainer> Make(
281  {
283  array;
284  return Make(castArray.GetSourceArray());
285  }
286 
287  template <typename T, typename... Ss>
288  static std::shared_ptr<UnknownAHContainer> Make(
290  {
292  .GetArrayHandleVariant();
293  if (variant.IsValid())
294  {
295  return variant.CastAndCall(MakeUnknownAHContainerFunctor{});
296  }
297  else
298  {
299  return std::shared_ptr<UnknownAHContainer>{};
300  }
301  }
302 
303 private:
304  UnknownAHContainer(const UnknownAHContainer&) = default;
305 
306  template <typename T, typename S>
307  explicit UnknownAHContainer(const vtkm::cont::ArrayHandle<T, S>& array);
308 };
309 
310 template <typename T, typename S>
311 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceBasic(void*, vtkm::VecTraitsTagSizeStatic)
312 {
313  return UnknownAHContainer::Make(vtkm::cont::ArrayHandleBasic<T>{});
314 }
315 template <typename T, typename S>
316 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceBasic(void* mem,
318 {
319  vtkm::IdComponent numComponents = UnknownAHNumberOfComponentsFlat<T, S>(mem);
320  if (numComponents < 1)
321  {
322  // Array can have an inconsistent number of components. Cannot be represented by basic array.
323  throw vtkm::cont::ErrorBadType("Cannot create a basic array from array with ValueType of " +
324  vtkm::cont::TypeToString<T>());
325  }
326  using ComponentType = typename vtkm::VecTraits<T>::BaseComponentType;
327  return UnknownAHContainer::Make(vtkm::cont::ArrayHandleRuntimeVec<ComponentType>(numComponents));
328 }
329 template <typename T, typename S>
330 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceBasic(void* mem)
331 {
332  return UnknownAHNewInstanceBasic<T, S>(mem, typename vtkm::VecTraits<T>::IsSizeStatic{});
333 }
334 
335 template <typename T, typename S>
336 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceFloatBasic(void*,
338 {
339  using FloatT = typename vtkm::VecTraits<T>::template ReplaceBaseComponentType<vtkm::FloatDefault>;
340  return UnknownAHContainer::Make(vtkm::cont::ArrayHandleBasic<FloatT>{});
341 }
342 template <typename T, typename S>
343 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceFloatBasic(void* mem,
345 {
346  vtkm::IdComponent numComponents = UnknownAHNumberOfComponentsFlat<T, S>(mem);
347  if (numComponents < 1)
348  {
349  // Array can have an inconsistent number of components. Cannot be represented by basic array.
350  throw vtkm::cont::ErrorBadType("Cannot create a basic array from array with ValueType of " +
351  vtkm::cont::TypeToString<T>());
352  }
353  return UnknownAHContainer::Make(
355 }
356 template <typename T, typename S>
357 std::shared_ptr<UnknownAHContainer> UnknownAHNewInstanceFloatBasic(void* mem)
358 {
359  return UnknownAHNewInstanceFloatBasic<T, S>(mem, typename vtkm::VecTraits<T>::IsSizeStatic{});
360 }
361 
362 template <typename T, typename S>
363 inline UnknownAHContainer::UnknownAHContainer(const vtkm::cont::ArrayHandle<T, S>& array)
364  : ArrayHandlePointer(new vtkm::cont::ArrayHandle<T, S>(array))
365  , ValueType(typeid(T))
366  , StorageType(typeid(S))
367  , BaseComponentType(
368  UnknownAHComponentInfo::Make<typename vtkm::VecTraits<T>::BaseComponentType>())
369  , DeleteFunction(detail::UnknownAHDelete<T, S>)
370  , Buffers(detail::UnknownAHBuffers<T, S>)
371  , NewInstance(detail::UnknownAHNewInstance<T, S>)
372  , NewInstanceBasic(detail::UnknownAHNewInstanceBasic<T, S>)
373  , NewInstanceFloatBasic(detail::UnknownAHNewInstanceFloatBasic<T, S>)
374  , NumberOfValues(detail::UnknownAHNumberOfValues<T, S>)
375  , NumberOfComponents(detail::UnknownAHNumberOfComponents<T, S>)
376  , NumberOfComponentsFlat(detail::UnknownAHNumberOfComponentsFlat<T, S>)
377  , Allocate(detail::UnknownAHAllocate<T, S>)
378  , ShallowCopy(detail::UnknownAHShallowCopy<T, S>)
379  , DeepCopy(detail::UnknownAHDeepCopy<T, S>)
380  , ExtractComponent(detail::UnknownAHExtractComponent<T, S>)
381  , ReleaseResources(detail::UnknownAHReleaseResources<T, S>)
382  , ReleaseResourcesExecution(detail::UnknownAHReleaseResourcesExecution<T, S>)
383  , PrintSummary(detail::UnknownAHPrintSummary<T, S>)
384 {
385 }
386 
387 template <typename T, typename S>
388 inline std::shared_ptr<UnknownAHContainer> MakeUnknownAHContainerFunctor::operator()(
389  const vtkm::cont::ArrayHandle<T, S>& array) const
390 {
391  return UnknownAHContainer::Make(array);
392 };
393 
394 } // namespace detail
395 
396 // Forward declaration. Include UncertainArrayHandle.h if using this.
397 template <typename ValueTypeList, typename StorageTypeList>
398 class UncertainArrayHandle;
399 
431 {
432  std::shared_ptr<detail::UnknownAHContainer> Container;
433 
434  VTKM_CONT bool IsValueTypeImpl(std::type_index type) const;
435  VTKM_CONT bool IsStorageTypeImpl(std::type_index type) const;
436  VTKM_CONT bool IsBaseComponentTypeImpl(const detail::UnknownAHComponentInfo& type) const;
437 
438 public:
439  VTKM_CONT UnknownArrayHandle() = default;
440 
441  template <typename T, typename S>
443  : Container(detail::UnknownAHContainer::Make(array))
444  {
445  }
446 
453  VTKM_CONT bool IsValid() const;
454 
461  VTKM_CONT UnknownArrayHandle NewInstance() const;
462 
470  VTKM_CONT UnknownArrayHandle NewInstanceBasic() const;
471 
488  VTKM_CONT UnknownArrayHandle NewInstanceFloatBasic() const;
489 
493  VTKM_CONT std::string GetValueTypeName() const;
494 
498  VTKM_CONT std::string GetBaseComponentTypeName() const;
499 
503  VTKM_CONT std::string GetStorageTypeName() const;
504 
510  VTKM_CONT std::string GetArrayTypeName() const;
511 
514  template <typename ValueType>
515  VTKM_CONT bool IsValueType() const
516  {
517  return this->IsValueTypeImpl(typeid(ValueType));
518  }
519 
522  template <typename StorageType>
524  {
525  return this->IsStorageTypeImpl(typeid(StorageType));
526  }
527 
539  template <typename BaseComponentType>
541  {
542  return this->IsBaseComponentTypeImpl(detail::UnknownAHComponentInfo::Make<BaseComponentType>());
543  }
544 
557  template <typename ArrayHandleType>
558  VTKM_CONT bool IsType() const
559  {
560  VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
561  return (this->IsValueType<typename ArrayHandleType::ValueType>() &&
562  this->IsStorageType<typename ArrayHandleType::StorageTag>());
563  }
564 
572  // Defined in UncertainArrayHandle.h
573  template <typename NewValueTypeList, typename NewStorageTypeList>
575  NewValueTypeList = NewValueTypeList{},
576  NewStorageTypeList = NewStorageTypeList{}) const;
577 
580  VTKM_CONT vtkm::Id GetNumberOfValues() const;
581 
589  VTKM_CONT vtkm::IdComponent GetNumberOfComponents() const;
590 
607  VTKM_CONT vtkm::IdComponent GetNumberOfComponentsFlat() const;
608 
612  VTKM_CONT void Allocate(vtkm::Id numValues,
613  vtkm::CopyFlag preserve,
614  vtkm::cont::Token& token) const;
616  VTKM_CONT void Allocate(vtkm::Id numValues, vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const;
617 
625  template <typename ArrayHandleType>
626  VTKM_CONT bool CanConvert() const;
627 
628  // MSVC will issue deprecation warnings here if this template is instantiated with
629  // a deprecated class even if the template is used from a section of code where
630  // deprecation warnings are suppressed. This is annoying behavior since this template
631  // has no control over what class it is used with. To get around it, we have to
632  // suppress all deprecation warnings here.
633 #ifdef VTKM_MSVC
635 #endif
636 
637 private:
638  template <typename T, typename S>
640  {
641  using ArrayType = vtkm::cont::ArrayHandle<T, S>;
642  if (!this->IsType<ArrayType>())
643  {
644  VTKM_LOG_CAST_FAIL(*this, decltype(array));
645  throwFailedDynamicCast(this->GetArrayTypeName(), vtkm::cont::TypeToString(array));
646  }
647 
648  array = *reinterpret_cast<ArrayType*>(this->Container->ArrayHandlePointer);
649  }
650 
651 public:
656  template <typename T, typename S>
658  {
659  this->BaseAsArrayHandle(array);
660  }
662  template <typename T>
663  VTKM_CONT void AsArrayHandle(vtkm::cont::ArrayHandle<T>& array) const;
665  template <typename T, typename... Ss>
666  VTKM_CONT void AsArrayHandle(
669  template <typename TargetT, typename SourceT, typename SourceS>
672  {
673  using ContainedArrayType = vtkm::cont::ArrayHandle<SourceT, SourceS>;
675  this->AsArrayHandle<ContainedArrayType>());
676  }
678  template <typename T>
681  {
682  using BaseT = typename T::ComponentType;
683  if (this->IsStorageType<vtkm::cont::StorageTagBasic>() && this->IsBaseComponentType<BaseT>())
684  {
685  // Reinterpret the basic array as components, and then wrap that in a runtime vec
686  // with the correct amount of components.
688  this->Container->Buffers(this->Container->ArrayHandlePointer));
689  array =
690  vtkm::cont::ArrayHandleRuntimeVec<BaseT>(this->GetNumberOfComponentsFlat(), basicArray);
691  }
692  else
693  {
694  this->BaseAsArrayHandle(array);
695  }
696  }
698  template <typename ArrayType>
699  VTKM_CONT ArrayType AsArrayHandle() const
700  {
701  VTKM_IS_ARRAY_HANDLE(ArrayType);
702  ArrayType array;
703  this->AsArrayHandle(array);
704  return array;
705  }
706 
707 #ifdef VTKM_MSVC
709 #endif
710 
718  void DeepCopyFrom(const vtkm::cont::UnknownArrayHandle& source);
719 
727  void DeepCopyFrom(const vtkm::cont::UnknownArrayHandle& source) const;
728 
741  void CopyShallowIfPossible(const vtkm::cont::UnknownArrayHandle& source);
742 
757  void CopyShallowIfPossible(const vtkm::cont::UnknownArrayHandle& source) const;
758 
786  template <typename BaseComponentType>
788  vtkm::IdComponent componentIndex,
789  vtkm::CopyFlag allowCopy = vtkm::CopyFlag::On) const
790  {
791  using ComponentArrayType = vtkm::cont::ArrayHandleStride<BaseComponentType>;
792  if (!this->IsBaseComponentType<BaseComponentType>())
793  {
794  VTKM_LOG_CAST_FAIL(*this, ComponentArrayType);
795  throwFailedDynamicCast("UnknownArrayHandle with " + this->GetArrayTypeName(),
796  "component array of " + vtkm::cont::TypeToString<BaseComponentType>());
797  }
798 
799  auto buffers = this->Container->ExtractComponent(
800  this->Container->ArrayHandlePointer, componentIndex, allowCopy);
801  return ComponentArrayType(buffers);
802  }
803 
846  template <typename BaseComponentType>
848  vtkm::CopyFlag allowCopy = vtkm::CopyFlag::On) const
849  {
851  vtkm::IdComponent numComponents = this->GetNumberOfComponentsFlat();
852  for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
853  {
854  result.AppendComponentArray(this->ExtractComponent<BaseComponentType>(cIndex, allowCopy));
855  }
856  return result;
857  }
858 
868  template <typename TypeList, typename StorageList, typename Functor, typename... Args>
869  VTKM_CONT void CastAndCallForTypes(Functor&& functor, Args&&... args) const;
870 
884  template <typename TypeList, typename StorageList, typename Functor, typename... Args>
885  VTKM_CONT void CastAndCallForTypesWithFloatFallback(Functor&& functor, Args&&... args) const;
886 
908  template <typename Functor, typename... Args>
909  VTKM_CONT void CastAndCallWithExtractedArray(Functor&& functor, Args&&... args) const;
910 
914  VTKM_CONT void ReleaseResourcesExecution() const;
915 
918  VTKM_CONT void ReleaseResources() const;
919 
921  VTKM_CONT void PrintSummary(std::ostream& out, bool full = false) const;
922 };
923 
924 //=============================================================================
925 // Out of class implementations
926 
927 namespace detail
928 {
929 
930 template <typename T, typename S>
931 struct UnknownArrayHandleCanConvert
932 {
933  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle& array) const
934  {
935  return array.IsType<vtkm::cont::ArrayHandle<T, S>>();
936  }
937 };
938 
939 template <typename T>
940 struct UnknownArrayHandleCanConvert<T, vtkm::cont::StorageTagBasic>
941 {
942  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle& array) const
943  {
944  using UnrolledVec = vtkm::internal::UnrollVec<T>;
945  return (array.IsType<vtkm::cont::ArrayHandleBasic<T>>() ||
947  array.IsBaseComponentType<typename UnrolledVec::ComponentType>() &&
948  UnrolledVec::NUM_COMPONENTS == array.GetNumberOfComponentsFlat()));
949  }
950 };
951 
952 template <typename TargetT, typename SourceT, typename SourceS>
953 struct UnknownArrayHandleCanConvert<TargetT, vtkm::cont::StorageTagCast<SourceT, SourceS>>
954 {
955  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle& array) const
956  {
957  return UnknownArrayHandleCanConvert<SourceT, SourceS>{}(array);
958  }
959 };
960 
961 template <typename T>
962 struct UnknownArrayHandleCanConvertTry
963 {
964  template <typename S>
965  VTKM_CONT void operator()(S, const vtkm::cont::UnknownArrayHandle& array, bool& canConvert) const
966  {
967  canConvert |= UnknownArrayHandleCanConvert<T, S>{}(array);
968  }
969 };
970 
971 template <typename T, typename... Ss>
972 struct UnknownArrayHandleCanConvert<T, vtkm::cont::StorageTagMultiplexer<Ss...>>
973 {
974  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle& array) const
975  {
976  bool canConvert = false;
977  vtkm::ListForEach(UnknownArrayHandleCanConvertTry<T>{}, vtkm::List<Ss...>{}, array, canConvert);
978  return canConvert;
979  }
980 };
981 
982 template <typename T>
983 struct UnknownArrayHandleCanConvert<T, vtkm::cont::StorageTagRuntimeVec>
984 {
985  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle& array) const
986  {
987  using BaseComponentType = typename T::ComponentType;
990  array.IsBaseComponentType<BaseComponentType>()));
991  }
992 };
993 
994 } // namespace detail
995 
996 template <typename ArrayHandleType>
997 VTKM_CONT inline bool UnknownArrayHandle::CanConvert() const
998 {
999  VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
1000 
1001  return detail::UnknownArrayHandleCanConvert<typename ArrayHandleType::ValueType,
1002  typename ArrayHandleType::StorageTag>{}(*this);
1003 }
1004 
1005 namespace detail
1006 {
1007 
1008 template <typename T,
1011 struct UnknownArrayHandleRuntimeVecAsBasic
1012 {
1013  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle*,
1014  const detail::UnknownAHContainer*,
1016  {
1017  // This version only gets called if T contains a `Vec`-like object that is not a strict `Vec`.
1018  // This is rare but could happen. In this case, the type cannot be stored in an
1019  // `ArrayHandleRuntimeVec` and therefore the load can never happen, so just ignore.
1020  return false;
1021  }
1022 };
1023 
1024 template <typename T>
1025 struct UnknownArrayHandleRuntimeVecAsBasic<T, 1>
1026 {
1027  VTKM_CONT bool operator()(const vtkm::cont::UnknownArrayHandle* self,
1028  const detail::UnknownAHContainer* container,
1029  vtkm::cont::ArrayHandle<T>& array) const
1030  {
1031  using UnrolledVec = vtkm::internal::UnrollVec<T>;
1032  using ComponentType = typename UnrolledVec::ComponentType;
1033  if (self->IsStorageType<vtkm::cont::StorageTagRuntimeVec>() &&
1034  self->IsBaseComponentType<ComponentType>() &&
1035  UnrolledVec::NUM_COMPONENTS == self->GetNumberOfComponentsFlat())
1036  {
1037  // Pull out the components array out of the buffers. The array might not match exactly
1038  // the array put in, but the buffer should still be consistent with the array (which works
1039  // because the size of a basic array is based on the number of bytes in the buffer).
1040  using RuntimeVecType = typename vtkm::cont::ArrayHandleRuntimeVec<ComponentType>::ValueType;
1041  using StorageRuntimeVec =
1042  vtkm::cont::internal::Storage<RuntimeVecType, vtkm::cont::StorageTagRuntimeVec>;
1043  StorageRuntimeVec::AsArrayHandleBasic(container->Buffers(container->ArrayHandlePointer),
1044  array);
1045  return true;
1046  }
1047  else
1048  {
1049  return false;
1050  }
1051  }
1052 };
1053 
1054 } // namespace detail
1055 
1056 template <typename T>
1057 VTKM_CONT inline void UnknownArrayHandle::AsArrayHandle(vtkm::cont::ArrayHandle<T>& array) const
1058 {
1059  if (!detail::UnknownArrayHandleRuntimeVecAsBasic<T>{}(this, this->Container.get(), array))
1060  {
1061  this->BaseAsArrayHandle(array);
1062  }
1063 }
1064 
1065 namespace detail
1066 {
1067 
1068 struct UnknownArrayHandleMultiplexerCastTry
1069 {
1070  template <typename T, typename S, typename... Ss>
1071  VTKM_CONT void operator()(
1072  S,
1073  const vtkm::cont::UnknownArrayHandle& unknownArray,
1075  bool& converted) const
1076  {
1077  using ArrayType = vtkm::cont::ArrayHandle<T, S>;
1078  if (unknownArray.CanConvert<ArrayType>())
1079  {
1080  if (converted && !unknownArray.IsType<ArrayType>())
1081  {
1082  // The array has already been converted and pushed in the multiplexer. It is
1083  // possible that multiple array types can be put in the ArrayHandleMultiplexer
1084  // (for example, and ArrayHandle or an ArrayHandle that has been cast). Exact
1085  // matches will override other matches (hence, the second part of the condition),
1086  // but at this point we have already found a better array to put inside.
1087  return;
1088  }
1090  unknownArray.AsArrayHandle<ArrayType>());
1091  converted = true;
1092  }
1093  }
1094 };
1095 
1096 } // namespace detail
1097 
1098 template <typename T, typename... Ss>
1099 void UnknownArrayHandle::AsArrayHandle(
1101 {
1102  bool converted = false;
1104  detail::UnknownArrayHandleMultiplexerCastTry{}, vtkm::List<Ss...>{}, *this, array, converted);
1105 
1106  if (!converted)
1107  {
1108  VTKM_LOG_CAST_FAIL(*this, decltype(array));
1110  }
1111 }
1112 
1113 namespace detail
1114 {
1115 
1116 struct UnknownArrayHandleTry
1117 {
1118  template <typename T, typename S, typename Functor, typename... Args>
1119  void operator()(vtkm::List<T, S>,
1120  Functor&& f,
1121  bool& called,
1122  const vtkm::cont::UnknownArrayHandle& unknownArray,
1123  Args&&... args) const
1124  {
1125  using DerivedArrayType = vtkm::cont::ArrayHandle<T, S>;
1126  if (!called && unknownArray.CanConvert<DerivedArrayType>())
1127  {
1128  called = true;
1129  DerivedArrayType derivedArray;
1130  unknownArray.AsArrayHandle(derivedArray);
1131  VTKM_LOG_CAST_SUCC(unknownArray, derivedArray);
1132 
1133  // If you get a compile error here, it means that you have called CastAndCall for a
1134  // vtkm::cont::UnknownArrayHandle and the arguments of the functor do not match those
1135  // being passed. This is often because it is calling the functor with an ArrayHandle
1136  // type that was not expected. Either add overloads to the functor to accept all
1137  // possible array types or constrain the types tried for the CastAndCall. Note that
1138  // the functor will be called with an array of type vtkm::cont::ArrayHandle<T, S>.
1139  // Directly using a subclass of ArrayHandle (e.g. vtkm::cont::ArrayHandleConstant<T>)
1140  // might not work.
1141  f(derivedArray, std::forward<Args>(args)...);
1142  }
1143  }
1144 };
1145 
1146 } // namespace detail
1147 
1148 namespace internal
1149 {
1150 
1151 namespace detail
1152 {
1153 
1154 template <typename T>
1155 struct IsUndefinedArrayType
1156 {
1157 };
1158 template <typename T, typename S>
1159 struct IsUndefinedArrayType<vtkm::List<T, S>> : vtkm::cont::internal::IsInvalidArrayHandle<T, S>
1160 {
1161 };
1162 
1163 } // namespace detail
1164 
1165 template <typename ValueTypeList, typename StorageTypeList>
1166 using ListAllArrayTypes =
1168 
1169 VTKM_CONT_EXPORT void ThrowCastAndCallException(const vtkm::cont::UnknownArrayHandle&,
1170  const std::type_info&);
1171 
1172 } // namespace internal
1173 
1174 template <typename TypeList, typename StorageTagList, typename Functor, typename... Args>
1175 inline void UnknownArrayHandle::CastAndCallForTypes(Functor&& f, Args&&... args) const
1176 {
1177  using crossProduct = internal::ListAllArrayTypes<TypeList, StorageTagList>;
1178 
1179  bool called = false;
1180  vtkm::ListForEach(detail::UnknownArrayHandleTry{},
1181  crossProduct{},
1182  std::forward<Functor>(f),
1183  called,
1184  *this,
1185  std::forward<Args>(args)...);
1186  if (!called)
1187  {
1188  // throw an exception
1189  VTKM_LOG_CAST_FAIL(*this, TypeList);
1190  internal::ThrowCastAndCallException(*this, typeid(TypeList));
1191  }
1192 }
1193 
1194 template <typename TypeList, typename StorageTagList, typename Functor, typename... Args>
1195 VTKM_CONT void UnknownArrayHandle::CastAndCallForTypesWithFloatFallback(Functor&& functor,
1196  Args&&... args) const
1197 {
1198  using crossProduct = internal::ListAllArrayTypes<TypeList, StorageTagList>;
1199 
1200  bool called = false;
1201  vtkm::ListForEach(detail::UnknownArrayHandleTry{},
1202  crossProduct{},
1203  std::forward<Functor>(functor),
1204  called,
1205  *this,
1206  std::forward<Args>(args)...);
1207  if (!called)
1208  {
1209  // Copy to a float array and try again
1211  "Cast and call from %s failed. Copying to basic float array.",
1212  this->GetArrayTypeName().c_str());
1213  vtkm::cont::UnknownArrayHandle floatArray = this->NewInstanceFloatBasic();
1214  floatArray.DeepCopyFrom(*this);
1215  vtkm::ListForEach(detail::UnknownArrayHandleTry{},
1216  crossProduct{},
1217  std::forward<Functor>(functor),
1218  called,
1219  floatArray,
1220  std::forward<Args>(args)...);
1221  }
1222  if (!called)
1223  {
1224  // throw an exception
1225  VTKM_LOG_CAST_FAIL(*this, TypeList);
1226  internal::ThrowCastAndCallException(*this, typeid(TypeList));
1227  }
1228 }
1229 
1230 //=============================================================================
1231 // Free function casting helpers
1232 
1235 template <typename ArrayHandleType>
1237 {
1238  return array.template IsType<ArrayHandleType>();
1239 }
1240 
1245 template <typename ArrayHandleType>
1246 VTKM_CONT inline ArrayHandleType Cast(const vtkm::cont::UnknownArrayHandle& array)
1247 {
1248  return array.template AsArrayHandle<ArrayHandleType>();
1249 }
1250 
1251 namespace detail
1252 {
1253 
1254 struct UnknownArrayHandleTryExtract
1255 {
1256  template <typename T, typename Functor, typename... Args>
1257  void operator()(T,
1258  Functor&& f,
1259  bool& called,
1260  const vtkm::cont::UnknownArrayHandle& unknownArray,
1261  Args&&... args) const
1262  {
1263  if (!called && unknownArray.IsBaseComponentType<T>())
1264  {
1265  called = true;
1266  auto extractedArray = unknownArray.ExtractArrayFromComponents<T>();
1267  VTKM_LOG_CAST_SUCC(unknownArray, extractedArray);
1268 
1269  // If you get a compile error here, it means that you have called
1270  // CastAndCallWithExtractedArray for a vtkm::cont::UnknownArrayHandle and the arguments of
1271  // the functor do not match those being passed. This is often because it is calling the
1272  // functor with an ArrayHandle type that was not expected. Add overloads to the functor to
1273  // accept all possible array types or constrain the types tried for the CastAndCall. Note
1274  // that the functor will be called with an array of type that is different than the actual
1275  // type of the `ArrayHandle` stored in the `UnknownArrayHandle`.
1276  f(extractedArray, std::forward<Args>(args)...);
1277  }
1278  }
1279 };
1280 
1281 } // namespace detail
1282 
1283 template <typename Functor, typename... Args>
1284 inline void UnknownArrayHandle::CastAndCallWithExtractedArray(Functor&& functor,
1285  Args&&... args) const
1286 {
1287  bool called = false;
1288  vtkm::ListForEach(detail::UnknownArrayHandleTryExtract{},
1290  std::forward<Functor>(functor),
1291  called,
1292  *this,
1293  std::forward<Args>(args)...);
1294  if (!called)
1295  {
1296  // Throw an exception.
1297  // The message will be a little wonky because the types are just the value types, not the
1298  // full type to cast to.
1300  internal::ThrowCastAndCallException(*this, typeid(vtkm::TypeListScalarAll));
1301  }
1302 }
1303 
1304 }
1305 } // namespace vtkm::cont
1306 
1307 //=============================================================================
1308 // Specializations of serialization related classes
1310 
1311 namespace vtkm
1312 {
1313 namespace cont
1314 {
1315 
1316 template <>
1317 struct VTKM_CONT_EXPORT SerializableTypeString<vtkm::cont::UnknownArrayHandle>
1318 {
1319  static VTKM_CONT std::string Get();
1320 };
1321 }
1322 } // namespace vtkm::cont
1323 
1324 namespace mangled_diy_namespace
1325 {
1326 
1327 template <>
1328 struct VTKM_CONT_EXPORT Serialization<vtkm::cont::UnknownArrayHandle>
1329 {
1330 public:
1331  static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::cont::UnknownArrayHandle& obj);
1332  static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::UnknownArrayHandle& obj);
1333 };
1334 
1335 } // namespace mangled_diy_namespace
1336 
1338 
1339 #endif //vtk_m_cont_UnknownArrayHandle_h
vtkm::cont::UnknownArrayHandle::CanConvert
bool CanConvert() const
Determine if the contained array can be passed to the given array type.
Definition: UnknownArrayHandle.h:997
vtkm::cont::TypeToString
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
vtkm::cont::UnknownArrayHandle::IsValueType
bool IsValueType() const
Returns true if this array matches the ValueType template argument.
Definition: UnknownArrayHandle.h:515
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
ArrayHandle.h
ArrayExtractComponent.h
vtkm::cont::ArrayExtractComponent
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
vtkm::cont::UnknownArrayHandle::AsArrayHandle
void AsArrayHandle(vtkm::cont::ArrayHandle< TargetT, vtkm::cont::StorageTagCast< SourceT, SourceS >> &array) const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:670
vtkm::cont::ArrayHandle::GetBuffers
const std::vector< vtkm::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:721
vtkm::cont::ArrayHandleRecombineVec
A grouping of ArrayHandleStrides into an ArrayHandle of vtkm::Vecs.
Definition: ArrayHandleRecombineVec.h:610
ArrayHandleStride.h
vtkm::cont::UnknownArrayHandle::IsBaseComponentType
bool IsBaseComponentType() const
Returns true if this array's ValueType has the provided base component type.
Definition: UnknownArrayHandle.h:540
vtkm::exec::arg::load
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::UnknownArrayHandle::AsArrayHandle
void AsArrayHandle(vtkm::cont::ArrayHandle< T, vtkm::cont::StorageTagRuntimeVec > &array) const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:679
vtkm::Get
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
ArrayHandleCast.h
VTKM_LOG_CAST_FAIL
#define VTKM_LOG_CAST_FAIL(inObj, outType)
Convenience macro for logging a failed cast of dynamic object.
Definition: Logging.h:230
ArrayHandleRecombineVec.h
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::cont::IsType
bool IsType(const vtkm::cont::UnknownArrayHandle &array)
Returns true if variant matches the type of ArrayHandleType.
Definition: UnknownArrayHandle.h:1236
vtkm::cont::printSummary_ArrayHandle
void printSummary_ArrayHandle(const vtkm::cont::ArrayHandle< T, StorageT > &array, std::ostream &out, bool full=false)
Definition: ArrayHandle.h:814
vtkm::cont::ArrayHandle::ReleaseResourcesExecution
void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:577
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
vtkm::cont::ArrayHandleRecombineVec::AppendComponentArray
void AppendComponentArray(const vtkm::cont::ArrayHandle< ComponentType, vtkm::cont::StorageTagStride > &array)
Add a component array.
Definition: ArrayHandleRecombineVec.h:648
vtkm::cont::UnknownArrayHandle::UnknownArrayHandle
UnknownArrayHandle(const vtkm::cont::ArrayHandle< T, S > &array)
Definition: UnknownArrayHandle.h:442
vtkm::cont::ArrayHandle::GetNumberOfValues
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
vtkm::cont::UnknownArrayHandle::AsArrayHandle
ArrayType AsArrayHandle() const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:699
vtkm::cont::ArrayHandleMultiplexer
An ArrayHandle that can behave like several other handles.
Definition: ArrayHandleMultiplexer.h:416
vtkm::cont::ArrayHandleRuntimeVec::ValueType
typename Superclass::ValueType ValueType
Definition: ArrayHandleRuntimeVec.h:338
vtkm::ListRemoveIf
typename detail::ListRemoveIfImpl< List, Predicate >::type ListRemoveIf
Takes an existing List and a predicate template that is applied to each type in the List.
Definition: List.h:680
vtkm::cont::UnknownArrayHandle::AsArrayHandle
void AsArrayHandle(vtkm::cont::ArrayHandle< T, S > &array) const
Returns this array cast appropriately and stored in the given ArrayHandle type.
Definition: UnknownArrayHandle.h:657
vtkm::cont::ErrorBadType
This class is thrown when VTK-m encounters data of a type that is incompatible with the current opera...
Definition: ErrorBadType.h:25
mangled_diy_namespace
Definition: Particle.h:351
vtkm::cont::UnknownArrayHandle::DeepCopyFrom
void DeepCopyFrom(const vtkm::cont::UnknownArrayHandle &source)
Deep copies data from another UnknownArrayHandle.
VTKM_DEPRECATED_SUPPRESS_END
#define VTKM_DEPRECATED_SUPPRESS_END
Definition: Deprecated.h:123
vtkm::cont::ArrayHandleStride
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:332
vtkm::VecTraits::BaseComponentType
T BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:78
vtkm::cont::throwFailedDynamicCast
void throwFailedDynamicCast(const std::string &baseType, const std::string &derivedType)
Throws an ErrorBadType exception with the following message: Cast failed: baseType --> derivedType".
vtkm::cont::StorageTagCast
Definition: ArrayHandleCast.h:28
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::VecTraitsTagSizeVariable
A tag for vectors where the number of components are not determined until run time.
Definition: VecTraits.h:43
vtkm::cont::LogLevel::Info
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
vtkm::cont::UnknownArrayHandle::GetNumberOfComponentsFlat
vtkm::IdComponent GetNumberOfComponentsFlat() const
Returns the total number of components for each value in the array.
vtkm::cont::ArrayHandleCast::GetSourceArray
ArrayHandleType GetSourceArray() const
Returns the ArrayHandle that is being transformed.
Definition: ArrayHandleCast.h:169
VTKM_IS_ARRAY_HANDLE
#define VTKM_IS_ARRAY_HANDLE(T)
Checks that the given type is a vtkm::cont::ArrayHandle.
Definition: ArrayHandle.h:137
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
VTKM_LOG_CAST_SUCC
#define VTKM_LOG_CAST_SUCC(inObj, outObj)
Convenience macro for logging the successful cast of dynamic object.
Definition: Logging.h:221
vtkm_cont_export.h
VTKM_LOG_F
#define VTKM_LOG_F(level,...)
Writes a message using printf syntax to the indicated log level.
Definition: Logging.h:209
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandle::ReleaseResources
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
TypeList.h
vtkm::CopyFlag::On
@ On
vtkm::cont::ArrayHandleRuntimeVec
Fancy array handle for a basic array with runtime selected vec size.
Definition: ArrayHandleRuntimeVec.h:327
VTKM_DEPRECATED_SUPPRESS_BEGIN
#define VTKM_DEPRECATED_SUPPRESS_BEGIN
Definition: Deprecated.h:122
vtkm::ListForEach
void ListForEach(Functor &&f, vtkm::List< Ts... >, Args &&... args)
For each typename represented by the list, call the functor with a default instance of that type.
Definition: List.h:725
vtkm::cont::Cast
ArrayHandleType Cast(const vtkm::cont::UnknownArrayHandle &array)
Returns variant cast to the given ArrayHandle type.
Definition: UnknownArrayHandle.h:1246
vtkm::cont::ArrayHandle::DeepCopyFrom
void DeepCopyFrom(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:707
vtkm::CopyFlag::Off
@ Off
vtkm::cont::UncertainArrayHandle
An ArrayHandle of an uncertain value type and storage.
Definition: UncertainArrayHandle.h:39
vtkm::VecTraitsTagSizeStatic
A tag for vectors where the number of components are known at compile time.
Definition: VecTraits.h:36
ArrayHandleMultiplexer.h
vtkm::cont::ArrayHandleCast
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
Deprecated.h
vtkm::cont::StorageTagRuntimeVec
Definition: ArrayHandleRuntimeVec.h:129
vtkm::List
A template used to hold a list of types.
Definition: List.h:39
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
vtkm::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
vtkm::cont::UnknownArrayHandle::ExtractArrayFromComponents
vtkm::cont::ArrayHandleRecombineVec< BaseComponentType > ExtractArrayFromComponents(vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On) const
Extract the array knowing only the component type of the array.
Definition: UnknownArrayHandle.h:847
vtkm::cont::UnknownArrayHandle::BaseAsArrayHandle
void BaseAsArrayHandle(vtkm::cont::ArrayHandle< T, S > &array) const
Definition: UnknownArrayHandle.h:639
ArrayHandleRuntimeVec.h
vtkm::cont::operator==
bool operator==(const vtkm::cont::Token &token, vtkm::cont::Token::Reference ref)
Definition: Token.h:173
vtkm::cont::ArrayHandle::Allocate
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
StorageList.h
vtkm::cont::ArrayHandleBasic
Basic array storage for an array handle.
Definition: ArrayHandleBasic.h:111
vtkm::VecTraits
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
vtkm::cont::ArrayHandle::GetNumberOfComponentsFlat
vtkm::IdComponent GetNumberOfComponentsFlat() const
Returns the total number of components for each value in the array.
Definition: ArrayHandle.h:474
vtkm::cont::UnknownArrayHandle::IsStorageType
bool IsStorageType() const
Returns true if this array matches the StorageType template argument.
Definition: UnknownArrayHandle.h:523
vtkm::cont::UnknownArrayHandle::IsType
bool IsType() const
Returns true if this array matches the ArrayHandleType template argument.
Definition: UnknownArrayHandle.h:558
vtkm::cont::UnknownArrayHandle::ExtractComponent
vtkm::cont::ArrayHandleStride< BaseComponentType > ExtractComponent(vtkm::IdComponent componentIndex, vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On) const
Extract a component of the array.
Definition: UnknownArrayHandle.h:787
VecTraits.h
vtkm::cont::UnknownArrayHandle::Container
std::shared_ptr< detail::UnknownAHContainer > Container
Definition: UnknownArrayHandle.h:432
vtkm::cont::StorageTagMultiplexer
Definition: ArrayHandleMultiplexer.h:141