14 , m_collapse_index(collapse_index)
19 const auto split_simplicies =
m_split(simplex);
20 if (split_simplicies.empty())
return {};
21 assert(split_simplicies.size() == 1);
24 const Tuple& split_ret = split_simplicies.front().tuple();
25 assert(!
mesh().is_boundary(split_simplicies.front()));
26 auto iter_tuple = split_ret;
27 std::vector<Tuple> candidate_edge_tuples;
32 if (iter_tuple == split_ret) {
46 const auto split_tuple_open_star =
48 std::array<std::vector<simplex::Simplex>, 4> simplices_generated_by_split;
53 const auto v_open_star =
55 const auto e_closed_star =
59 std::array<std::vector<simplex::Simplex>, 4> simplices_deleted_by_collapse;
66 assert(simplices_generated_by_split[1].size() >= simplices_deleted_by_collapse[1].size());
68 bool able_to_return_edges =
true;
69 if (simplices_generated_by_split[1].size() == simplices_deleted_by_collapse[1].size())
70 able_to_return_edges =
false;
73 std::vector<simplex::Simplex> edges_generated_by_swap;
74 std::vector<simplex::Simplex> faces_generated_by_swap;
81 if (able_to_return_edges) {
83 simplices_generated_by_split[1].begin(),
84 simplices_generated_by_split[1].end(),
87 simplices_deleted_by_collapse[1].begin(),
88 simplices_deleted_by_collapse[1].end(),
92 simplices_generated_by_split[1].begin(),
93 simplices_generated_by_split[1].end(),
94 simplices_deleted_by_collapse[1].begin(),
95 simplices_deleted_by_collapse[1].end(),
96 std::back_inserter(edges_generated_by_swap),
100 edges_generated_by_swap.size() ==
101 (simplices_generated_by_split[1].size() - simplices_deleted_by_collapse[1].size()));
105 assert(simplices_generated_by_split[2].size() >= simplices_deleted_by_collapse[2].size());
108 simplices_generated_by_split[2].begin(),
109 simplices_generated_by_split[2].end(),
112 simplices_deleted_by_collapse[2].begin(),
113 simplices_deleted_by_collapse[2].end(),
117 simplices_generated_by_split[2].begin(),
118 simplices_generated_by_split[2].end(),
119 simplices_deleted_by_collapse[2].begin(),
120 simplices_deleted_by_collapse[2].end(),
121 std::back_inserter(faces_generated_by_swap),
125 faces_generated_by_swap.size() ==
126 (simplices_generated_by_split[2].size() - simplices_deleted_by_collapse[2].size()));
127 assert(faces_generated_by_swap.size() == 1);
129 if (faces_generated_by_swap.size() != 1) {
130 std::cout <<
"swap return more than one face!!" << std::endl;
131 throw std::runtime_error(
"faces_generated_by_swap.size() != 1");
137 const auto collapse_simplicies =
139 if (collapse_simplicies.empty())
return {};
140 assert(collapse_simplicies.size() == 1);
142 if (able_to_return_edges) {
143 for (int64_t i = 0; i < edges_generated_by_swap.size(); ++i) {
144 edges_generated_by_swap[i] =
148 return edges_generated_by_swap;
150 for (int64_t i = 0; i < faces_generated_by_swap.size(); ++i) {
151 faces_generated_by_swap[i] =
155 return faces_generated_by_swap;
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
PrimitiveType primitive_type() const override
const Mesh & mesh() const
std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex) override
returns an empty vector in case of failure
std::vector< simplex::Simplex > unmodified_primitives(const simplex::Simplex &simplex) const override
Returns all simplices that will be potentially affected by the operation.
TetEdgeSwap(Mesh &m, int64_t collapse_index=0)
static SimplexCollection get_intersection(const SimplexCollection &collection_a, const SimplexCollection &collection_b)
Get intersection of two simplex collections.
static Simplex face(const Mesh &m, const Tuple &t)
static Simplex edge(const Mesh &m, const Tuple &t)
static Simplex vertex(const Mesh &m, const Tuple &t)
static bool less(const Mesh &m, const Simplex &s0, const Simplex &s1)
SimplexCollection open_star(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
SimplexCollection closed_star(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
The closed star contains the input simplex, all its top dimension cofaces, and their faces.
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.