VTK  9.5.20251210
vtkLocatorInterface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
16
17#ifndef vtkLocatorInterface_h
18#define vtkLocatorInterface_h
19
20#include "vtkABINamespace.h"
21#include "vtkSystemIncludes.h"
22
23#include <vector>
24
25VTK_ABI_NAMESPACE_BEGIN
26
35{
37 double Dist2;
39 : Id(-1)
40 , Dist2(0)
41 {
42 }
43 vtkDist2Tuple(vtkIdType id, double d2)
44 : Id(id)
45 , Dist2(d2)
46 {
47 }
48
49 // Support sort operation from smallest to largest.
50 bool operator<(const vtkDist2Tuple& tuple) const { return Dist2 < tuple.Dist2; }
51};
52
61struct vtkDist2TupleArray : public std::vector<vtkDist2Tuple>
62{
63};
64typedef std::vector<vtkDist2Tuple> vtkDist2TupleType;
65typedef std::vector<vtkDist2Tuple>::iterator vtkDist2TupleIterator;
66
67//------------------------------------------------------------------------------
68// The following tuple is what is sorted in the locator maps (i.e., a map of
69// bucket/bins to point ids). Note that it is templated because depending on
70// the number of points / buckets to process we may want to use vtkIdType to
71// represent the tuple. Otherwise for performance reasons it's best to use an
72// int (or other integral type). Typically sort() is 25-30% faster on smaller
73// integral types, plus it takes a heck less memory (when vtkIdType is 64-bit
74// and int is 32-bit).
75template <typename TTuple>
77{
78 TTuple PtId; // originating point id
79 TTuple Bucket; // i-j-k index into bucket space
80
81 // Operator< used to support the subsequent sort operation. There are two
82 // implementations, one gives a stable sort (points ordered by id within
83 // each bucket) and the other a little faster but less stable (in parallel
84 // sorting the order of sorted points in a bucket may vary).
85 bool operator<(const vtkLocatorTuple& tuple) const
86 {
87 if (Bucket < tuple.Bucket)
88 return true;
89 if (tuple.Bucket < Bucket)
90 return false;
91 if (PtId < tuple.PtId)
92 return true;
93 return false;
94 }
95};
96
97VTK_ABI_NAMESPACE_END
98#endif
99// VTK-HeaderTest-Exclude: vtkLocatorInterface.h
Represent an array of vtkDist2Tuples.
vtkDist2Tuple(vtkIdType id, double d2)
bool operator<(const vtkDist2Tuple &tuple) const
bool operator<(const vtkLocatorTuple &tuple) const
std::vector< vtkDist2Tuple >::iterator vtkDist2TupleIterator
std::vector< vtkDist2Tuple > vtkDist2TupleType
int vtkIdType
Definition vtkType.h:367