30 dal::bit_vector res = convex_tab.index();
31 for (dal::bv_visitor cv(convex_tab.index()); !cv.finished(); ++cv)
38 mesh_convex_structure::ind_pt_ct::const_iterator it;
40 for (it=convex_tab[ic].pts.begin();
41 it != convex_tab[ic].pts.end() && (*it) != ip; ++it) ++ind;
42 GMM_ASSERT1(it != convex_tab[ic].pts.end(),
43 "This point does not exist on this convex.");
49 std::vector<size_type> doubles;
53 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l) {
55 if (ind == i) ind = j;
56 else if (ind == j) { ind = i; doubles.push_back(cv); }
61 if (std::find(doubles.begin(), doubles.end(), cv) == doubles.end()) {
62 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
63 if (convex_tab[cv].pts[l] == j) convex_tab[cv].pts[l] = i;
71 std::vector<size_type> doubles;
74 for (
size_type k = 0; k < convex_tab[i].pts.size(); ++k) {
78 if (ind == i) ind = j;
79 else if (ind == j) { ind = i; doubles.push_back(ip); }
83 for (
size_type k = 0; k < convex_tab[j].pts.size(); ++k) {
85 if (std::find(doubles.begin(), doubles.end(), ip) == doubles.end()) {
87 if (points_tab[ip][l] == j) points_tab[ip][l] = i;
102 for (
size_type l = 0; l < convex_tab[ic].pts.size(); ++l) {
104 std::vector<size_type>::iterator it1= points_tab[ind].
begin(), it2 = it1;
105 std::vector<size_type>::iterator ite= points_tab[ind].
end();
106 for (; it2 != ite; ++it2) { *it1 = *it2;
if (*it1 != ic) ++it1; }
107 points_tab[ind].pop_back();
119 for (
short_type iff = 0; iff < ps->nb_faces(); ++iff)
126 for (dal::bv_visitor i(nn); !i.finished(); ++i)
127 if (convex_tab[i].cstruct->dim() == n)
134 for (dal::bv_visitor i(nn); !i.finished(); ++i)
135 dmax = std::max(dmax, convex_tab[i].cstruct->dim());
136 for ( ; dmax > 1; --dmax)
to_faces(dmax);
143 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
144 if (convex_tab[cv].pts[l] == i2) { ++nb;
break; }
150 std::vector<size_type> &ipt)
const {
154 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
155 if (convex_tab[cv].pts[l] == i2) { ipt.push_back(cv);
break; }
164 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
165 if (ip != convex_tab[cv].pts[l]) {
167 if (std::find(s.begin(), s.end(), ind) != s.end()) s.push_back(ind);
175 const mesh_convex_structure *q = &(convex_tab[ic]);
176 std::vector<size_type>::const_iterator r = q->pts.begin();
177 const convex_ind_ct *p = &(q->cstruct->ind_points_of_face(iff));
181 size_type mesh_structure::memsize(
void)
const {
183 + convex_tab.memsize();
184 for (
size_type i = 0; i < convex_tab.size(); ++i)
185 mems += convex_tab[i].pts.size() *
sizeof(
size_type);
187 mems += points_tab[i].size() *
sizeof(
size_type);
193 for (i = 0; i < j; i++)
194 if (!convex_tab.index_valid(i))
197 if (points_tab.
size())
198 for (i=0, j = (points_tab.
end()-points_tab.
begin())-1; i < j; ++i, --j){
199 while (i < j && !(points_tab[i].empty())) ++i;
200 while (i < j && points_tab[j].empty()) --j;
206 points_tab = dal::dynamic_tas<ind_cv_ct, 8>();
207 convex_tab = dal::dynamic_tas<mesh_convex_structure, 8>();
211 void mesh_structure::stat(
void) {
212 cout <<
"mesh structure with " <<
nb_convex() <<
" valid convex, "
213 <<
"for a total memory size of " << memsize() <<
" bytes.\n";
226 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
233 const std::vector<short_type> &ftab,
236 std::vector<size_type> ipts;
238 switch (ftab.size()) {
242 ipts.resize(pt.size());
243 std::copy(pt.begin(), pt.end(), ipts.begin());
250 ipts.resize(pt.size());
251 std::copy(pt.begin(), pt.end(), ipts.begin());
257 const mesh_convex_structure &q = convex_tab[ic];
258 const convex_ind_ct &ind = q.cstruct->ind_common_points_of_faces(ftab);
260 ipts.resize(ind.size());
261 auto it = ind.cbegin();
262 for (
size_type &ipt : ipts) ipt = q.pts[*it++];
267 if (ipts.size() == 0) {
271 auto ipt0 = ipts.cbegin();
272 auto ipt1 = ipt0 + 1;
274 for (
size_type icv : points_tab[*ipt0]) {
290 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
291 if (std::find(s.begin(), s.end(), icv) == s.end())
305 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
313 if (neighbor_element ==
size_type(-1))
return convex_face::invalid_face();
316 auto nNeighborElementFaces = pcs->nb_faces();
317 for (
short_type iff = 0; iff < nNeighborElementFaces; ++iff) {
318 auto nPointsOnFace = pcs->nb_points_of_face(iff);
320 nPointsOnFace, face_points.begin()))
321 return {neighbor_element, iff};
323 GMM_ASSERT2(
false,
"failed to determine neighboring face");
324 return convex_face::invalid_face();
330 ind_cv_ct::const_iterator it = std::find(ct.begin(), ct.end(), ip);
331 return (it != ct.end()) ? (it - ct.begin()):
size_type(-1);
340 void mesh_edge_list_convex(
pconvex_structure cvs, std::vector<size_type> points_of_convex,
341 size_type cv_id, edge_list &el,
bool merge_convex)
343 dim_type n = cvs->dim();
345 size_type ncv = merge_convex ? 0 : cv_id;
348 for (dim_type k = 0; k < n; ++k)
349 for (dim_type l = dim_type(k+1); l <= n; ++l)
350 el.add(edge_list_elt(points_of_convex[k],
351 points_of_convex[l], ncv));
356 for (dim_type j = 0; j < n; ++j)
357 if ((k & (1 << j)) == 0)
358 el.add(edge_list_elt(points_of_convex[k],
359 points_of_convex[k | (1 << j)], ncv));
362 for (dim_type k = 0; k < n - 1; ++k)
363 for (dim_type l = dim_type(k+1); l < n; ++l) {
364 el.add(edge_list_elt(points_of_convex[k],
365 points_of_convex[l], ncv));
366 el.add(edge_list_elt(points_of_convex[k+n],
367 points_of_convex[l+n], ncv));
369 for (dim_type k = 0; k < n; ++k)
370 el.add(edge_list_elt(points_of_convex[k],
371 points_of_convex[k+n], ncv));
378 indpttab[0].resize(cvstab[0]->nb_points());
379 std::copy(points_of_convex.begin(),
380 points_of_convex.end(), indpttab[0].begin());
389 std::vector< size_type > pts = indpttab[ncs];
390 if (cvs->dim() == 1) {
392 for (
size_type j = 1; j < cvs->nb_points(); ++j) {
394 el.add(edge_list_elt((indpttab[ncs])[j-1],(indpttab[ncs])[j],ncv));
401 cvstab[ncs+f] = (cvs->faces_structure())[f];
402 indpttab[ncs+f].resize(cvs->nb_points_of_face(f));
411 for (
size_type k = 0; k < cvs->nb_points_of_face(f); ++k)
412 (indpttab[ncs+f])[k] = pts[cvs->ind_points_of_face(f)[k]];
424 void mesh_edge_list(
const mesh_structure &m, edge_list &el,
426 std::vector<size_type> p;
427 for (dal::bv_visitor cv(m.convex_index()); !cv.finished(); ++cv) {
428 p.resize(m.nb_points_of_convex(cv));
429 std::copy(m.ind_points_of_convex(cv).begin(),
430 m.ind_points_of_convex(cv).end(), p.begin());
431 mesh_edge_list_convex(m.structure_of_convex(cv), p, cv,
439 std::vector<size_type> &cmk) {
441 cmk.reserve(cvlst.card()); cmk.resize(0);
443 std::deque<int> pile;
444 std::vector<size_type> tab, connectivity(cvlst.last_true()+1),
445 temp(cvlst.last_true()+1);
449 std::fill(connectivity.begin(), connectivity.end(),
size_type(-1));
453 for (dal::bv_visitor j(cvlst); !j.finished(); ++j) {
455 mesh_structure::ind_cv_ct::const_iterator itp = ct.begin(),
459 for (; itp != itpe; ++itp) {
461 mesh_structure::ind_cv_ct::const_iterator
464 for ( ; it != ite; ++it)
465 if (temp[*it] != j+1) { temp[*it] = j+1; nei++; }
467 connectivity[j] = nei-1;
468 if (nei < connectivity[cv]) cv = j;
479 mesh_structure::ind_cv_ct::const_iterator
482 for ( ; it != ite; ++it)
483 if (connectivity[*it] !=
size_type(-1)) {
485 pile.push_front(
int(*it));
490 cv = std::min_element(connectivity.begin(), connectivity.end()) - connectivity.begin();
491 if (connectivity[cv] ==
size_type(-1))
break;
493 else { cv = pile.back(); pile.pop_back(); }