VTK
9.1.0
|
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate. More...
Namespaces | |
namespace | detail |
namespace | hypertreegrid |
Classes | |
class | CompositeDataSetNodeReference |
A reference proxy into a vtkCompositeDataSet, obtained by dereferencing an iterator from the vtk::Range(vtkCompositeDataSet*) overloads. More... | |
Typedefs | |
using | ComponentIdType = int |
using | TupleIdType = vtkIdType |
using | ValueIdType = vtkIdType |
template<typename ArrayType , typename = detail::EnableIfVtkDataArray<ArrayType>> | |
using | GetAPIType = typename detail::GetAPITypeImpl< ArrayType >::APIType |
template<typename ArrayType > | |
using | IsAOSDataArray = std::integral_constant< bool, detail::IsAOSDataArrayImpl< ArrayType >::value > |
Enumerations | |
enum class | CompositeDataSetOptions : unsigned int { None = 0 , SkipEmptyNodes = 1 << 1 } |
enum class | DataObjectTreeOptions : unsigned int { None = 0 , SkipEmptyNodes = 1 << 1 , VisitOnlyLeaves = 1 << 2 , TraverseSubTree = 1 << 3 } |
Functions | |
template<ComponentIdType TupleSize = detail::DynamicTupleSize, typename ArrayTypePtr = vtkDataArray*> | |
VTK_ITER_INLINE auto | DataArrayTupleRange (const ArrayTypePtr &array, TupleIdType start=-1, TupleIdType end=-1) -> typename detail::SelectTupleRange< ArrayTypePtr, TupleSize >::type |
Generate an stl and for-range compatible range of tuple iterators from a vtkDataArray. More... | |
template<ComponentIdType TupleSize = detail::DynamicTupleSize, typename ArrayTypePtr = vtkDataArray*> | |
VTK_ITER_INLINE auto | DataArrayValueRange (const ArrayTypePtr &array, ValueIdType start=-1, ValueIdType end=-1) -> typename detail::SelectValueRange< ArrayTypePtr, TupleSize >::type |
Generate an stl and for-range compatible range of flat AOS iterators from a vtkDataArray. More... | |
template<typename IterablePtr , typename... Options> | |
auto | Range (IterablePtr iterable, Options &&... opts) -> typename detail::IterableTraits< typename detail::StripPointers< IterablePtr >::type >::RangeType |
Generate an iterable STL proxy object for a VTK container. More... | |
template<typename T > | |
vtkSmartPointer< T > | MakeSmartPointer (T *obj) |
Construct a vtkSmartPointer<T> containing obj. More... | |
template<typename T > | |
vtkSmartPointer< T > | TakeSmartPointer (T *obj) |
Construct a vtkSmartPointer<T> containing obj. More... | |
template<typename T > | |
vtkWeakPointer< T > | TakeWeakPointer (T *obj) |
Construct a vtkWeakPointer<T> containing obj. More... | |
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
Compare smart pointer values.
Specialization of value ranges and iterators for vtkAOSDataArrayTemplate.
Generic implementation of value ranges and iterators, suitable for vtkDataArray and all subclasses.
using vtk::ComponentIdType = typedef int |
Definition at line 68 of file vtkDataArrayMeta.h.
using vtk::TupleIdType = typedef vtkIdType |
Definition at line 69 of file vtkDataArrayMeta.h.
using vtk::ValueIdType = typedef vtkIdType |
Definition at line 70 of file vtkDataArrayMeta.h.
using vtk::GetAPIType = typedef typename detail::GetAPITypeImpl<ArrayType>::APIType |
Definition at line 188 of file vtkDataArrayMeta.h.
using vtk::IsAOSDataArray = typedef std::integral_constant<bool, detail::IsAOSDataArrayImpl<ArrayType>::value> |
Definition at line 206 of file vtkDataArrayMeta.h.
|
strong |
Enumerator | |
---|---|
None | |
SkipEmptyNodes |
Definition at line 34 of file vtkCompositeDataSetRange.h.
|
strong |
Enumerator | |
---|---|
None | |
SkipEmptyNodes | |
VisitOnlyLeaves | |
TraverseSubTree |
Definition at line 34 of file vtkDataObjectTreeRange.h.
VTK_ITER_INLINE auto vtk::DataArrayTupleRange | ( | const ArrayTypePtr & | array, |
TupleIdType | start = -1 , |
||
TupleIdType | end = -1 |
||
) | -> typename detail::SelectTupleRange<ArrayTypePtr, TupleSize>::type |
Generate an stl and for-range compatible range of tuple iterators from a vtkDataArray.
This function returns a TupleRange object that is compatible with C++11 for-range syntax. As an example usage, consider a function that takes some instance of vtkDataArray (or a subclass) and prints the magnitude of each tuple:
Note that ArrayType
is generic in the above function. When vtk::DataArrayTupleRange
is given a vtkDataArray
pointer, the generated code produces iterators and reference proxies that rely on the vtkDataArray
API. However, when a more derived ArrayType
is passed in (for example, vtkFloatArray
), specialized implementations are used that generate highly optimized code.
Performance can be further improved when the number of components in the array is known. By passing a compile-time-constant integer as a template parameter, e.g. vtk::DataArrayTupleRange<3>(array)
, specializations are enabled that allow the compiler to perform additional optimizations.
vtk::DataArrayTupleRange
takes an additional two arguments that can be used to restrict the range of tuples to [start, end).
There is a compiler definition / CMake option called VTK_DEBUG_RANGE_ITERATORS
that enables checks for proper usage of the range/iterator/reference classes. This slows things down significantly, but is useful for diagnosing problems.
In some situations, developers may want to build in Debug mode while still maintaining decent performance for data-heavy computations. For these usecases, an additional CMake option VTK_ALWAYS_OPTIMIZE_ARRAY_ITERATORS
may be enabled to force optimization of code using these iterators. This option will force inlining and enable -O3 (or equivalent) optimization level for iterator code when compiling on platforms that support these features. This option has no effect when VTK_DEBUG_RANGE_ITERATORS
is enabled.
auto
to hold values or references obtained from iterators, as they may not behave as expected. This is a deficiency in C++ that affects all proxy iterators (such as those from vector<bool>
) that use a reference object instead of an actual C++ reference type. When in doubt, use std::iterator_traits
(along with decltype) or the typedefs listed below to determine the proper value/reference type to use. The examples below show how these may be used.To mitigate this, the following types are defined on the range object:
Range::TupleIteratorType
: Iterator that visits tuples.Range::ConstTupleIteratorType
: Const iterator that visits tuples.Range::TupleReferenceType
: Mutable tuple proxy reference.Range::ConstTupleReferenceType
: Const tuple proxy reference.Range::ComponentIteratorType
: Iterator that visits components in a tuple.Range::ConstComponentIteratorType
: Const iterator that visits tuple components.Range::ComponentReferenceType
: Reference proxy to a single tuple component.Range::ConstComponentReferenceType
: Const reference proxy to a single tuple component.Range::ComponentType
: ValueType
of components.These can be accessed via the range objects, e.g.:
Definition at line 258 of file vtkDataArrayRange.h.
VTK_ITER_INLINE auto vtk::DataArrayValueRange | ( | const ArrayTypePtr & | array, |
ValueIdType | start = -1 , |
||
ValueIdType | end = -1 |
||
) | -> typename detail::SelectValueRange<ArrayTypePtr, TupleSize>::type |
Generate an stl and for-range compatible range of flat AOS iterators from a vtkDataArray.
This function returns a ValueRange object that is compatible with C++11 for-range syntax. The array is traversed as if calling vtkGenericDataArray::GetValue with consecutive, increasing indices. As an example usage, consider a function that takes some instance of vtkDataArray (or a subclass) and sums the values it contains:
These ranges may also be used with STL algorithms:
Note that ArrayType
is generic in the above function. When vtk::DataArrayValueRange
is given a vtkDataArray
pointer, the generated code produces iterators and reference proxies that rely on the vtkDataArray
API. However, when a more derived ArrayType
is passed in (for example, vtkFloatArray
), specialized implementations are used that generate highly optimized code.
Performance can be further improved when the number of components in the array is known. By passing a compile-time-constant integer as a template parameter, e.g. vtk::DataArrayValueRange<3>(array)
, specializations are enabled that allow the compiler to perform additional optimizations.
vtk::DataArrayValueRange
takes an additional two arguments that can be used to restrict the range of values to [start, end).
There is a compiler definition / CMake option called VTK_DEBUG_RANGE_ITERATORS
that enables checks for proper usage of the range/iterator/reference classes. This slows things down significantly, but is useful for diagnosing problems.
In some situations, developers may want to build in Debug mode while still maintaining decent performance for data-heavy computations. For these usecases, an additional CMake option VTK_ALWAYS_OPTIMIZE_ARRAY_ITERATORS
may be enabled to force optimization of code using these iterators. This option will force inlining and enable -O3 (or equivalent) optimization level for iterator code when compiling on platforms that support these features. This option has no effect when VTK_DEBUG_RANGE_ITERATORS
is enabled.
auto
to hold values or references obtained from iterators, as they may not behave as expected. This is a deficiency in C++ that affects all proxy iterators (such as those from vector<bool>
) that use a reference object instead of an actual C++ reference type. When in doubt, use std::iterator_traits
(along with decltype) or the typedefs listed below to determine the proper value/reference type to use. The examples below show how these may be used.To mitigate this, the following types are defined on the range object:
Range::IteratorType
: Iterator that visits values in AOS order.Range::ConstIteratorType
: Const iterator that visits values in AOS order.Range::ReferenceType
: Mutable value proxy reference.Range::ConstReferenceType
: Const value proxy reference.Range::ValueType
: ValueType
of array's API.These can be accessed via the range objects, e.g.:
Definition at line 368 of file vtkDataArrayRange.h.
auto vtk::Range | ( | IterablePtr | iterable, |
Options &&... | opts | ||
) | -> typename detail::IterableTraits<typename detail::StripPointers<IterablePtr>::type>::RangeType |
Generate an iterable STL proxy object for a VTK container.
Currently supports:
#include <vtkCollectionRange.h>
):#include <vtkCompositeDataSetRange.h>
)#include <vtkDataObjectTreeRange.h>
)Usage:
Definition at line 85 of file vtkRange.h.
vtkSmartPointer< T > vtk::MakeSmartPointer | ( | T * | obj | ) |
Construct a vtkSmartPointer<T> containing obj.
A new reference is added to obj.
Definition at line 449 of file vtkSmartPointer.h.
vtkSmartPointer< T > vtk::TakeSmartPointer | ( | T * | obj | ) |
Construct a vtkSmartPointer<T> containing obj.
obj's reference count is not changed.
Definition at line 457 of file vtkSmartPointer.h.
vtkWeakPointer< T > vtk::TakeWeakPointer | ( | T * | obj | ) |
Construct a vtkWeakPointer<T> containing obj.
obj's reference count is not changed.
Definition at line 300 of file vtkWeakPointer.h.