Wildmeshing Toolkit
NewAttributeStrategy.cpp
Go to the documentation of this file.
2 #include <wmtk/Mesh.hpp>
4 
5 namespace wmtk::operations {
6 
8 
9 //NewAttributeStrategy::NewAttributeStrategy(const wmtk::attribute::MeshAttributeHandle& handle) {
10 //}
11 
13 {
14  return const_cast<const Mesh&>(const_cast<NewAttributeStrategy*>(this)->mesh());
15 }
17 {
18  m_simplex_predicate = std::move(f);
19 }
20 
22 {
23  switch (f) {
24  default: [[fallthrough]];
25  case BasicSimplexPredicate::Default: [[fallthrough]];
29  [&](const simplex::Simplex& s) -> bool { return mesh().is_boundary(s); });
30  break;
31  }
32 }
33 
35  PrimitiveType pt,
36  const std::array<Tuple, 2>& simplices) const
37 {
38  if (!bool(m_simplex_predicate)) {
39  std::bitset<2> pred(0);
40  return pred;
41  }
42 
43  auto old_pred = mesh().parent_scope([&]() {
44  std::bitset<2> pred(0);
45  if (bool(m_simplex_predicate)) {
46  for (size_t j = 0; j < 2; ++j) {
47  pred[j] = m_simplex_predicate(simplex::Simplex(mesh(), pt, simplices[j]));
48  }
49  }
50  return pred;
51  });
52 
53  return old_pred;
54 }
55 } // namespace wmtk::operations
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:107
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
void set_simplex_predicate(SimplexPredicateType &&f)
std::bitset< 2 > evaluate_predicate(PrimitiveType pt, const std::array< Tuple, 2 > &simplices) const
std::function< bool(const simplex::Simplex &)> SimplexPredicateType