Wildmeshing Toolkit
MultiMeshLinkConditionInvariant.cpp
Go to the documentation of this file.
2 
3 #include <stdexcept>
4 #include <wmtk/EdgeMesh.hpp>
5 #include <wmtk/Mesh.hpp>
6 #include <wmtk/PointMesh.hpp>
7 #include <wmtk/TetMesh.hpp>
8 #include <wmtk/TriMesh.hpp>
10 #include <wmtk/simplex/Simplex.hpp>
12 
13 namespace wmtk::invariants {
14 namespace {
15 
16 struct MultiMeshLinkConditionFunctor
17 {
18  template <typename T>
19  bool operator()(const T& m, const simplex::Simplex& s, int64_t) {
20  return this->operator()(m,s);
21  }
22  template <typename MeshType>
23  bool operator()(const MeshType& m, const simplex::Simplex& s) const
24  {
25  return m.is_free() || simplex::link_condition(m, s.tuple());
26  }
27 };
28 } // namespace
29 
31  : Invariant(m, true, false, false)
32 {}
34 {
35  assert(t.primitive_type() == PrimitiveType::Edge);
37  std::integral_constant<int64_t, 1>{}, // specify that this runs on edges
38  MultiMeshLinkConditionFunctor{});
39  // TODO: fix visitor to work for const data
40  visitor.execute_from_root(const_cast<Mesh&>(mesh()), simplex::NavigatableSimplex(mesh(),t));
41  const auto& data = visitor.cache();
42 
43  for (const auto& [key, value_var] : data) {
44  const bool valid = std::get<bool>(value_var);
45  if (!valid) {
46  return false;
47  }
48  }
49 
50  return true;
51 }
52 } // namespace wmtk::invariants
const Mesh & mesh() const
Definition: Invariant.cpp:35
void execute_from_root(Mesh &mesh, const simplex::NavigatableSimplex &simplex)
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
bool link_condition(const EdgeMesh &mesh, const Tuple &edge)
Check if the edge to collapse satisfying the link condition.