Wildmeshing Toolkit
Loading...
Searching...
No Matches
TetFaceSwap.cpp
Go to the documentation of this file.
1#include "TetFaceSwap.hpp"
2#include <wmtk/Mesh.hpp>
3
6 : Operation(m)
7 , m_split(m)
8 , m_collapse(m)
9{}
10
11std::vector<simplex::Simplex> TetFaceSwap::execute(const simplex::Simplex& simplex)
12{
13 constexpr static PrimitiveType PV = PrimitiveType::Vertex;
14 constexpr static PrimitiveType PE = PrimitiveType::Edge;
15 constexpr static PrimitiveType PF = PrimitiveType::Triangle;
17
18 // first split, split the edge of the input tuple
19 const auto split_simplicies_first = m_split(simplex::Simplex::edge(mesh(), simplex.tuple()));
20 if (split_simplicies_first.empty()) return {};
21 assert(split_simplicies_first.size() == 1);
22
23 // prepare the simplex for the second split, the rib edge generated by the first split on the
24 // input face plane
25 const Tuple& split_ret_first = split_simplicies_first.front().tuple();
26 const auto edge_input_for_second_split =
27 simplex::Simplex::edge(mesh(), mesh().switch_tuple(split_ret_first, PrimitiveType::Edge));
28
29 // second split, split the rib edge generated by the first split on the input face plane
30 const auto split_simplicies_second = m_split(edge_input_for_second_split);
31 if (split_simplicies_second.empty()) return {};
32 assert(split_simplicies_second.size() == 1);
33
34 // prepare the simplex for the first collapse
35 const Tuple& split_ret_second = split_simplicies_second.front().tuple();
36 const auto edge_input_for_first_collapse = simplex::Simplex::edge(
37 mesh(),
38 mesh().switch_tuples(split_ret_second, {PE, PF, PT, PF, PE, PV, PE}));
39
40 // prepare the tuple for the second collapse
41 const Tuple& edge_tuple_input_for_second_collapse =
42 mesh().switch_tuples(split_ret_second, {PF, PE});
43
44 // prepare the tuple for return simplex (edge)
45 const Tuple& edge_tuple_for_return = mesh().switch_tuples(split_ret_second, {PT, PF, PE, PV});
46
47 // first collapse, merge spine edges and their related primitives generated by the first split
48 const auto collapse_simplicies_first = m_collapse(edge_input_for_first_collapse);
49 if (collapse_simplicies_first.empty()) return {};
50 assert(collapse_simplicies_first.size() == 1);
51
52 // prepare the simplex for the second collapse
53 const auto edge_input_for_second_collapse =
54 simplex::Simplex::edge(mesh(), edge_tuple_input_for_second_collapse);
55
56 // second collapse, drag the interior vertex on the ground to the "peak"
57 const auto collapse_simplicies_second = m_collapse(edge_input_for_second_collapse);
58 if (collapse_simplicies_second.empty()) return {};
59 assert(collapse_simplicies_second.size() == 1);
60
61 return {simplex::Simplex::edge(mesh(), edge_tuple_for_return)};
62}
63
64std::vector<simplex::Simplex> TetFaceSwap::unmodified_primitives(
65 const simplex::Simplex& simplex) const
66{
67 return {simplex};
68}
69
70
71} // namespace wmtk::operations::composite
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition Mesh.hpp:953
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
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
static Simplex edge(const Mesh &m, const Tuple &t)
Definition Simplex.hpp:61
const Tuple & tuple() const
Definition Simplex.hpp:53
constexpr wmtk::PrimitiveType PT
constexpr wmtk::PrimitiveType PF
constexpr PrimitiveType PE
constexpr PrimitiveType PV