8#ifndef vtkCellGridSidesQuery_h
9#define vtkCellGridSidesQuery_h
18#include <unordered_map>
21VTK_ABI_NAMESPACE_BEGIN
43 std::unordered_map<vtkStringToken, std::unordered_map<vtkIdType, std::set<int>>>>&
72 template <
typename T, std::
size_t NN>
74 const std::array<T, NN>& conn)
79 for (std::size_t jj = 1; jj < NN; ++jj)
87 bool forward = conn[(ss + 1) % NN] > conn[(ss + NN - 1) % NN];
89 std::size_t hashedValue = std::hash<std::size_t>{}(NN);
93 for (std::size_t ii = 0; ii < NN; ++ii)
95 std::size_t hashedToken = std::hash<T>{}(conn[(ss + ii) % NN]);
101 for (std::size_t ii = 0; ii < NN; ++ii)
103 std::size_t hashedToken = std::hash<T>{}(conn[(ss + NN - ii) % NN]);
108 this->Hashes[hashedValue].Sides.insert(
Side{ cellType, shape, cell, side });
111 template <
typename T>
113 const std::vector<T>& conn)
116 std::size_t NN = conn.size();
123 for (std::size_t jj = 1; jj < NN; ++jj)
131 bool forward = conn[(ss + 1) % NN] > conn[(ss + NN - 1) % NN];
133 std::size_t hashedValue = std::hash<std::size_t>{}(NN);
138 for (std::size_t ii = 0; ii < NN; ++ii)
140 std::size_t hashedToken = std::hash<T>{}(conn[(ss + ii) % NN]);
147 for (std::size_t ii = 0; ii < NN; ++ii)
149 std::size_t hashedToken = std::hash<T>{}(conn[(ss + NN - ii) % NN]);
156 this->Hashes[hashedValue].Sides.insert(
Side{ cellType, shape, cell, side });
168 template <
typename T>
169 void operator()(T&
h,
typename std::enable_if<
sizeof(T) == 8, std::size_t>::type k)
171 constexpr T m = 0xc6a4a7935bd1e995ull;
172 constexpr int r = 47;
186 template <
typename T>
187 void operator()(T&
h,
typename std::enable_if<
sizeof(T) == 4, std::size_t>::type k)
189 constexpr std::uint32_t c1 = 0xcc9e2d51;
190 constexpr std::uint32_t c2 = 0x1b873593;
191 constexpr std::uint32_t r1 = 15;
192 constexpr std::uint32_t r2 = 13;
195 k = (k << r1) | (k >> (32 - r1));
199 h = (
h << r2) | (
h >> (32 - r2));
200 h =
h * 5 + 0xe6546b64;
212 return (this->CellType < other.
CellType) ||
213 (this->CellType == other.
CellType &&
214 ((this->DOF < other.
DOF) || (this->DOF == other.
DOF && this->SideId < other.
SideId)));
221 std::unordered_map<std::size_t, Entry>
Hashes;
223 std::unordered_map<vtkStringToken, std::unordered_map<vtkIdType, std::set<int>>>>
Perform an operation on cells in a vtkCellMetadata instance.
void operator()(T &h, typename std::enable_if< sizeof(T)==4, std::size_t >::type k)
void operator()(T &h, typename std::enable_if< sizeof(T)==8, std::size_t >::type k)
A cell-grid query for enumerating sides of cells.
~vtkCellGridSidesQuery() override=default
void Finalize() override
Override this if your query-result state requires finalization.
void AddSide(vtkStringToken cellType, vtkIdType cell, int side, vtkStringToken shape, const std::vector< T > &conn)
vtkCellGridSidesQuery()=default
std::map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkIdType, std::set< int > > > > Sides
std::unordered_map< std::size_t, Entry > Hashes
void Initialize() override
Override this if your query-result state requires initialization.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkCellGridSidesQuery * New()
void AddSide(vtkStringToken cellType, vtkIdType cell, int side, vtkStringToken shape, const std::array< T, NN > &conn)
Add a side with the given shape and connectivity to the request's state.
std::map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkIdType, std::set< int > > > > & GetSides()
a simple class to control print indentation
Computes the portion of a dataset which is inside a selection.
Represent a string by its integer hash.
Hash GetId() const
Return the token's ID (usually its hash but possibly not in the case of collisions).
bool operator<(const Side &other) const