Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayRangeComputeTemplate_h
11 #define vtk_m_cont_ArrayRangeComputeTemplate_h
36 struct ComputeRangeOptionsDecorator
38 bool IgnoreInf =
false;
40 template <
typename SrcPortal,
typename MaskPortal>
47 using InValueType =
typename SrcPortal::ValueType;
52 ResultType operator()(
vtkm::Id idx)
const
54 if ((this->Mask.GetNumberOfValues() != 0) && (this->Mask.Get(idx) == 0))
59 const auto& inVal = this->Src.Get(idx);
64 if (vtkm::IsNan(val) || (this->IgnoreInf && !vtkm::IsFinite(val)))
71 outVal[0][i] = outVal[1][i] = val;
79 template <
typename SrcPortal,
typename GhostPortal>
80 Functor<SrcPortal, GhostPortal> CreateFunctor(
const SrcPortal& sp,
const GhostPortal& gp)
const
82 return { sp, gp, this->IgnoreInf };
86 template <
typename ArrayHandleType>
87 struct ArrayValueIsNested
89 static constexpr
bool Value =
90 !vtkm::internal::IsFlatVec<typename ArrayHandleType::ValueType>::value;
93 template <typename ArrayHandleType, bool IsNested = ArrayValueIsNested<ArrayHandleType>::Value>
96 template <
typename ArrayHandleType>
97 struct NestedToFlat<ArrayHandleType, true>
99 static auto Transform(
const ArrayHandleType& in)
102 ArrayHandleType>(in);
106 template <
typename ArrayHandleType>
107 struct NestedToFlat<ArrayHandleType, false>
109 static auto Transform(
const ArrayHandleType& in) {
return in; }
112 template <
typename ArrayHandleType>
113 inline auto NestedToFlatTransform(
const ArrayHandleType& input)
122 template <
typename T,
typename S>
126 bool computeFiniteRange,
145 auto flattened = NestedToFlatTransform(input);
146 ComputeRangeOptionsDecorator decorator{ computeFiniteRange };
159 portal.Set(i,
vtkm::Range(result[0][i], result[1][i]));
167 struct ScalarMagnitudeFunctor
169 template <
typename T>
178 struct MagnitudeSquareFunctor
180 template <
typename T>
188 result += comp * comp;
194 template <
typename ArrayHandleType>
197 const ArrayHandleType& input,
199 bool computeFiniteRange,
203 auto rangeAH = ArrayRangeComputeGeneric(mag, maskArray, computeFiniteRange, device);
204 return rangeAH.ReadPortal().Get(0);
207 template <
typename ArrayHandleType>
210 const ArrayHandleType& input,
212 bool computeFiniteRange,
216 auto rangeAH = ArrayRangeComputeGeneric(magsqr, maskArray, computeFiniteRange, device);
218 if (range.IsNonEmpty())
229 template <
typename T,
typename S>
230 inline vtkm::Range ArrayRangeComputeMagnitudeGeneric(
233 bool computeFiniteRange,
247 auto flattened = NestedToFlatTransform(input);
248 return ArrayRangeComputeMagnitudeGenericImpl(
253 template <
typename S>
254 struct ArrayRangeComputeImpl
256 template <
typename T>
260 bool computeFiniteRange,
263 return vtkm::cont::internal::ArrayRangeComputeGeneric(
264 input, maskArray, computeFiniteRange, device);
268 template <
typename S>
269 struct ArrayRangeComputeMagnitudeImpl
271 template <
typename T>
274 bool computeFiniteRange,
277 return vtkm::cont::internal::ArrayRangeComputeMagnitudeGeneric(
278 input, maskArray, computeFiniteRange, device);
289 template <
typename T,
typename S>
292 bool computeFiniteRange =
false,
299 template <
typename T,
typename S>
303 bool computeFiniteRange =
false,
308 return internal::ArrayRangeComputeImpl<S>{}(input, maskArray, computeFiniteRange, device);
311 template <
typename T,
typename S>
325 template <
typename T,
typename S>
328 bool computeFiniteRange =
false,
335 template <
typename T,
typename S>
339 bool computeFiniteRange =
false,
344 return internal::ArrayRangeComputeMagnitudeImpl<S>{}(
345 input, maskArray, computeFiniteRange, device);
348 template <
typename T,
typename S>
357 template <
typename ArrayHandleType>
358 VTKM_DEPRECATED(2.1,
"Use precompiled ArrayRangeCompute or ArrayRangeComputeTemplate.")
360 const ArrayHandleType& input,
369 #define VTK_M_ARRAY_RANGE_COMPUTE_DCLR(...) \
370 vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
371 const vtkm::cont::ArrayHandle<__VA_ARGS__>&, \
372 const vtkm::cont::ArrayHandle<vtkm::UInt8>&, \
374 vtkm::cont::DeviceAdapterId)
376 #define VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(...) \
377 vtkm::Range vtkm::cont::ArrayRangeComputeMagnitudeTemplate( \
378 const vtkm::cont::ArrayHandle<__VA_ARGS__>&, \
379 const vtkm::cont::ArrayHandle<vtkm::UInt8>&, \
381 vtkm::cont::DeviceAdapterId)
383 #define VTK_M_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers, ...) \
384 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Int8, __VA_ARGS__); \
385 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Int8, __VA_ARGS__); \
386 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::UInt8, __VA_ARGS__); \
387 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::UInt8, __VA_ARGS__); \
388 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Int16, __VA_ARGS__); \
389 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Int16, __VA_ARGS__); \
390 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::UInt16, __VA_ARGS__); \
391 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::UInt16, __VA_ARGS__); \
392 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Int32, __VA_ARGS__); \
393 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Int32, __VA_ARGS__); \
394 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::UInt32, __VA_ARGS__); \
395 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::UInt32, __VA_ARGS__); \
396 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Int64, __VA_ARGS__); \
397 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Int64, __VA_ARGS__); \
398 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::UInt64, __VA_ARGS__); \
399 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::UInt64, __VA_ARGS__)
401 #define VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers, ...) \
402 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Float32, __VA_ARGS__); \
403 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Float32, __VA_ARGS__); \
404 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Float64, __VA_ARGS__); \
405 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Float64, __VA_ARGS__)
407 #define VTK_M_ARRAY_RANGE_COMPUTE_BOOL_SCALARS(modifiers, ...) \
408 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(bool, __VA_ARGS__); \
409 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(bool, __VA_ARGS__)
411 #define VTK_M_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers, ...) \
412 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(char, __VA_ARGS__); \
413 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(char, __VA_ARGS__); \
414 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(signed VTKM_UNUSED_INT_TYPE, __VA_ARGS__); \
415 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(signed VTKM_UNUSED_INT_TYPE, __VA_ARGS__); \
416 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(unsigned VTKM_UNUSED_INT_TYPE, __VA_ARGS__); \
417 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(unsigned VTKM_UNUSED_INT_TYPE, __VA_ARGS__)
419 #define VTK_M_ARRAY_RANGE_COMPUTE_ALL_SCALARS(modifiers, ...) \
420 VTK_M_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers, __VA_ARGS__); \
421 VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers, __VA_ARGS__); \
422 VTK_M_ARRAY_RANGE_COMPUTE_BOOL_SCALARS(modifiers, __VA_ARGS__); \
423 VTK_M_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers, __VA_ARGS__)
425 #define VTK_M_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N, ...) \
426 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Int8, N>, __VA_ARGS__); \
427 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Int8, N>, __VA_ARGS__); \
428 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::UInt8, N>, __VA_ARGS__); \
429 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::UInt8, N>, __VA_ARGS__); \
430 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Int16, N>, __VA_ARGS__); \
431 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Int16, N>, __VA_ARGS__); \
432 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::UInt16, N>, __VA_ARGS__); \
433 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::UInt16, N>, __VA_ARGS__); \
434 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Int32, N>, __VA_ARGS__); \
435 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Int32, N>, __VA_ARGS__); \
436 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::UInt32, N>, __VA_ARGS__); \
437 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::UInt32, N>, __VA_ARGS__); \
438 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Int64, N>, __VA_ARGS__); \
439 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Int64, N>, __VA_ARGS__); \
440 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::UInt64, N>, __VA_ARGS__); \
441 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::UInt64, N>, __VA_ARGS__)
443 #define VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N, ...) \
444 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Float32, N>, __VA_ARGS__); \
445 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Float32, N>, __VA_ARGS__); \
446 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<vtkm::Float64, N>, __VA_ARGS__); \
447 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<vtkm::Float64, N>, __VA_ARGS__)
449 #define VTK_M_ARRAY_RANGE_COMPUTE_BOOL_VECN(modifiers, N, ...) \
450 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<bool, N>, __VA_ARGS__); \
451 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<bool, N>, __VA_ARGS__)
453 #define VTK_M_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N, ...) \
454 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<char, N>, __VA_ARGS__); \
455 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<char, N>, __VA_ARGS__); \
456 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<signed VTKM_UNUSED_INT_TYPE, N>, \
458 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<signed VTKM_UNUSED_INT_TYPE, N>, \
460 modifiers VTK_M_ARRAY_RANGE_COMPUTE_DCLR(vtkm::Vec<unsigned VTKM_UNUSED_INT_TYPE, N>, \
462 modifiers VTK_M_ARRAY_RANGE_COMPUTE_MAG_DCLR(vtkm::Vec<unsigned VTKM_UNUSED_INT_TYPE, N>, \
465 #define VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(modifiers, N, ...) \
466 VTK_M_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N, __VA_ARGS__); \
467 VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N, __VA_ARGS__); \
468 VTK_M_ARRAY_RANGE_COMPUTE_BOOL_VECN(modifiers, N, __VA_ARGS__); \
469 VTK_M_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N, __VA_ARGS__)
476 struct StorageTagSOA;
478 template <
typename ST1,
typename ST2,
typename ST3>
479 struct StorageTagCartesianProduct;
481 struct StorageTagConstant;
483 struct StorageTagCounting;
485 struct StorageTagXGCCoordinates;
487 struct StorageTagStride;
550 StorageTagXGCCoordinates);
630 #endif //vtk_m_cont_ArrayRangeComputeTemplate_h
#define VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:401
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:211
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
vtkm::Float32 Sqrt(vtkm::Float32 x)
Definition: Math.h:943
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
Binary Predicate that takes two arguments argument x, and y and returns a vtkm::Vec<T,...
Definition: BinaryOperators.h:112
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
auto Transform(const TupleType &&tuple, Function &&f) -> decltype(Apply(tuple, detail::TupleTransformFunctor(), std::forward< Function >(f)))
Construct a new vtkm::Tuple by applying a function to each value.
Definition: Tuple.h:213
void Fill(const ValueType &fillValue, vtkm::Id startIndex, vtkm::Id endIndex, vtkm::cont::Token &token) const
Fills the array with a given value.
Definition: ArrayHandle.h:554
static constexpr vtkm::IdComponent NUM_COMPONENTS
Number of components in the vector.
Definition: VecTraits.h:85
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
Definition: ArrayHandleCartesianProduct.h:161
static U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:657
#define VTK_M_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:443
#define VTK_M_ARRAY_RANGE_COMPUTE_ALL_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:419
Definition: ArrayHandleConstant.h:27
#define VTK_M_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:411
Definition: ArrayHandleCounting.h:27
static constexpr vtkm::IdComponent GetNumberOfComponents(const T &)
Returns the number of components in the given vector.
Definition: VecTraits.h:94
vtkm::Range ArrayRangeComputeMagnitudeTemplate(const vtkm::cont::ArrayHandle< T, S > &input, bool computeFiniteRange=false, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
Templated version of ArrayRangeComputeMagnitude.
Definition: ArrayRangeComputeTemplate.h:326
#define VTKM_INSTANTIATION_END
Definition: Instantiations.h:48
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
Tag for a device adapter used to specify that any device may be used for an operation.
Definition: DeviceAdapterTag.h:180
vtkm::cont::ArrayHandle< vtkm::Range > ArrayRangeComputeTemplate(const vtkm::cont::ArrayHandle< T, S > &input, bool computeFiniteRange=false, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
Templated version of ArrayRangeCompute.
Definition: ArrayRangeComputeTemplate.h:290
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
#define VTK_M_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:383
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
#define VTKM_CONT_TEMPLATE_EXPORT
Definition: vtkm_cont_export.h:62
A short fixed-length array.
Definition: Types.h:357
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
static const ComponentType & GetComponent(const T &vector, vtkm::IdComponent)
Returns the value in a given component of the vector.
Definition: VecTraits.h:117
vtkm::VecTraitsTagSingleComponent HasMultipleComponents
A tag specifying whether this vector has multiple components (i.e.
Definition: VecTraits.h:105
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
vtkm::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:34
#define VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:465
vtkm::cont::ArrayHandle< vtkm::Range > ArrayRangeCompute(const vtkm::cont::UnknownArrayHandle &array, bool computeFiniteRange=false, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
Compute the range of the data in an array handle.
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
#define VTK_M_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:453
#define VTK_M_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:425
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
vtkm::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:36
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
vtkm::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:480
#define VTKM_DEPRECATED(...)
Definition: Deprecated.h:145
#define VTKM_INSTANTIATION_BEGIN
The following empty macros are instantiation delimiters used by vtk_add_instantiations at CMake/VTKmW...
Definition: Instantiations.h:47
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
ArrayHandleDecorator< typename std::decay< DecoratorImplT >::type, typename std::decay< ArrayTs >::type... > make_ArrayHandleDecorator(vtkm::Id numValues, DecoratorImplT &&f, ArrayTs &&... arrays)
Create an ArrayHandleDecorator with the specified number of values that uses the provided DecoratorIm...
Definition: ArrayHandleDecorator.h:694
Represent a continuous scalar range of values.
Definition: Range.h:31