9 const Tuple& operating_tuple)
11 , ee_accessor(m.create_accessor<int64_t>(m.m_ee_handle))
12 , ev_accessor(m.create_accessor<int64_t>(m.m_ev_handle))
13 , ve_accessor(m.create_accessor<int64_t>(m.m_ve_handle))
16 m_operating_tuple = operating_tuple;
17 Tuple operating_tuple_switch_vertex = m_mesh.switch_vertex(operating_tuple);
19 m_operating_edge_id = m_mesh.id_edge(m_operating_tuple);
20 m_spine_vids[0] = m_mesh.id_vertex(m_operating_tuple);
21 m_spine_vids[1] = m_mesh.id_vertex(operating_tuple_switch_vertex);
24 if (!m_mesh.is_boundary_vertex(m_operating_tuple)) {
25 m_neighbor_eids[0] = m_mesh.id_edge(m_mesh.switch_edge(m_operating_tuple));
27 if (!m_mesh.is_boundary_vertex(operating_tuple_switch_vertex)) {
28 m_neighbor_eids[1] = m_mesh.id_edge(m_mesh.switch_edge(operating_tuple_switch_vertex));
32 if (m_neighbor_eids[0] == m_neighbor_eids[1] && m_neighbor_eids[0] == m_operating_edge_id) {
33 m_is_self_loop =
true;
48 const std::array<std::vector<int64_t>, 2>
53 std::array<std::vector<int64_t>, 2> ids;
54 ids[1].emplace_back(m.
id_edge(tuple));
58 const std::array<std::vector<int64_t>, 2>
63 std::array<std::vector<int64_t>, 2> ids;
65 ids[1].emplace_back(m.
id_edge(tuple));
76 m_output_tuple = split_edge_single_mesh();
82 simplex_ids_to_delete = get_split_simplices_to_delete(m_operating_tuple, m_mesh);
86 const auto& data = split_facet_data().add_facet(m_mesh, m_operating_tuple);
87 m_split_e = data.new_facet_indices;
89 if (m_mesh.is_free()) {
90 const std::vector<int64_t> new_vids =
92 assert(new_vids.size() == 2);
93 std::copy(new_vids.begin(), new_vids.end(), m_free_split_v.begin());
94 const int64_t v_new = new_vids[0];
98 const std::vector<int64_t> new_vids =
100 assert(new_vids.size() == 1);
101 const int64_t v_new = new_vids[0];
104 const int64_t local_vid = m_mesh.is_ccw(m_operating_tuple) ? 0 : 1;
107 if (m_mesh.is_free()) {
110 auto ee_new_0 = ee_accessor.index_access().vector_attribute(m_split_e[0]);
111 auto ee_new_1 = ee_accessor.index_access().vector_attribute(m_split_e[1]);
112 ee_new_0[local_vid ^ 1] = m_split_e[1];
113 ee_new_1[local_vid] = m_split_e[0];
114 if (m_is_self_loop) {
115 ee_new_0[local_vid] = m_split_e[1];
116 ee_new_1[local_vid ^ 1] = m_split_e[0];
118 ee_new_0[local_vid] = m_neighbor_eids[0];
119 ee_new_1[local_vid ^ 1] = m_neighbor_eids[1];
121 for (int64_t i = 0; i < 2; i++) {
122 if (m_neighbor_eids[i] != -1) {
124 ee_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
126 ev_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
127 for (int64_t j = 0; j < 2; j++) {
128 if (ee_neighbor[j] == m_operating_edge_id &&
129 ev_neighbor[j] == m_spine_vids[i]) {
130 ee_neighbor[j] = m_split_e[i];
142 auto ev_new_0 = ev_accessor.index_access().vector_attribute(m_split_e[0]);
143 auto ev_new_1 = ev_accessor.index_access().vector_attribute(m_split_e[1]);
144 ev_new_0[local_vid] = m_spine_vids[0];
145 if (m_mesh.is_free()) {
146 ev_new_0[local_vid ^ 1] = m_free_split_v[0];
147 ev_new_1[local_vid] = m_free_split_v[1];
149 ev_new_0[local_vid ^ 1] = m_split_v;
150 ev_new_1[local_vid] = m_split_v;
152 ev_new_1[local_vid ^ 1] = m_spine_vids[1];
158 if (m_mesh.is_free()) {
159 ve_accessor.index_access().scalar_attribute(m_free_split_v[0]) = m_split_e[0];
160 ve_accessor.index_access().scalar_attribute(m_free_split_v[1]) = m_split_e[1];
162 ve_accessor.index_access().scalar_attribute(m_split_v) = m_split_e[0];
166 ve_accessor.index_access().scalar_attribute(m_spine_vids[0]) = m_split_e[0];
167 ve_accessor.index_access().scalar_attribute(m_spine_vids[1]) = m_split_e[1];
173 auto ret_edge = m_mesh.edge_tuple_from_id(m_split_e[1]);
176 if (!m_mesh.is_free()) {
177 if (m_mesh.id_vertex(ret_edge) != m_split_v) {
178 ret_edge = m_mesh.switch_vertex(ret_edge);
180 assert(m_mesh.id_edge(ret_edge) == m_split_e[1]);
181 assert(m_mesh.id_vertex(ret_edge) == m_split_v);
182 assert(m_mesh.id_vertex(m_mesh.switch_vertex(ret_edge)) == m_spine_vids[1]);
197 m_output_tuple = collapse_edge_single_mesh();
204 if (m_mesh.is_free()) {
205 simplex_ids_to_delete = get_collapse_simplices_to_delete(m_operating_tuple, m_mesh);
212 if (m_is_self_loop || (m_mesh.is_boundary_vertex(m_operating_tuple) &&
213 m_mesh.is_boundary_vertex(m_mesh.switch_vertex(m_operating_tuple)))) {
217 simplex_ids_to_delete = get_collapse_simplices_to_delete(m_operating_tuple, m_mesh);
222 for (int64_t i = 0; i < 2; i++) {
223 if (m_neighbor_eids[i] != -1) {
224 auto ee_neighbor = ee_accessor.index_access().vector_attribute(m_neighbor_eids[i]);
225 for (int64_t j = 0; j < 2; j++) {
226 if (ee_neighbor[j] == m_operating_edge_id) {
227 ee_neighbor[j] = m_neighbor_eids[i ^ 1];
237 if (m_neighbor_eids[0] != -1) {
238 auto ev_neighbor = ev_accessor.index_access().vector_attribute(m_neighbor_eids[0]);
239 for (int64_t j = 0; j < 2; j++) {
240 if (ev_neighbor[j] == m_spine_vids[0]) {
241 ev_neighbor[j] = m_spine_vids[1];
250 ve_accessor.index_access().scalar_attribute(m_spine_vids[1]) =
251 (m_neighbor_eids[1] != -1) ? m_neighbor_eids[1] : m_neighbor_eids[0];
257 const int64_t ret_eid = m_neighbor_eids[0] == -1 ? m_neighbor_eids[1] : m_neighbor_eids[0];
258 Tuple ret_tuple = m_mesh.edge_tuple_from_id(ret_eid);
260 if (m_mesh.id_vertex(ret_tuple) != m_spine_vids[1]) {
261 ret_tuple = m_mesh.switch_vertex(ret_tuple);
270 m_mesh.guarantee_more_attributes(type, count);
271 return m_mesh.request_simplex_indices(type, count);
Tuple collapse_edge_single_mesh()
void update_hash_in_map(EdgeMesh &child_mesh)
EdgeMeshOperationExecutor(EdgeMesh &m, const Tuple &operating_tuple)
std::vector< int64_t > request_simplex_indices(const PrimitiveType type, int64_t count)
static const std::array< std::vector< int64_t >, 2 > get_split_simplices_to_delete(const Tuple &tuple, const EdgeMesh &m)
gather all simplices that are deleted in a split
std::array< attribute::Accessor< char >, 2 > flag_accessors
Tuple split_edge_single_mesh()
static const std::array< std::vector< int64_t >, 2 > get_collapse_simplices_to_delete(const Tuple &tuple, const EdgeMesh &m)
gather all simplices that are deleted in a collapse
int64_t id_edge(const Tuple &tuple) const
Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const override
switch the orientation of the Tuple of the given dimension
int64_t id_vertex(const Tuple &tuple) const
std::vector< int64_t > request_simplex_indices(PrimitiveType type, int64_t count)
const attribute::Accessor< char > get_flag_accessor(PrimitiveType type) const
std::array< std::vector< int64_t >, 2 > simplex_ids_to_delete