VTK  9.7.20261105
vtk::keys Namespace Reference

Namespaces

namespace  detail

Classes

class  KeysBase
 What DenseKeys and SparseKeys share, and all that Reduce(), Group(), Compact() and ForEachKeyRange() use: the first element of every key id, the elements of key id k being at [GetOffset(k), GetOffset(k + 1)) of the Output. More...
class  DenseKeys
 The dense keys of the elements, returned by ScatterDense(): every key of the key range [GetMinKey(), GetMaxKey()], present or not, whose key id is its position in the range. More...
class  SparseKeys
 The sparse keys of the elements, returned by ScatterSparse(): the distinct keys, in increasing order of their operator<, whose key id is their position. More...
class  ReducedKeys
 The keys of the surviving elements of Reduce(), or of the groups of Group(): the keys of the scattered keys, with the scanned survivors of every key id as offsets, i.e., the keys of the Output once compacted. More...
struct  SortUnique
 The reduce functor of an array of elements that keeps one element of every set of equal ones, with operator< and operator==: it sorts the elements of every key, then applies std::unique(). More...
class  GroupedElements
 The groups of equal elements of Group(), ordered by key: the elements of group g are at [GetGroupOffset(g), GetGroupOffset(g + 1)) of the grouped Output. More...
struct  Grouping
 The result of Group(): the groups, and the keys of the groups, i.e., the groups of key id k are [Keys.GetOffset(k), Keys.GetOffset(k + 1)), which are also the keys of the first elements of the groups once compacted. More...
struct  SortGroup
 The group functor of an array of elements, with operator< and operator!=: it sorts the elements of every key, then flags the elements that differ from the previous one. More...

Typedefs

template<typename Input>
using DenseKeysOf = DenseKeys<detail::KeyTypeOfT<Input>, detail::ElementIdTypeOfT<Input>>
 The keys of the scatters of an input, with its KeyType and ElementIdType, and of an array.
template<typename Input>
using SparseKeysOf = SparseKeys<detail::KeyTypeOfT<Input>, detail::ElementIdTypeOfT<Input>>
template<typename Element, typename ElementIdType>
using DenseArrayKeys = DenseKeys<detail::ElementKeyOf<Element>, ElementIdType>
template<typename Element, typename ElementIdType>
using SparseArrayKeys = SparseKeys<detail::ElementKeyOf<Element>, ElementIdType>

Functions

template<typename InputMapper>
vtkIdType CountElements (const InputMapper &mapper)
 The number of elements of an InputMapper, without storing them, e.g., to choose its ElementIdType.
template<typename Input, typename Output>
DenseKeysOf< Input > ScatterDense (const Input &input, Output &output)
 Scatter the elements of an Input or an InputMapper to an Output by a counting sort over the key range, with the KeyType and ElementIdType of the input.
template<typename Input, typename Output>
DenseKeysOf< Input > ScatterDense (const Input &input, detail::KeyTypeOfT< Input > minKey, detail::KeyTypeOfT< Input > maxKey, Output &output)
template<typename Element, typename ElementIdType>
DenseArrayKeys< Element, ElementIdType > ScatterDense (const Element *elements, ElementIdType numberOfElements, Element *scattered)
 Scatter an array of elements, keyed by their GetKey() (Element concept), to scattered, which holds as many elements and does not overlap elements.
template<typename Element, typename ElementIdType>
DenseArrayKeys< Element, ElementIdType > ScatterDense (const Element *elements, ElementIdType numberOfElements, detail::ElementKeyOf< Element > minKey, detail::ElementKeyOf< Element > maxKey, Element *scattered)
template<typename Input, typename Output>
SparseKeysOf< Input > ScatterSparse (const Input &input, Output &output)
 Scatter the elements of an Input or an InputMapper, or an array of elements, to an Output by a parallel sort of their keys, for keys too sparse for ScatterDense().
template<typename Element, typename ElementIdType>
SparseArrayKeys< Element, ElementIdType > ScatterSparse (const Element *elements, ElementIdType numberOfElements, Element *scattered)
template<typename TKeys, typename Output, typename Functor, typename... Args>
void ForEachKeyRange (const TKeys &keys, Output &&output, Functor &functor, Args... args)
 Call functor(output, beginKeyId, endKeyId, offsets, args...) on disjoint ranges of key ids, concurrently, on the same functor, where the elements of key id k are [offsets[k], offsets[k + 1]) of the Output, for DenseKeys or SparseKeys.
template<typename TKeys, typename Output, typename Functor>
ReducedKeys< TKeys > Reduce (const TKeys &keys, Output &&output, Functor &&functor)
 Keep the surviving elements of every key of the Output at its front with a reduce functor called as functor(output, beginKeyId, endKeyId, offsets, counts), which writes the survivors of key id k to counts[k], see ForEachKeyRange().
template<typename TKeys, typename Output, typename = std::enable_if_t<!std::is_pointer_v<Output>>>
TKeys::ElementIdType Compact (const TKeys &keys, const ReducedKeys< TKeys > &reduced, const Output &input, Output &output)
 Copy the survivors of the reduced Output input contiguously into output, another Output that implements CopyData(), or arrays of elements.
template<typename TKeys, typename Element>
TKeys::ElementIdType Compact (const TKeys &keys, const ReducedKeys< TKeys > &reduced, const Element *input, Element *output)
template<typename TKeys, typename Output, typename Functor>
Grouping< TKeys > Group (const TKeys &keys, Output &&output, Functor &&functor)
 Group the equal elements of every key of the Output with a group functor called as functor(output, beginKeyId, endKeyId, offsets, groupStarts), which makes them contiguous and sets groupStarts[i] to 1 for every element i that differs from the previous one, see ForEachKeyRange().
template<typename TKeys, typename Output, typename = std::enable_if_t<!std::is_pointer_v<Output>>>
TKeys::ElementIdType Compact (const GroupedElements< TKeys > &groups, const Output &input, Output &output)
 Copy the first element of every group of the grouped Output input to output, another Output that implements CopyData(), or arrays of elements, so that group g is element g of output.
template<typename TKeys, typename Element>
TKeys::ElementIdType Compact (const GroupedElements< TKeys > &groups, const Element *input, Element *output)

Typedef Documentation

◆ DenseKeysOf

template<typename Input>
using vtk::keys::DenseKeysOf = DenseKeys<detail::KeyTypeOfT<Input>, detail::ElementIdTypeOfT<Input>>

The keys of the scatters of an input, with its KeyType and ElementIdType, and of an array.

Definition at line 302 of file vtkKeys.h.

◆ SparseKeysOf

template<typename Input>
using vtk::keys::SparseKeysOf = SparseKeys<detail::KeyTypeOfT<Input>, detail::ElementIdTypeOfT<Input>>

Definition at line 304 of file vtkKeys.h.

◆ DenseArrayKeys

template<typename Element, typename ElementIdType>
using vtk::keys::DenseArrayKeys = DenseKeys<detail::ElementKeyOf<Element>, ElementIdType>

Definition at line 306 of file vtkKeys.h.

◆ SparseArrayKeys

template<typename Element, typename ElementIdType>
using vtk::keys::SparseArrayKeys = SparseKeys<detail::ElementKeyOf<Element>, ElementIdType>

Definition at line 308 of file vtkKeys.h.

Function Documentation

◆ CountElements()

template<typename InputMapper>
vtkIdType vtk::keys::CountElements ( const InputMapper & mapper)

The number of elements of an InputMapper, without storing them, e.g., to choose its ElementIdType.

The elements of a record must fit it, not their total.

◆ ScatterDense() [1/4]

template<typename Input, typename Output>
DenseKeysOf< Input > vtk::keys::ScatterDense ( const Input & input,
Output & output )

Scatter the elements of an Input or an InputMapper to an Output by a counting sort over the key range, with the KeyType and ElementIdType of the input.

The key range, [minKey, maxKey], saves a pass if given; every key must lie in it.

Returns
The keys, empty if the elements do not fit their ElementIdType.

◆ ScatterDense() [2/4]

template<typename Input, typename Output>
DenseKeysOf< Input > vtk::keys::ScatterDense ( const Input & input,
detail::KeyTypeOfT< Input > minKey,
detail::KeyTypeOfT< Input > maxKey,
Output & output )

◆ ScatterDense() [3/4]

template<typename Element, typename ElementIdType>
DenseArrayKeys< Element, ElementIdType > vtk::keys::ScatterDense ( const Element * elements,
ElementIdType numberOfElements,
Element * scattered )

Scatter an array of elements, keyed by their GetKey() (Element concept), to scattered, which holds as many elements and does not overlap elements.

The ElementIdType of the keys is the type of numberOfElements.

◆ ScatterDense() [4/4]

template<typename Element, typename ElementIdType>
DenseArrayKeys< Element, ElementIdType > vtk::keys::ScatterDense ( const Element * elements,
ElementIdType numberOfElements,
detail::ElementKeyOf< Element > minKey,
detail::ElementKeyOf< Element > maxKey,
Element * scattered )

◆ ScatterSparse() [1/2]

template<typename Input, typename Output>
SparseKeysOf< Input > vtk::keys::ScatterSparse ( const Input & input,
Output & output )

Scatter the elements of an Input or an InputMapper, or an array of elements, to an Output by a parallel sort of their keys, for keys too sparse for ScatterDense().

One key and two ids per element are allocated, and released before returning.

Returns
The keys, empty if the elements do not fit their ElementIdType.

◆ ScatterSparse() [2/2]

template<typename Element, typename ElementIdType>
SparseArrayKeys< Element, ElementIdType > vtk::keys::ScatterSparse ( const Element * elements,
ElementIdType numberOfElements,
Element * scattered )

◆ ForEachKeyRange()

template<typename TKeys, typename Output, typename Functor, typename... Args>
void vtk::keys::ForEachKeyRange ( const TKeys & keys,
Output && output,
Functor & functor,
Args... args )

Call functor(output, beginKeyId, endKeyId, offsets, args...) on disjoint ranges of key ids, concurrently, on the same functor, where the elements of key id k are [offsets[k], offsets[k + 1]) of the Output, for DenseKeys or SparseKeys.

The functor's Initialize() and Reduce(), if any, are called as the ones of a vtkSMPTools functor.

◆ Reduce()

template<typename TKeys, typename Output, typename Functor>
ReducedKeys< TKeys > vtk::keys::Reduce ( const TKeys & keys,
Output && output,
Functor && functor )

Keep the surviving elements of every key of the Output at its front with a reduce functor called as functor(output, beginKeyId, endKeyId, offsets, counts), which writes the survivors of key id k to counts[k], see ForEachKeyRange().

The Output is any Output, or an array of elements. Only one Reduce() or Group() can be applied to an Output.

◆ Compact() [1/4]

template<typename TKeys, typename Output, typename = std::enable_if_t<!std::is_pointer_v<Output>>>
TKeys::ElementIdType vtk::keys::Compact ( const TKeys & keys,
const ReducedKeys< TKeys > & reduced,
const Output & input,
Output & output )

Copy the survivors of the reduced Output input contiguously into output, another Output that implements CopyData(), or arrays of elements.

Returns
The number of elements copied.

◆ Compact() [2/4]

template<typename TKeys, typename Element>
TKeys::ElementIdType vtk::keys::Compact ( const TKeys & keys,
const ReducedKeys< TKeys > & reduced,
const Element * input,
Element * output )

◆ Group()

template<typename TKeys, typename Output, typename Functor>
Grouping< TKeys > vtk::keys::Group ( const TKeys & keys,
Output && output,
Functor && functor )

Group the equal elements of every key of the Output with a group functor called as functor(output, beginKeyId, endKeyId, offsets, groupStarts), which makes them contiguous and sets groupStarts[i] to 1 for every element i that differs from the previous one, see ForEachKeyRange().

The Output is any Output, or an array of elements. One byte per element is allocated, and released before returning. Only one Reduce() or Group() can be applied to an Output.

◆ Compact() [3/4]

template<typename TKeys, typename Output, typename = std::enable_if_t<!std::is_pointer_v<Output>>>
TKeys::ElementIdType vtk::keys::Compact ( const GroupedElements< TKeys > & groups,
const Output & input,
Output & output )

Copy the first element of every group of the grouped Output input to output, another Output that implements CopyData(), or arrays of elements, so that group g is element g of output.

Returns
The number of elements copied.

◆ Compact() [4/4]

template<typename TKeys, typename Element>
TKeys::ElementIdType vtk::keys::Compact ( const GroupedElements< TKeys > & groups,
const Element * input,
Element * output )