Wildmeshing Toolkit
edgemesh_topology_initialization.cpp
Go to the documentation of this file.
2 #include <algorithm>
3 #include <vector>
4 #include <wmtk/utils/Logger.hpp>
5 
6 namespace wmtk {
7 
8 std::tuple<RowVectors2l, VectorXl> edgemesh_topology_initialization(
9  Eigen::Ref<const RowVectors2l> E)
10 {
11  RowVectors2l EE;
12  VectorXl VE;
13 
14  const int64_t vertex_count = E.maxCoeff() + 1;
15 
16  // store the complete vertex-edge connnectivity
17  std::vector<std::vector<int64_t>> complete_VE(vertex_count);
18 
19  // compute VE
20  VE.resize(vertex_count, 1);
21  for (int64_t i = 0; i < E.rows(); ++i) {
22  for (int64_t j = 0; j < E.cols(); ++j) {
23  VE[E(i, j)] = i;
24  complete_VE[E(i, j)].push_back(i);
25  }
26  }
27 
28  EE.resize(E.rows(), 2);
29  // compute EE & connectivity check
30  for (int64_t i = 0; i < complete_VE.size(); ++i) {
31  assert(complete_VE[i].size() > 0 || complete_VE[i].size() < 3);
32  if (complete_VE[i].size() == 1) {
33  // boundary vertex
34  if (E(complete_VE[i][0], 0) == i) {
35  EE(complete_VE[i][0], 0) = -1;
36  } else {
37  EE(complete_VE[i][0], 1) = -1;
38  }
39  } else {
40  // non-boundary vertex
41  for (int64_t k = 0; k < 2; ++k) {
42  if (E(complete_VE[i][k], 0) == i) {
43  EE(complete_VE[i][k], 0) = complete_VE[i][1 - k];
44  }
45  if (E(complete_VE[i][k], 1) == i) {
46  EE(complete_VE[i][k], 1) = complete_VE[i][1 - k];
47  }
48  }
49  }
50  }
51  return {EE, VE};
52 }
53 } // namespace wmtk
Definition: Accessor.hpp:6
VectorX< int64_t > VectorXl
Definition: Types.hpp:33
RowVectors< int64_t, 2 > RowVectors2l
Definition: Types.hpp:46
std::tuple< RowVectors2l, VectorXl > edgemesh_topology_initialization(Eigen::Ref< const RowVectors2l > E)