VTK  9.7.20261029
vtkStaticElementLocator< TID, TElement > Class Template Reference

#include <vtkStaticElementLocator.h>

Detailed Description

template<typename TID, typename TElement>
class vtkStaticElementLocator< TID, TElement >

templated locator of topological elements, with data on the elements

vtkStaticElementLocator locates topological elements, i.e., tuples of point ids, e.g., an edge (v0, v1) with v0 < v1 (see EdgeTuple, TriangleTuple and QuadTuple), with data associated with them, e.g., to find the duplicate edges of an isocontour. It is templated on the type of the ids (IDType) and the element tuple (ElementType), which carries the data.

The locator is static, as vtkStaticPointLocator and vtkStaticCellLocator: it is built from an array of elements, to which no element can be added afterwards. It is used in one of two ways:

  • BuildLocator(), then IsInsertedElement() queries, to search the unique elements;
  • GroupElements(), which sorts an array of elements into groups of equal elements, whose offsets give the number of unique elements and O(1) access to every group, e.g., to renumber the duplicate elements or their data. Both scatter the elements in parallel by their key (GetKey(), e.g., their smallest point id) with vtk::keys::ScatterDense(), see vtkKeys.h, so that only the elements of a key are sorted and compared.
Warning
The number of unique elements of BuildLocator() must fit IDType, which can be smaller than vtkIdType to reduce memory and speed up processing. The number of elements of GroupElements() can exceed it, since the offsets of its groups are vtkIdType.
The data of the elements is not used to compare and sort them: since the elements are binned in parallel, equal elements with different data can be ordered differently within their group from one run to the next.
ElementType must provide GetKey() const -> IDType, operator==, operator!= and operator<: the Element concept of vtkKeys.h, checked at compile time. The keys must be dense, as point ids are, see vtk::keys::DenseKeys.
This class has been threaded with vtkSMPTools. Using TBB or other non-sequential type (set in the CMake variable VTK_SMP_IMPLEMENTATION_TYPE) may improve performance significantly.
See also
vtkStaticPointLocator vtkStaticCellLocator
Tests:
vtkStaticElementLocator (Tests)

Definition at line 62 of file vtkStaticElementLocator.h.

Inheritance diagram for vtkStaticElementLocator< TID, TElement >:
[legend]
Collaboration diagram for vtkStaticElementLocator< TID, TElement >:
[legend]

Public Types

using IDType = TID
using ElementType = TElement
using KeysType = vtk::keys::DenseArrayKeys<ElementType, vtkIdType>
using GroupedElements = vtk::keys::GroupedElements<KeysType>
 The groups of equal elements of GroupElements(), see vtk::keys::GroupedElements.

Public Member Functions

 vtkStaticElementLocator ()=default
 Construct an empty element locator.
 ~vtkStaticElementLocator ()=default
 vtkStaticElementLocator (vtkStaticElementLocator &&)=default
 Move a locator.
vtkStaticElementLocator & operator= (vtkStaticElementLocator &&)=default
vtkIdType BuildLocator (vtkIdType numElements, ElementType *elementArray)
 Build the locator from the numElements elements of elementArray, which may contain duplicates: the unique elements are moved to its front, sorted by key, see vtkKeys.h.
IDType IsInsertedElement (const ElementType &query) const
 Return the id of an element, or a negative value if it was not inserted.
template<typename Arg0, typename Arg1, typename... Args>
IDType IsInsertedElement (Arg0 &&arg0, Arg1 &&arg1, Args &&... args) const
 Same as above, with the query constructed in place from its arguments, as emplace_back(), e.g., IsInsertedElement(v0, v1) for an element.
IDType GetNumberOfElements () const
 Return the number of unique elements, after BuildLocator().
const ElementType & GetElement (IDType i) const
 Return the element of id i, i.e., the ith unique element, 0 <= i < GetNumberOfElements().
const GroupedElements & GroupElements (vtkIdType numElements, ElementType *elementArray)
 Sort the numElements elements of elementArray in place into groups of equal elements, and return them: group g is [GetGroupOffset(g), GetGroupOffset(g + 1)) of elementArray, the number of unique elements is GetNumberOfGroups(), and GetGroupOffset(GetNumberOfGroups()) is numElements.

Protected Attributes

IDType NumElements = 0
ElementType * ElementArray = nullptr
vtk::keys::ReducedKeys< KeysType > Index
GroupedElements Groups

Member Typedef Documentation

◆ IDType

template<typename TID, typename TElement>
using vtkStaticElementLocator< TID, TElement >::IDType = TID

Definition at line 65 of file vtkStaticElementLocator.h.

◆ ElementType

template<typename TID, typename TElement>
using vtkStaticElementLocator< TID, TElement >::ElementType = TElement

Definition at line 66 of file vtkStaticElementLocator.h.

◆ KeysType

template<typename TID, typename TElement>
using vtkStaticElementLocator< TID, TElement >::KeysType = vtk::keys::DenseArrayKeys<ElementType, vtkIdType>

Definition at line 68 of file vtkStaticElementLocator.h.

◆ GroupedElements

template<typename TID, typename TElement>
using vtkStaticElementLocator< TID, TElement >::GroupedElements = vtk::keys::GroupedElements<KeysType>

The groups of equal elements of GroupElements(), see vtk::keys::GroupedElements.

Definition at line 73 of file vtkStaticElementLocator.h.

Constructor & Destructor Documentation

◆ vtkStaticElementLocator() [1/2]

template<typename TID, typename TElement>
vtkStaticElementLocator< TID, TElement >::vtkStaticElementLocator ( )
default

Construct an empty element locator.

◆ ~vtkStaticElementLocator()

template<typename TID, typename TElement>
vtkStaticElementLocator< TID, TElement >::~vtkStaticElementLocator ( )
default

◆ vtkStaticElementLocator() [2/2]

template<typename TID, typename TElement>
vtkStaticElementLocator< TID, TElement >::vtkStaticElementLocator ( vtkStaticElementLocator< TID, TElement > && )
default

Move a locator.

The locator does not own the elements, so their array must still outlive it. A moved-from locator must be built again before it is used.

Member Function Documentation

◆ operator=()

template<typename TID, typename TElement>
vtkStaticElementLocator & vtkStaticElementLocator< TID, TElement >::operator= ( vtkStaticElementLocator< TID, TElement > && )
default

◆ BuildLocator()

template<typename TID, typename TElement>
vtkIdType vtkStaticElementLocator< TID, TElement >::BuildLocator ( vtkIdType numElements,
ElementType * elementArray )

Build the locator from the numElements elements of elementArray, which may contain duplicates: the unique elements are moved to its front, sorted by key, see vtkKeys.h.

elementArray is modified in place, and must outlive the locator. Return the number of unique elements.

◆ IsInsertedElement() [1/2]

template<typename TID, typename TElement>
IDType vtkStaticElementLocator< TID, TElement >::IsInsertedElement ( const ElementType & query) const

Return the id of an element, or a negative value if it was not inserted.

The point ids of the query can be in any order, since the element tuple sorts them. BuildLocator() must be called first.

◆ IsInsertedElement() [2/2]

template<typename TID, typename TElement>
template<typename Arg0, typename Arg1, typename... Args>
IDType vtkStaticElementLocator< TID, TElement >::IsInsertedElement ( Arg0 && arg0,
Arg1 && arg1,
Args &&... args ) const
inline

Same as above, with the query constructed in place from its arguments, as emplace_back(), e.g., IsInsertedElement(v0, v1) for an element.

Definition at line 108 of file vtkStaticElementLocator.h.

◆ GetNumberOfElements()

template<typename TID, typename TElement>
IDType vtkStaticElementLocator< TID, TElement >::GetNumberOfElements ( ) const
inline

Return the number of unique elements, after BuildLocator().

Definition at line 117 of file vtkStaticElementLocator.h.

◆ GetElement()

template<typename TID, typename TElement>
const ElementType & vtkStaticElementLocator< TID, TElement >::GetElement ( IDType i) const
inline

Return the element of id i, i.e., the ith unique element, 0 <= i < GetNumberOfElements().

Definition at line 122 of file vtkStaticElementLocator.h.

◆ GroupElements()

template<typename TID, typename TElement>
const GroupedElements & vtkStaticElementLocator< TID, TElement >::GroupElements ( vtkIdType numElements,
ElementType * elementArray )

Sort the numElements elements of elementArray in place into groups of equal elements, and return them: group g is [GetGroupOffset(g), GetGroupOffset(g + 1)) of elementArray, the number of unique elements is GetNumberOfGroups(), and GetGroupOffset(GetNumberOfGroups()) is numElements.

The data of the elements can then, e.g., renumber the duplicate elements to unique ids. The groups are owned by the locator until the next GroupElements(), independently of BuildLocator(). The equal elements are grouped with vtk::keys::SortGroup: another rule needs vtk::keys::Group() with its group functor.

Member Data Documentation

◆ NumElements

template<typename TID, typename TElement>
IDType vtkStaticElementLocator< TID, TElement >::NumElements = 0
protected

Definition at line 136 of file vtkStaticElementLocator.h.

◆ ElementArray

template<typename TID, typename TElement>
ElementType* vtkStaticElementLocator< TID, TElement >::ElementArray = nullptr
protected

Definition at line 137 of file vtkStaticElementLocator.h.

◆ Index

template<typename TID, typename TElement>
vtk::keys::ReducedKeys<KeysType> vtkStaticElementLocator< TID, TElement >::Index
protected

Definition at line 140 of file vtkStaticElementLocator.h.

◆ Groups

template<typename TID, typename TElement>
GroupedElements vtkStaticElementLocator< TID, TElement >::Groups
protected

Definition at line 142 of file vtkStaticElementLocator.h.


The documentation for this class was generated from the following file: