Wildmeshing Toolkit
grid_utils.cpp
Go to the documentation of this file.
1 #include "grid_utils.hpp"
3 
4 namespace {
5 template <int64_t D>
6 int64_t _grid_index(const std::array<int64_t, D>& d, const std::array<int64_t, D>& i)
7 {
8  int64_t v = i[0];
9  for (int64_t j = 1; j < D; ++j) {
10  v = v * d[j] + i[j];
11  }
12  return v;
13 }
14 } // namespace
15 
16 int64_t grid_index(const std::array<int64_t, 3>& d, const std::array<int64_t, 3>& i)
17 {
18  return _grid_index<3>(d, i);
19 }
20 int64_t grid_index(const std::array<int64_t, 2>& d, const std::array<int64_t, 2>& i)
21 {
22  return _grid_index<2>(d, i);
23 }
24 } // namespace wmtk::components::procedural
int64_t grid_index(const std::array< int64_t, 3 > &d, const std::array< int64_t, 3 > &i)
Definition: grid_utils.cpp:16