Wildmeshing Toolkit
TetCellSplit.cpp
Go to the documentation of this file.
1 #include "TetCellSplit.hpp"
2 
3 #include <wmtk/Mesh.hpp>
4 
6 
7 
9  : Operation(m)
10  , m_split(m)
11  , m_collapse(m)
12 {}
13 
14 std::vector<simplex::Simplex> TetCellSplit::execute(const simplex::Simplex& simplex)
15 {
16  const auto first_split_simplicies = m_split(simplex::Simplex::edge(mesh(), simplex.tuple()));
17  if (first_split_simplicies.empty()) return {};
18  assert(first_split_simplicies.size() == 1);
19  const Tuple first_split_ret = first_split_simplicies.front().tuple();
20 
21  const Tuple second_split_input = mesh().switch_tuples(first_split_ret, {PrimitiveType::Edge});
22  const auto second_split_simplicies =
23  m_split(simplex::Simplex::edge(mesh(), second_split_input));
24  if (second_split_simplicies.empty()) return {};
25  assert(second_split_simplicies.size() == 1);
26  const Tuple second_split_ret = second_split_simplicies.front().tuple();
27 
28  const Tuple third_split_input = mesh().switch_tuples(
29  second_split_ret,
31  const auto third_split_simplicies = m_split(simplex::Simplex::edge(mesh(), third_split_input));
32  if (third_split_simplicies.empty()) return {};
33  assert(third_split_simplicies.size() == 1);
34  const Tuple third_split_ret = third_split_simplicies.front().tuple();
35 
36  const Tuple first_collapse_input = mesh().switch_tuples(
37  third_split_ret,
45  const auto first_collapse_simplicies =
46  m_collapse(simplex::Simplex::edge(mesh(), first_collapse_input));
47  if (first_collapse_simplicies.empty()) return {};
48  assert(first_collapse_simplicies.size() == 1);
49  const Tuple first_collapse_ret = first_collapse_simplicies.front().tuple();
50 
51  const Tuple second_collapse_input = first_collapse_ret;
52  const auto second_collapse_simplicies =
53  m_collapse(simplex::Simplex::edge(mesh(), second_collapse_input));
54  if (second_collapse_simplicies.empty()) return {};
55  assert(second_collapse_simplicies.size() == 1);
56  const Tuple second_collapse_ret = second_collapse_simplicies.front().tuple();
57 
58  const Tuple output_tuple = mesh().switch_tuples(
59  second_collapse_ret,
61 
62  return {simplex::Simplex::vertex(mesh(), output_tuple)};
63 }
64 
65 
66 std::vector<simplex::Simplex> TetCellSplit::unmodified_primitives(
67  const simplex::Simplex& simplex) const
68 {
69  return {simplex};
70 }
71 
72 } // namespace wmtk::operations::composite
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition: Mesh.hpp:967
const Mesh & mesh() const
Definition: Operation.hpp:45
std::vector< simplex::Simplex > unmodified_primitives(const simplex::Simplex &simplex) const override
Returns all simplices that will be potentially affected by the operation.
std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex) override
returns an empty vector in case of failure
const Tuple & tuple() const
Definition: Simplex.hpp:53
static Simplex edge(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:61
static Simplex vertex(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:56