38 #ifndef BGEOT_MESH_STRUCTURE_H__ 39 #define BGEOT_MESH_STRUCTURE_H__ 47 struct APIDECL mesh_convex_structure {
48 typedef std::vector<size_type> ind_pt_ct;
55 mesh_convex_structure() : cstruct(0) {}
77 typedef std::vector<size_type> ind_cv_ct;
78 typedef std::vector<size_type> ind_set;
85 dal::dynamic_tas<mesh_convex_structure, 8> convex_tab;
92 {
return convex_tab.index(); }
94 dal::bit_vector convex_index(dim_type)
const;
99 {
return convex_tab.index().last_true()+1; }
102 size_type nb_max_points()
const {
return points_tab.
size(); }
108 const {
return convex_tab[ic].pts; }
113 {
return convex_tab[ic].cstruct; }
116 {
return convex_tab[ic].cstruct->nb_points(); }
119 {
return short_type(convex_tab[ic].cstruct->nb_faces()); }
136 ITER ipts,
bool *present = 0);
137 template<
class ITER>
size_type add_simplex(dim_type dim, ITER ipts)
147 void sup_convex_with_points(ITER ipts,
short_type nb);
149 {
size_type t[2]; t[0] = a; t[1] = b; sup_convex_with_points(&t[0], 2); }
156 void to_faces(dim_type n);
163 std::vector<size_type> &ipt)
const;
167 {
return points_tab[ip]; }
169 void ind_points_to_point(
size_type, ind_set &)
const;
185 ind_pt_face_ct ind_points_of_face_of_convex(
size_type ic,
191 void optimize_structure();
210 const std::vector<short_type> &ftab,
217 void neighbours_of_convex(
size_type ic, ind_set &s)
const;
236 {
return (neighbour_of_convex(ic, f) !=
size_type(-1)); }
240 {
return points_tab[ip].
empty() ?
size_type(-1) : points_tab[ip][0]; }
256 std::vector<size_type> &cmk);
261 const ind_cv_ct &pt = ind_points_of_convex(ic);
263 if (std::find(pt.begin(), pt.end(), *pit) == pt.end())
268 template<
class ITER>
bool 273 if (std::find(pt.begin(), pt.end(), *pit) == pt.end())
return false;
280 mesh_convex_structure s; s.cstruct = cs;
283 if (is !=
size_type(-1)) { sup_convex(is); convex_tab.add_to_index(is,s); }
284 else is = convex_tab.add(s);
286 convex_tab[is].pts.resize(nb);
287 for (
size_type i = 0; i < nb; ++i, ++ipts)
288 { convex_tab[is].pts[i] = *ipts; points_tab[*ipts].push_back(is); }
294 ITER ipts,
bool *present) {
295 if (present) *present =
false;
296 for (
size_type i = 0; i < points_tab[*ipts].size(); ++i)
297 if (structure_of_convex(points_tab[*ipts][i]) == cs &&
298 is_convex_having_points(points_tab[*ipts][i], cs->nb_points(), ipts))
299 {
if (present) *present =
true;
return points_tab[*ipts][i]; }
300 return add_convex_noverif(cs, ipts);
306 for (
size_type i = 0; i < points_tab[*ipts].size(); ++i)
307 if (is_convex_having_points(points_tab[*ipts][i], nb, ipts))
308 sup_convex(points_tab[*ipts][i]);
320 struct APIDECL edge_list_elt {
323 inline bool operator < (
const edge_list_elt &e)
const {
324 if (i < e.i)
return true;
325 if (i > e.i)
return false;
326 if (j < e.j)
return true;
else if (j > e.j)
return false;
327 if (cv < e.cv)
return true;
331 { i = std::min(ii, jj); j = std::max(ii, jj); }
335 typedef dal::dynamic_tree_sorted<edge_list_elt> edge_list;
339 std::vector<size_type> points_of_convex,
342 void APIDECL mesh_edge_list(
const mesh_structure &m, edge_list &el,
343 bool merge_convex =
true);
bool empty(void) const
True if no space is allocated.
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
short_type nb_points_of_convex(size_type ic) const
Return the number of points of convex ic.
Definition of convex structures.
pconvex_structure structure_of_convex(size_type ic) const
Return the pconvex_structure of the convex ic.
void sup_convex_with_points(ITER ipts, short_type nb)
Remove a convex given its points.
const ind_cv_ct & convex_to_point(size_type ip) const
Return a container of the convexes attached to point ip.
bool is_convex_face_having_points(size_type ic, short_type face_num, short_type nb, ITER pit) const
Return true if the face of the convex contains the given list of points.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
size_type nb_convex() const
The total number of convexes in the mesh.
size_t size_type
used as the common size type in the library
bool is_convex_having_points(size_type ic, short_type nb, ITER pit) const
Return true if the convex contains the listed points.
bool is_point_valid(size_type i) const
Return true if the point i is used by at least one convex.
a balanced tree stored in a dal::dynamic_array
size_type size(void) const
Number of allocated elements.
gmm::uint16_type short_type
used as the common short type integer in the library
size_type add_convex(pconvex_structure cs, ITER ipts, bool *present=0)
Insert a new convex in the mesh_structure.
size_type nb_allocated_convex() const
The number of convex indexes from 0 to the index of the last convex.
size_type first_convex_of_point(size_type ip) const
Convex ID of the first convex attached to the point ip.
pconvex_structure simplex_structure(dim_type nc)
Give a pointer on the structures of a simplex of dimension d.
Mesh structure definition.
bool is_convex_valid(size_type i)
Return true if i is in convex_index()
void cuthill_mckee_on_convexes(const bgeot::mesh_structure &ms, std::vector< size_type > &cmk)
Return the cuthill_mc_kee ordering on the convexes.
const ind_cv_ct & ind_points_of_convex(size_type ic) const
Return a container to the list of points attached to convex ic.
short_type nb_faces_of_convex(size_type ic) const
Return the number of faces of convex ic.
const dal::bit_vector & convex_index() const
Return the list of valid convex IDs.