33 if (M.type == MeshType::TET)
37 idx.
face = M.HF(0, hi);
46 else if (M.elements[hi].hex)
56 vector<uint32_t> fvs, fvs_;
57 fvs.insert(fvs.end(), M.elements[hi].vs.begin(), M.elements[hi].vs.begin() + 4);
58 sort(fvs.begin(), fvs.end());
61 for (uint32_t i = 0; i < 6; i++)
64 fvs_ = M.faces[M.elements[hi].fs[i]].vs;
65 sort(fvs_.begin(), fvs_.end());
66 if (std::equal(fvs.begin(), fvs.end(), fvs_.begin()))
71 idx.
vertex = M.elements[hi].vs[0];
74 int v0 = idx.
vertex, v1 = M.elements[hi].vs[1];
75 const vector<uint32_t> &ves0 = M.vertices[v0].neighbor_es, &ves1 = M.vertices[v1].neighbor_es;
76 std::array<uint32_t, 2> sharedes;
79 idx.
edge = sharedes[0];
129 if (M.type == MeshType::TET)
131 for (
int i = 0; i < 4; i++)
133 const auto &fid = M.HF(i, idx.
element);
134 for (
int j = 0; j < 3; j++)
136 const auto &eid = M.FE(j, fid);
137 assert(M.EV(0, eid) < M.EV(1, eid));
138 if (M.EV(0, eid) == v0 && M.EV(1, eid) == v1)
143 if (M.FV(0, fid) == idx.
vertex)
145 else if (M.FV(1, fid) == idx.
vertex)
150 assert(idx.
vertex == v0i);
161 for (
int i = 0; i < M.elements[hi].fs.size(); i++)
163 const auto &fid = M.elements[hi].fs[i];
164 for (
int j = 0; j < M.faces[fid].es.size(); j++)
166 const auto &eid = M.faces[fid].es[j];
167 assert(M.edges[eid].vs[0] < M.edges[eid].vs[1]);
168 if (M.edges[eid].vs[0] == v0 && M.edges[eid].vs[1] == v1)
173 for (
int k = 0; k < M.faces[fid].vs.size(); k++)
174 if (M.faces[fid].vs[k] == idx.
vertex)
177 assert(idx.
vertex == v0i);
200 int v0_ = v0, v1_ = v1;
215 if (M.type == MeshType::TET)
217 for (
int i = 0; i < 4; i++)
219 const auto &fid = M.HF(i, idx.
element);
220 int fv0 = M.FV(0, fid), fv1 = M.FV(1, fid), fv2 = M.FV(2, fid);
232 if (v0 != fv0 || v1 != fv1 || v2 != fv2)
238 for (
int j = 0; j < 3; j++)
240 const auto &eid = M.FE(j, fid);
241 assert(M.EV(0, eid) < M.EV(1, eid));
242 if (M.EV(0, eid) == v0_ && M.EV(1, eid) == v1_)
245 if (M.FV(0, fid) == idx.
vertex)
247 else if (M.FV(1, fid) == idx.
vertex)
252 assert(idx.
vertex == v0i);
262 assert(M.elements[idx.
element].fs.size() == 4);
263 for (
int i = 0; i < 4; i++)
265 const auto fid = M.elements[idx.
element].fs[i];
266 const auto &fvid = M.faces[fid].vs;
267 int fv0 = fvid[0], fv1 = fvid[1], fv2 = fvid[2];
279 if (v0 != fv0 || v1 != fv1 || v2 != fv2)
285 for (
int j = 0; j < 3; j++)
287 const auto eid = M.faces[fid].es[j];
288 const auto &veid = M.edges[eid].vs;
289 assert(veid[0] < veid[1]);
290 if (veid[0] == v0_ && veid[1] == v1_)
293 if (fvid[0] == idx.
vertex)
295 else if (fvid[1] == idx.
vertex)
300 assert(idx.
vertex == v0i);
373 if (M.type == MeshType::TET)
375 for (
int i = 0; i < 4; i++)
377 const auto &fid = M.HF(i, idx.
element);
380 if (M.FE(0, fid) == idx.
edge || M.FE(1, fid) == idx.
edge || M.FE(2, fid) == idx.
edge)
384 if (M.FV(0, fid) == idx.
vertex)
386 else if (M.FV(1, fid) == idx.
vertex)
396 const vector<uint32_t> &efs = M.edges[idx.
edge].neighbor_fs, &hfs = M.elements[idx.
element].fs;
397 std::array<uint32_t, 2> sharedfs;
400 if (sharedfs[0] == idx.
face)
401 idx.
face = sharedfs[1];
403 idx.
face = sharedfs[0];
404 for (
int i = 0; i < hfs.size(); i++)
405 if (idx.
face == hfs[i])
411 const vector<uint32_t> &fvs = M.faces[idx.
face].vs;
412 for (
int i = 0; i < fvs.size(); i++)