Geogram  Version 1.8.9-rc
A programming library of geometric algorithms
mesh.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef GEOGRAM_MESH_MESH
41 #define GEOGRAM_MESH_MESH
42 
43 #include <geogram/basic/common.h>
44 #include <geogram/basic/range.h>
46 #include <geogram/basic/geometry.h>
47 
53 namespace GEO {
54 
55  class Mesh;
56 
57  static constexpr index_t NO_VERTEX = NO_INDEX;
58  static constexpr index_t NO_EDGE = NO_INDEX;
59  static constexpr index_t NO_FACET = NO_INDEX;
60  static constexpr index_t NO_CELL = NO_INDEX;
61  static constexpr index_t NO_CORNER = NO_INDEX;
62 
70  class GEOGRAM_API MeshSubElementsStore {
71  public:
72 
79 
84 
89  index_t nb() const {
90  return nb_;
91  }
92 
101  return const_cast<AttributesManager&>(attributes_);
102  }
103 
109  return index_as_iterator(0);
110  }
111 
117  return index_as_iterator(nb());
118  }
119 
120  protected:
121 
131  virtual void clear_store(
132  bool keep_attributes, bool keep_memory = false
133  );
134 
141  virtual void resize_store(index_t new_size);
142 
143 
148  void reserve_store(index_t nb_to_reserve) {
149  index_t nb = this->nb();
150  resize_store(nb + nb_to_reserve);
151  resize_store(nb);
152  }
153 
160  index_t result = nb_;
161  if(nb_ + nb > attributes_.size()) {
162  index_t new_capacity=nb_ + nb;
163  if(nb < 128) {
164  new_capacity = std::max(index_t(16),attributes_.size());
165  while(new_capacity < nb_ + nb) {
166  new_capacity *= 2;
167  }
168  }
169  attributes_.reserve(new_capacity);
170  }
171  nb_ += nb;
172  attributes_.resize(nb_);
173  return result;
174  }
175 
181  index_t result = nb_;
182  ++nb_;
183  if(attributes_.capacity() < nb_) {
184  index_t new_capacity =
185  std::max(index_t(16),attributes_.capacity()*2);
186  attributes_.reserve(new_capacity);
187  }
188  attributes_.resize(nb_);
189  return result;
190  }
191 
201  void adjust_store() {
202  attributes_.resize(nb_);
203  }
204 
214  void copy(
215  const MeshSubElementsStore& rhs,
216  bool copy_attributes = true
217  ) {
218  nb_ = rhs.nb();
219  if(copy_attributes) {
220  attributes_.copy(rhs.attributes_);
221  } else {
222  attributes_.clear(false,false);
223  attributes_.resize(rhs.attributes_.size());
224  }
225  }
226 
227  protected:
228  Mesh& mesh_;
229  AttributesManager attributes_;
230  index_t nb_;
231  };
232 
233 
234  /**************************************************************************/
235 
243  class GEOGRAM_API MeshElements {
244  public:
245  MeshElements();
246  virtual ~MeshElements();
247 
257  virtual void delete_elements(
258  vector<index_t>& to_delete,
259  bool remove_isolated_vertices=true
260  ) = 0;
261 
274  virtual void permute_elements(vector<index_t>& permutation) = 0;
275 
285  virtual void clear(
286  bool keep_attributes=true, bool keep_memory=false
287  ) = 0;
288 
292  virtual void pop() = 0;
293 
294  protected:
302  static bool has_non_zero(const GEO::vector<index_t>& I) {
303  for(index_t i = 0; i < I.size(); i++) {
304  if(I[i] != 0) {
305  return true;
306  }
307  }
308  return false;
309  }
310  };
311 
312  /**************************************************************************/
313 
314  class MeshEdges;
315  class MeshFacetCornersStore;
316  class MeshCellCornersStore;
317 
322  class GEOGRAM_API MeshVertices :
323  public MeshSubElementsStore, public MeshElements {
324  public:
325  MeshVertices(Mesh& mesh);
326  ~MeshVertices() override;
327 
333 
335  vector<index_t>& to_delete, bool remove_isolated_vertices=true
336  ) override;
337 
338  void permute_elements(vector<index_t>& permutation) override;
339 
346  }
347 
353  index_t create_vertex(const double* coords) {
354  // Sanity check:
355  // It is not correct to call create_vertex(point_ptr(v)) since
356  // create_vertex may realloc the points coordinates vector, thus
357  // invalidate point_ptr(v).
359  nb() == 0 ||
360  coords < point_ptr(0) ||
361  coords >= point_ptr(0) + nb() * dimension()
362  );
363  index_t result = create_vertex();
364  for(index_t c=0; c<dimension(); ++c) {
365  point_ptr(result)[c] = coords[c];
366  }
367  return result;
368  }
369 
377  }
378 
379  void clear(
380  bool keep_attributes=true, bool keep_memory=false
381  ) override;
382 
391 
401 
408  bool single_precision() const {
409  return point_fp32_.is_bound();
410  }
411 
419  bool double_precision() const {
420  return point_.is_bound();
421  }
422 
427  index_t dimension() const {
428  return
429  single_precision() ?
430  point_fp32_.dimension() :
431  point_.dimension() ;
432  }
433 
440  void set_dimension(index_t dim) {
441  if(single_precision()) {
442  point_fp32_.redim(dim);
443  } else {
444  point_.redim(dim);
445  }
446  }
447 
455  const double* point_ptr(index_t v) const {
456  geo_debug_assert(v < nb());
457  geo_debug_assert(!single_precision());
458  return &point_[v*point_.dimension()];
459  }
460 
468  double* point_ptr(index_t v) {
469  geo_debug_assert(v < nb());
470  geo_debug_assert(!single_precision());
471  return &point_[v*point_.dimension()];
472  }
473 
474 
483  geo_debug_assert(v < nb());
484  geo_debug_assert(!single_precision());
485  geo_debug_assert(dimension() >= 3);
486  return *(vec3*)(&point_[v*point_.dimension()]);
487  }
488 
496  const vec3& point(index_t v) const {
497  geo_debug_assert(v < nb());
498  geo_debug_assert(!single_precision());
499  geo_debug_assert(dimension() >= 3);
500  return *(const vec3*)(&point_[v*point_.dimension()]);
501  }
502 
510  const float* single_precision_point_ptr(index_t v) const {
511  geo_debug_assert(v < nb());
512  geo_debug_assert(single_precision());
513  return &point_fp32_[v*point_fp32_.dimension()];
514  }
515 
524  geo_debug_assert(v < nb());
525  geo_debug_assert(single_precision());
526  return &point_fp32_[v*point_fp32_.dimension()];
527  }
528 
539  vector<double>& points, index_t dim, bool steal_arg
540  );
541 
551  const double* points, index_t dim, index_t nb_pts
552  );
553 
554  void pop() override;
555 
556  protected:
557 
559  bool keep_attributes, bool keep_memory = false
560  ) override;
561 
562  void resize_store(index_t new_size) override;
563 
564  void bind_point_attribute(index_t dim, bool single_precision=false);
565 
566  void copy(const MeshVertices& rhs, bool copy_attributes=true) {
567  index_t dim = rhs.dimension();
568  if(point_fp32_.is_bound()) {
569  point_fp32_.destroy();
570  }
571  if(point_.is_bound()) {
572  point_.destroy();
573  }
574  MeshSubElementsStore::copy(rhs, copy_attributes);
575  if(rhs.single_precision()) {
576  point_fp32_.bind_if_is_defined(attributes(),"point_fp32");
577  if(!point_fp32_.is_bound()) {
578  point_fp32_.create_vector_attribute(
579  attributes(), "point_fp32", dim
580  );
581  }
582  } else {
583  point_.bind_if_is_defined(attributes(),"point");
584  if(!point_.is_bound()) {
585  point_.create_vector_attribute(
586  attributes(), "point", dim
587  );
588  }
589  }
590  // Even if we do not copy the attributes, we need at least
591  // to copy the coordinates of the points !!
592  if(!copy_attributes) {
593  if(rhs.single_precision()) {
594  Memory::copy(
595  single_precision_point_ptr(0),
597  rhs.dimension()*rhs.nb()*sizeof(float)
598  );
599  } else {
600  Memory::copy(
601  point_ptr(0),
602  rhs.point_ptr(0),
603  rhs.dimension()*rhs.nb()*sizeof(double)
604  );
605  }
606  }
607  }
608 
609  MeshEdges& edges_;
610  MeshFacetCornersStore& facet_corners_;
611  MeshCellCornersStore& cell_corners_;
612  Attribute<double> point_;
613  Attribute<float> point_fp32_;
614 
615  friend class Mesh;
616  friend class GeogramIOHandler;
617  };
618 
619  /*************************************************************************/
620 
625  class GEOGRAM_API MeshEdges :
626  public MeshSubElementsStore, public MeshElements {
627  public:
628  MeshEdges(Mesh& mesh);
629  ~MeshEdges() override;
630 
637  index_t vertex(index_t e, index_t lv) const {
638  geo_debug_assert(e < nb());
639  geo_debug_assert(lv < 2);
640  return edge_vertex_[2*e+lv];
641  }
642 
650  geo_debug_assert(e < nb());
651  geo_debug_assert(lv < 2);
652  edge_vertex_[2*e+lv] = v;
653  }
654 
655 
663  geo_debug_assert(c < 2*nb());
664  return &(edge_vertex_[c]);
665  }
666 
673  const index_t* vertex_index_ptr(index_t c) const {
674  geo_debug_assert(c < 2*nb());
675  return &(edge_vertex_[c]);
676  }
677 
683  return create_sub_element();
684  }
685 
692  return create_sub_elements(nb);
693  }
694 
701  index_t result = create_edge();
702  set_vertex(result,0,v1);
703  set_vertex(result,1,v2);
704  return result;
705  }
706 
708  vector<index_t>& to_delete, bool remove_isolated_vertices=true
709  ) override;
710 
711  void permute_elements(vector<index_t>& permutation) override;
712 
713  void clear(
714  bool keep_attributes=true, bool keep_memory=false
715  ) override;
716 
717  void pop() override;
718 
719  protected:
721  bool keep_attributes, bool keep_memory = false
722  ) override;
723 
724  void resize_store(index_t new_size) override;
725 
726  index_t create_sub_element() {
727  edge_vertex_.push_back(NO_VERTEX);
728  edge_vertex_.push_back(NO_VERTEX);
730  }
731 
732  index_t create_sub_elements(index_t nb_in) {
733  edge_vertex_.resize(2*(nb()+nb_in),NO_VERTEX);
735  }
736 
737  void copy(const MeshEdges& rhs, bool copy_attributes=true) {
738  MeshSubElementsStore::copy(rhs, copy_attributes);
739  edge_vertex_ = rhs.edge_vertex_;
740  }
741 
742  vector<index_t> edge_vertex_;
743  friend class Mesh;
744  friend class GeogramIOHandler;
745  };
746 
747  /**************************************************************************/
748 
753  class GEOGRAM_API MeshFacetsStore : public MeshSubElementsStore {
754  public:
755  MeshFacetsStore(Mesh& mesh);
756 
764  geo_debug_assert(f < nb());
765  return (is_simplicial_ ? 3*f : facet_ptr_[f]);
766  }
767 
775  geo_debug_assert(f < nb());
776  return (is_simplicial_ ? 3*(f+1): facet_ptr_[f+1]);
777  }
778 
785  geo_debug_assert(f < nb());
786  return (is_simplicial_ ? 3 : facet_ptr_[f+1] - facet_ptr_[f]);
787  }
788 
796  index_t corner(index_t f, index_t lv) const {
797  geo_debug_assert(f < nb());
798  geo_debug_assert(lv < nb_corners(f));
799  return corners_begin(f)+lv;
800  }
801 
809  bool are_simplices() const {
810  return is_simplicial_;
811  }
812 
820  geo_debug_assert(!is_simplicial_);
821  geo_debug_assert(f < nb());
822  return &facet_ptr_[f];
823  }
824 
825  protected:
827  bool keep_attributes, bool keep_memory = false
828  ) override;
829 
830  void resize_store(index_t new_size) override;
831 
832  index_t create_sub_element() {
833  if(!is_simplicial_) {
834  facet_ptr_.push_back(NO_CORNER);
835  }
837  }
838 
839  index_t create_sub_elements(index_t nb) {
840  if(!is_simplicial_) {
841  for(index_t i=0; i<nb; ++i) {
842  facet_ptr_.push_back(NO_CORNER);
843  }
844  }
846  }
847 
848  void copy(const MeshFacetsStore& rhs, bool copy_attributes=true) {
849  MeshSubElementsStore::copy(rhs,copy_attributes);
850  is_simplicial_ = rhs.is_simplicial_;
851  facet_ptr_ = rhs.facet_ptr_;
852  }
853 
854  protected:
855  bool is_simplicial_;
856  vector<index_t> facet_ptr_;
857  friend class Mesh;
858  friend class GeogramIOHandler;
859  };
860 
861  /*************************************************************************/
862 
867  class GEOGRAM_API MeshFacetCornersStore : public MeshSubElementsStore {
868  public:
870 
876  index_t vertex(index_t c) const {
877  geo_assert(c < nb());
878  return corner_vertex_[c];
879  }
880 
888  geo_assert(c < nb());
889  return corner_adjacent_facet_[c];
890  }
891 
900  geo_assert(c < nb());
901  return &corner_adjacent_facet_[c];
902  }
903 
904 
913  geo_assert(c < nb());
914  return &corner_adjacent_facet_[c];
915  }
916 
924  geo_debug_assert(c < nb());
925  geo_debug_assert(v < vertices_.nb());
926  corner_vertex_[c] = v;
927  }
928 
940  geo_debug_assert(c < nb());
941  corner_vertex_[c] = v;
942  }
943 
951  geo_debug_assert(c < nb());
952  geo_debug_assert(f == NO_FACET || f < facets_.nb());
953  corner_adjacent_facet_[c] = f;
954  }
955 
964  geo_debug_assert(c < nb());
965  return &(corner_vertex_[c]);
966  }
967 
975  const index_t* vertex_index_ptr(index_t c) const {
976  geo_debug_assert(c < nb());
977  return &(corner_vertex_[c]);
978  }
979 
980  protected:
982  bool keep_attributes, bool keep_memory = false
983  ) override;
984 
985  void resize_store(index_t new_size) override;
986 
987  index_t create_sub_element(index_t v, index_t f = NO_FACET) {
988  corner_vertex_.push_back(v);
989  corner_adjacent_facet_.push_back(f);
991  }
992 
993  index_t create_sub_elements(index_t nb) {
994  for(index_t i=0; i<nb; ++i) {
995  corner_vertex_.push_back(NO_VERTEX);
996  }
997  for(index_t i=0; i<nb; ++i) {
998  corner_adjacent_facet_.push_back(NO_FACET);
999  }
1001  }
1002 
1003  void copy(
1004  const MeshFacetCornersStore& rhs, bool copy_attributes=true
1005  ) {
1006  MeshSubElementsStore::copy(rhs, copy_attributes);
1007  corner_vertex_ = rhs.corner_vertex_;
1008  corner_adjacent_facet_ = rhs.corner_adjacent_facet_;
1009  }
1010 
1011  protected:
1012  MeshVertices& vertices_;
1013  MeshFacetsStore& facets_;
1014  vector<index_t> corner_vertex_;
1015  vector<index_t> corner_adjacent_facet_;
1016 
1017  friend class MeshFacets;
1018  friend class Mesh;
1019  friend class GeogramIOHandler;
1020  };
1021 
1022  /*************************************************************************/
1023 
1028  class GEOGRAM_API MeshFacets : public MeshFacetsStore, public MeshElements {
1029  public:
1030 
1037 
1044  return nb_corners(f);
1045  }
1046 
1055  return facet_corners_.vertex(corner(f,lv));
1056  }
1057 
1066  facet_corners_.set_vertex(corner(f,lv),v);
1067  }
1068 
1077  for(index_t lv=0; lv<nb_vertices(f); ++lv) {
1078  if(vertex(f,lv) == v) {
1079  return lv;
1080  }
1081  }
1082  return NO_VERTEX;
1083  }
1084 
1092  for(index_t lv=0; lv<nb_vertices(f1); ++lv) {
1093  index_t v = vertex(f1,lv);
1094  if(find_vertex(f2,v) != NO_VERTEX) {
1095  return lv;
1096  }
1097  }
1098  return NO_VERTEX;
1099  }
1100 
1109  return facet_corners_.adjacent_facet(corner(f,le));
1110  }
1111 
1120  for(index_t le=0; le<nb_vertices(f); ++le) {
1121  if(adjacent(f,le) == f2) {
1122  return le;
1123  }
1124  }
1125  return NO_INDEX;
1126  }
1127 
1136  facet_corners_.set_adjacent_facet(corner(f,le),f2);
1137  }
1138 
1147  geo_debug_assert(f < nb());
1148  geo_debug_assert(c >= corners_begin(f) && c < corners_end(f));
1149  return c + 1 == corners_end(f) ? corners_begin(f) : c + 1;
1150  }
1151 
1160  geo_debug_assert(f < nb());
1161  geo_debug_assert(c >= corners_begin(f) && c < corners_end(f));
1162  return c == corners_begin(f) ? corners_end(f) - 1 : c - 1;
1163  }
1164 
1173  for(index_t c1 = corners_begin(f); c1 != corners_end(f); ++c1) {
1174  index_t c2 = next_corner_around_facet(f,c1);
1175  if(
1176  facet_corners_.vertex(c1) == v1 &&
1177  facet_corners_.vertex(c2) == v2
1178  ) {
1179  return c1 - corners_begin(f);
1180  }
1181  }
1182  return NO_INDEX;
1183  }
1184 
1186  vector<index_t>& to_delete,
1187  bool remove_isolated_vertices=true
1188  ) override;
1189 
1190  void permute_elements(vector<index_t>& permutation) override;
1191 
1192  void clear(
1193  bool keep_attributes=true, bool keep_memory=false
1194  ) override;
1195 
1204  index_t nb_facets, index_t nb_vertices_per_polygon
1205  ) {
1206  if(nb_vertices_per_polygon != 3) {
1207  is_not_simplicial();
1208  }
1209 
1210  index_t first_facet = nb();
1211  index_t co = facet_corners_.nb();
1212  facet_corners_.create_sub_elements(
1213  nb_facets*nb_vertices_per_polygon
1214  );
1215  index_t result = create_sub_elements(nb_facets);
1216 
1217  if(!is_simplicial_) {
1218  for(index_t f=first_facet; f<=first_facet+nb_facets; ++f) {
1219  facet_ptr_[f] = co;
1220  co += nb_vertices_per_polygon;
1221  }
1222  geo_debug_assert(facet_ptr_.size() == nb()+1);
1223  geo_debug_assert(facet_ptr_[nb()] == facet_corners_.nb());
1224  }
1225  return result;
1226  }
1227 
1233  void reserve(index_t nb_to_reserve) {
1234  facet_corners_.reserve_store(nb_to_reserve*3);
1235  this->reserve_store(nb_to_reserve);
1236  }
1237 
1244  return create_facets(nb_triangles, 3);
1245  }
1246 
1253  return create_facets(nb_quads, 4);
1254  }
1255 
1262  geo_debug_assert(v1 != v2);
1263  geo_debug_assert(v2 != v3);
1264  geo_debug_assert(v3 != v1);
1265  facet_corners_.create_sub_element(v1);
1266  facet_corners_.create_sub_element(v2);
1267  facet_corners_.create_sub_element(v3);
1268  index_t result = create_sub_element();
1269  if(!is_simplicial_) {
1270  facet_ptr_[result+1] = facet_corners_.nb();
1271  geo_debug_assert(facet_ptr_.size() == nb()+1);
1272  geo_debug_assert(facet_ptr_[nb()] == facet_corners_.nb());
1273  }
1274  return result;
1275  }
1276 
1283  is_not_simplicial();
1284  facet_corners_.create_sub_element(v1);
1285  facet_corners_.create_sub_element(v2);
1286  facet_corners_.create_sub_element(v3);
1287  facet_corners_.create_sub_element(v4);
1288  index_t result = create_sub_element();
1289  facet_ptr_[result+1] = facet_corners_.nb();
1290  geo_debug_assert(facet_ptr_.size() == nb()+1);
1291  geo_debug_assert(facet_ptr_[nb()] == facet_corners_.nb());
1292  return result;
1293  }
1294 
1301  if(nb_vertices != 3) {
1302  is_not_simplicial();
1303  }
1304  for(index_t i=0; i<nb_vertices; ++i) {
1305  facet_corners_.create_sub_element(NO_VERTEX);
1306  }
1307  index_t result = create_sub_element();
1308  if(!is_simplicial_) {
1309  facet_ptr_[result+1] = facet_corners_.nb();
1310  geo_debug_assert(facet_ptr_.size() == nb()+1);
1311  geo_debug_assert(facet_ptr_[nb()] == facet_corners_.nb());
1312  }
1313  return result;
1314  }
1315 
1322  index_t create_polygon(index_t nb_vertices, const index_t* vertices) {
1323  if(nb_vertices != 3) {
1324  is_not_simplicial();
1325  }
1326  for(index_t i=0; i<nb_vertices; ++i) {
1327  facet_corners_.create_sub_element(vertices[i]);
1328  }
1329  index_t result = create_sub_element();
1330  if(!is_simplicial_) {
1331  facet_ptr_[result+1] = facet_corners_.nb();
1332  geo_debug_assert(facet_ptr_.size() == nb()+1);
1333  geo_debug_assert(facet_ptr_[nb()] == facet_corners_.nb());
1334  }
1335  return result;
1336  }
1337 
1345  return create_polygon(vertices.size(), vertices.data());
1346  }
1347 
1351  void connect();
1352 
1353 
1358  void triangulate();
1359 
1365  void flip(index_t f);
1366 
1372 
1385  coord_index_t dim,
1386  vector<double>& vertices,
1387  vector<index_t>& triangles,
1388  bool steal_args
1389  );
1390 
1391  /*
1392  * \brief Copies a triangle mesh into this Mesh.
1393  * \details Facet adjacence are not computed.
1394  * Facet and corner attributes are zeroed.
1395  * \param[in] triangles facet to vertex links
1396  * \param[in] steal_args if set, vertices and triangles
1397  * are 'stolen' from the arguments
1398  * (using vector::swap).
1399  */
1400  void assign_triangle_mesh(
1401  vector<index_t>& triangles,
1402  bool steal_args
1403  );
1404 
1405  void pop() override;
1406 
1413  geo_debug_assert(f < nb());
1414  return index_range(
1415  index_as_iterator(corners_begin(f)),
1416  index_as_iterator(corners_end(f))
1417  );
1418  }
1419 
1420  protected:
1421 
1425  void is_simplicial() {
1426  if(!is_simplicial_) {
1427  is_simplicial_ = true;
1428  facet_ptr_.resize(1);
1429  facet_ptr_[0] = 0;
1430  }
1431  }
1432 
1440  if(is_simplicial_) {
1441  is_simplicial_ = false;
1442  facet_ptr_.resize(nb()+1);
1443  for(index_t f=0; f<facet_ptr_.size(); ++f) {
1444  facet_ptr_[f] = 3*f;
1445  }
1446  }
1447  }
1448 
1449  protected:
1450  MeshVertices& vertices_;
1451  MeshFacetCornersStore& facet_corners_;
1452  friend class Mesh;
1453  friend class GeogramIOHandler;
1454  friend void GEOGRAM_API tessellate_facets(
1455  Mesh& M, index_t max_nb_vertices
1456  );
1457  };
1458 
1459  /*************************************************************************/
1460 
1461  enum MeshCellType {
1462  MESH_TET = 0,
1463  MESH_HEX = 1,
1464  MESH_PRISM = 2,
1465  MESH_PYRAMID = 3,
1466  MESH_CONNECTOR = 4,
1467  MESH_NB_CELL_TYPES = 5
1468  };
1469 
1478 
1481 
1484 
1489 
1493 
1498 
1503  };
1504 
1505 
1512  namespace MeshCellDescriptors {
1516  GEOGRAM_API extern CellDescriptor*
1517  cell_type_to_cell_descriptor[GEO::MESH_NB_CELL_TYPES];
1518 
1519  GEOGRAM_API extern CellDescriptor tet_descriptor;
1520  GEOGRAM_API extern CellDescriptor hex_descriptor;
1521  GEOGRAM_API extern CellDescriptor prism_descriptor;
1522  GEOGRAM_API extern CellDescriptor pyramid_descriptor;
1523  GEOGRAM_API extern CellDescriptor connector_descriptor;
1524  }
1525 
1530  class GEOGRAM_API MeshCellsStore : public MeshSubElementsStore {
1531  public:
1532  MeshCellsStore(Mesh& mesh);
1533 
1541  bool are_simplices() const {
1542  return is_simplicial_;
1543  }
1544 
1551  MeshCellType type(index_t c) const {
1552  geo_debug_assert(c < nb());
1553  return is_simplicial_ ? MESH_TET : MeshCellType(cell_type_[c]);
1554  }
1555 
1565  geo_debug_assert(c < nb());
1566  return is_simplicial_ ? MeshCellDescriptors::tet_descriptor :
1567  *(
1569  cell_type_[c]
1570  ]
1571  );
1572  }
1573 
1584  MeshCellType t
1585  ) {
1586  geo_debug_assert(t < GEO::MESH_NB_CELL_TYPES);
1588  }
1589 
1596  geo_debug_assert(c < nb());
1597  return descriptor(c).nb_vertices;
1598  }
1599 
1607  geo_debug_assert(c < nb());
1608  return is_simplicial_ ? 4*c : cell_ptr_[c];
1609  }
1610 
1618  geo_debug_assert(c < nb());
1619  return is_simplicial_ ? 4*(c+1) : cell_ptr_[c] + nb_corners(c);
1620  }
1621 
1629  geo_debug_assert(c < nb());
1630  // There seems to be a linkage problem under MSVC for the
1631  // following assertion check...
1632 #ifndef GEO_OS_WINDOWS
1633  geo_debug_assert(lv < nb_corners(c));
1634 #endif
1635  return corners_begin(c) + lv;
1636  }
1637 
1644  geo_debug_assert(c < nb());
1645  return descriptor(c).nb_facets;
1646  }
1647 
1655  geo_debug_assert(c < nb());
1656  return is_simplicial_ ? 4*c : cell_ptr_[c];
1657  }
1658 
1666  geo_debug_assert(c < nb());
1667  return is_simplicial_ ? 4*(c+1) : cell_ptr_[c] + nb_facets(c);
1668  }
1669 
1676  index_t facet(index_t c, index_t lf) const {
1677  geo_debug_assert(c < nb());
1678  geo_debug_assert(lf < nb_facets(c));
1679  return facets_begin(c) + lf;
1680  }
1681 
1688  return descriptor(c).nb_edges;
1689  }
1690 
1691  protected:
1693  bool keep_attributes, bool keep_memory = false
1694  ) override;
1695 
1696  void resize_store(index_t new_size) override;
1697 
1698  index_t create_sub_element(MeshCellType type) {
1699  if(!is_simplicial_) {
1700  cell_ptr_.push_back(NO_CORNER);
1701  cell_type_.push_back(Numeric::uint8(type));
1702  }
1704  }
1705 
1706  index_t create_sub_elements(index_t nb, MeshCellType type) {
1707  if(!is_simplicial_) {
1708  for(index_t i=0; i<nb; ++i) {
1709  cell_ptr_.push_back(NO_CORNER);
1710  cell_type_.push_back(Numeric::uint8(type));
1711  }
1712  }
1714  }
1715 
1716  void copy(
1717  const MeshCellsStore& rhs, bool copy_attributes=true
1718  ) {
1719  MeshSubElementsStore::copy(rhs, copy_attributes);
1720  is_simplicial_ = rhs.is_simplicial_;
1721  cell_type_ = rhs.cell_type_;
1722  cell_ptr_ = rhs.cell_ptr_;
1723  }
1724 
1725  protected:
1726  bool is_simplicial_;
1727  vector<Numeric::uint8> cell_type_;
1728  vector<index_t> cell_ptr_;
1729 
1730  protected:
1731  friend class Mesh;
1732  friend class GeogramIOHandler;
1733  };
1734 
1735  /*************************************************************************/
1736 
1741  class GEOGRAM_API MeshCellCornersStore : public MeshSubElementsStore {
1742  public:
1743  MeshCellCornersStore(Mesh& mesh);
1744 
1751  geo_assert(c < nb());
1752  return corner_vertex_[c];
1753  }
1754 
1761  geo_debug_assert(c < nb());
1762  geo_debug_assert(v < vertices_.nb());
1763  corner_vertex_[c] = v;
1764  }
1765 
1774  geo_debug_assert(c < nb());
1775  return &(corner_vertex_[c]);
1776  }
1777 
1786  geo_debug_assert(c < nb());
1787  return &(corner_vertex_[c]);
1788  }
1789 
1790  protected:
1792  bool keep_attributes, bool keep_memory = false
1793  ) override;
1794 
1795  void resize_store(index_t new_size) override;
1796 
1797  index_t create_sub_element(index_t v) {
1798  corner_vertex_.push_back(v);
1800  }
1801 
1802  index_t create_sub_elements(index_t nb) {
1803  for(index_t i=0; i<nb; ++i) {
1804  corner_vertex_.push_back(NO_VERTEX);
1805  }
1807  }
1808 
1809  void copy(
1810  const MeshCellCornersStore& rhs, bool copy_attributes=true
1811  ) {
1812  MeshSubElementsStore::copy(rhs, copy_attributes);
1813  corner_vertex_ = rhs.corner_vertex_;
1814  }
1815 
1816  protected:
1817  MeshVertices& vertices_;
1818  vector<index_t> corner_vertex_;
1819 
1820  friend class MeshCells;
1821  friend class Mesh;
1822  friend class GeogramIOHandler;
1823  };
1824 
1825  /*************************************************************************/
1826 
1831  class GEOGRAM_API MeshCellFacetsStore : public MeshSubElementsStore {
1832  public:
1838 
1846  geo_assert(f < nb());
1847  return adjacent_cell_[f];
1848  }
1849 
1858  geo_debug_assert(f < nb());
1859  geo_debug_assert(c == NO_CELL || c < cells_.nb());
1860  adjacent_cell_[f] = c;
1861  }
1862 
1870  geo_assert(f < nb());
1871  return &adjacent_cell_[f];
1872  }
1873 
1881  geo_assert(f < nb());
1882  return &adjacent_cell_[f];
1883  }
1884 
1885  protected:
1887  bool keep_attributes, bool keep_memory = false
1888  ) override;
1889 
1890  void resize_store(index_t new_size) override;
1891 
1892  index_t create_sub_element(index_t c = NO_CELL) {
1893  adjacent_cell_.push_back(c);
1895  }
1896 
1897  index_t create_sub_elements(index_t nb) {
1898  for(index_t i=0; i<nb; ++i) {
1899  adjacent_cell_.push_back(NO_CELL);
1900  }
1902  }
1903 
1904  void copy(
1905  const MeshCellFacetsStore& rhs, bool copy_attributes=true
1906  ) {
1907  MeshSubElementsStore::copy(rhs, copy_attributes);
1908  adjacent_cell_ = rhs.adjacent_cell_;
1909  }
1910 
1911  protected:
1912  MeshVertices& vertices_;
1913  MeshCellsStore& cells_;
1914  vector<index_t> adjacent_cell_;
1915 
1916  friend class MeshCells;
1917  friend class Mesh;
1918  friend class GeogramIOHandler;
1919  };
1920 
1921  /*************************************************************************/
1922 
1927  class GEOGRAM_API MeshCells : public MeshCellsStore, public MeshElements {
1928  public:
1933  MeshCells(Mesh& mesh);
1934 
1941  return nb_corners(c);
1942  }
1943 
1951  return cell_corners_.vertex(corner(c,lv));
1952  }
1953 
1961  cell_corners_.set_vertex(corner(c,lv),v);
1962  }
1963 
1972  return cell_facets_.adjacent_cell(facet(c,lf));
1973  }
1974 
1983  cell_facets_.set_adjacent_cell(facet(c,lf),c2);
1984  }
1985 
1993  geo_debug_assert(lf < nb_facets(c));
1994  return descriptor(c).nb_vertices_in_facet[lf];
1995  }
1996 
2006  geo_debug_assert(lv < facet_nb_vertices(c, lf));
2007  return cell_corners_.vertex(
2008  corner(c, descriptor(c).facet_vertex[lf][lv])
2009  );
2010  }
2020  geo_debug_assert(lc < facet_nb_vertices(c, lf));
2021  return corner(c, descriptor(c).facet_vertex[lf][lc]);
2022  }
2023 
2033  geo_debug_assert(le < nb_edges(c));
2034  geo_debug_assert(lv < 2);
2035  return cell_corners_.vertex(
2036  corner(c,descriptor(c).edge_vertex[le][lv])
2037  );
2038  }
2039 
2051  geo_debug_assert(le < nb_edges(c));
2052  geo_debug_assert(lf < 2);
2053  return descriptor(c).edge_adjacent_facet[le][lf];
2054  }
2055 
2062  geo_debug_assert(c < nb());
2063  return index_range(
2064  index_as_iterator(corners_begin(c)),
2065  index_as_iterator(corners_end(c))
2066  );
2067  }
2068 
2069  void clear(
2070  bool keep_attributes=true, bool keep_memory=false
2071  ) override;
2072 
2074  vector<index_t>& to_delete,
2075  bool remove_isolated_vertices=true
2076  ) override;
2077 
2078  void permute_elements(vector<index_t>& permutation) override;
2079 
2088  index_t create_cells(index_t nb_cells, MeshCellType type) {
2089 
2090  if(nb_cells == 0) {
2091  return NO_CELL;
2092  }
2093 
2094 
2095  if(type != MESH_TET) {
2096  is_not_simplicial();
2097  }
2098 
2099  const CellDescriptor& desc = cell_type_to_cell_descriptor(type);
2100 
2101  // Note: there is padding, the same number of corners and
2102  // faces is created for each cell, so that a single cell
2103  // pointer is used for both.
2104 
2105  index_t cell_size = std::max(desc.nb_vertices, desc.nb_facets);
2106  index_t first_cell = nb();
2107  index_t co = cell_corners_.nb();
2108 
2109  cell_corners_.create_sub_elements(
2110  nb_cells*cell_size
2111  );
2112 
2113  cell_facets_.create_sub_elements(
2114  nb_cells*cell_size
2115  );
2116 
2117  index_t result = create_sub_elements(nb_cells, type);
2118 
2119  if(!is_simplicial_) {
2120  for(index_t c=first_cell; c<=first_cell+nb_cells; ++c) {
2121  cell_ptr_[c] = co;
2122  co += cell_size;
2123  }
2124 
2125  geo_debug_assert(cell_ptr_.size() == nb()+1);
2126  geo_debug_assert(cell_ptr_[nb()] == cell_corners_.nb());
2127  geo_debug_assert(cell_ptr_[nb()] == cell_facets_.nb());
2128  }
2129 
2130  return result;
2131  }
2132 
2139  return create_cells(nb_tets, MESH_TET);
2140  }
2141 
2148  return create_cells(nb_hexes, MESH_HEX);
2149  }
2150 
2157  return create_cells(nb_prisms, MESH_PRISM);
2158  }
2159 
2166  return create_cells(nb_pyramids, MESH_PYRAMID);
2167  }
2168 
2178  index_t v1, index_t v2, index_t v3, index_t v4,
2179  index_t adj1 = NO_CELL,
2180  index_t adj2 = NO_CELL,
2181  index_t adj3 = NO_CELL,
2182  index_t adj4 = NO_CELL
2183  ) {
2184  cell_corners_.create_sub_element(v1);
2185  cell_corners_.create_sub_element(v2);
2186  cell_corners_.create_sub_element(v3);
2187  cell_corners_.create_sub_element(v4);
2188  cell_facets_.create_sub_element(adj1);
2189  cell_facets_.create_sub_element(adj2);
2190  cell_facets_.create_sub_element(adj3);
2191  cell_facets_.create_sub_element(adj4);
2192  index_t result = create_sub_element(MESH_TET);
2193  if(!is_simplicial_) {
2194  cell_ptr_[nb()] = cell_corners_.nb();
2195  }
2196  geo_debug_assert(cell_facets_.nb() == cell_corners_.nb());
2197  return result;
2198  }
2199 
2210  index_t v1, index_t v2, index_t v3, index_t v4,
2211  index_t v5, index_t v6, index_t v7, index_t v8,
2212  index_t adj1 = NO_CELL,
2213  index_t adj2 = NO_CELL,
2214  index_t adj3 = NO_CELL,
2215  index_t adj4 = NO_CELL,
2216  index_t adj5 = NO_CELL,
2217  index_t adj6 = NO_CELL
2218  ) {
2219  is_not_simplicial();
2220  cell_corners_.create_sub_element(v1);
2221  cell_corners_.create_sub_element(v2);
2222  cell_corners_.create_sub_element(v3);
2223  cell_corners_.create_sub_element(v4);
2224  cell_corners_.create_sub_element(v5);
2225  cell_corners_.create_sub_element(v6);
2226  cell_corners_.create_sub_element(v7);
2227  cell_corners_.create_sub_element(v8);
2228  cell_facets_.create_sub_element(adj1);
2229  cell_facets_.create_sub_element(adj2);
2230  cell_facets_.create_sub_element(adj3);
2231  cell_facets_.create_sub_element(adj4);
2232  cell_facets_.create_sub_element(adj5);
2233  cell_facets_.create_sub_element(adj6);
2234  cell_facets_.create_sub_element(NO_CELL); // padding
2235  cell_facets_.create_sub_element(NO_CELL); // padding
2236  index_t result = create_sub_element(MESH_HEX);
2237  cell_ptr_[nb()] = cell_corners_.nb();
2238  geo_debug_assert(cell_facets_.nb() == cell_corners_.nb());
2239  return result;
2240  }
2241 
2252  index_t v1, index_t v2,
2253  index_t v3, index_t v4,
2254  index_t v5, index_t v6,
2255  index_t adj1 = NO_CELL,
2256  index_t adj2 = NO_CELL,
2257  index_t adj3 = NO_CELL,
2258  index_t adj4 = NO_CELL,
2259  index_t adj5 = NO_CELL
2260  ) {
2261  is_not_simplicial();
2262  cell_corners_.create_sub_element(v1);
2263  cell_corners_.create_sub_element(v2);
2264  cell_corners_.create_sub_element(v3);
2265  cell_corners_.create_sub_element(v4);
2266  cell_corners_.create_sub_element(v5);
2267  cell_corners_.create_sub_element(v6);
2268  cell_facets_.create_sub_element(adj1);
2269  cell_facets_.create_sub_element(adj2);
2270  cell_facets_.create_sub_element(adj3);
2271  cell_facets_.create_sub_element(adj4);
2272  cell_facets_.create_sub_element(adj5);
2273  cell_facets_.create_sub_element(NO_CELL); // padding
2274  index_t result = create_sub_element(MESH_PRISM);
2275  cell_ptr_[nb()] = cell_corners_.nb();
2276  geo_debug_assert(cell_facets_.nb() == cell_corners_.nb());
2277  return result;
2278  }
2279 
2290  index_t v1, index_t v2, index_t v3, index_t v4, index_t v5,
2291  index_t adj1 = NO_CELL,
2292  index_t adj2 = NO_CELL,
2293  index_t adj3 = NO_CELL,
2294  index_t adj4 = NO_CELL,
2295  index_t adj5 = NO_CELL
2296  ) {
2297  is_not_simplicial();
2298  cell_corners_.create_sub_element(v1);
2299  cell_corners_.create_sub_element(v2);
2300  cell_corners_.create_sub_element(v3);
2301  cell_corners_.create_sub_element(v4);
2302  cell_corners_.create_sub_element(v5);
2303  cell_facets_.create_sub_element(adj1);
2304  cell_facets_.create_sub_element(adj2);
2305  cell_facets_.create_sub_element(adj3);
2306  cell_facets_.create_sub_element(adj4);
2307  cell_facets_.create_sub_element(adj5);
2308  index_t result = create_sub_element(MESH_PYRAMID);
2309  cell_ptr_[nb()] = cell_corners_.nb();
2310  geo_debug_assert(cell_facets_.nb() == cell_corners_.nb());
2311  return result;
2312  }
2313 
2327  index_t v1, index_t v2, index_t v3, index_t v4,
2328  index_t adj1 = NO_CELL,
2329  index_t adj2 = NO_CELL,
2330  index_t adj3 = NO_CELL
2331  ) {
2332  is_not_simplicial();
2333  cell_corners_.create_sub_element(v1);
2334  cell_corners_.create_sub_element(v2);
2335  cell_corners_.create_sub_element(v3);
2336  cell_corners_.create_sub_element(v4);
2337  cell_facets_.create_sub_element(adj1);
2338  cell_facets_.create_sub_element(adj2);
2339  cell_facets_.create_sub_element(adj3);
2340  cell_facets_.create_sub_element(NO_CELL); // padding
2341  index_t result = create_sub_element(MESH_CONNECTOR);
2342  cell_ptr_[nb()] = cell_corners_.nb();
2343  geo_debug_assert(cell_facets_.nb() == cell_corners_.nb());
2344  return result;
2345  }
2346 
2357  void connect(
2358  bool remove_trivial_slivers = true, bool verbose_if_OK=false
2359  );
2360 
2366 
2375 
2387  coord_index_t dim,
2388  vector<double>& vertices,
2389  vector<index_t>& tets,
2390  bool steal_args
2391  );
2392 
2402  vector<index_t>& tets,
2403  bool steal_args
2404  );
2405 
2406  void pop() override;
2407 
2408  index_t tet_adjacent(index_t t, index_t lf) const {
2409  geo_debug_assert(is_simplicial_);
2410  geo_debug_assert(t < nb());
2411  geo_debug_assert(lf < 4);
2412  return cell_facets_.adjacent_cell_[4*t+lf];
2413  }
2414 
2415  index_t find_tet_adjacent(index_t t, index_t t2) const {
2416  geo_debug_assert(is_simplicial_);
2417  geo_debug_assert(t < nb());
2418  geo_debug_assert(t2 < nb());
2419  for(index_t lf=0; lf<4; ++lf) {
2420  if(cell_facets_.adjacent_cell_[4*t+lf] == t2) {
2421  return lf;
2422  }
2423  }
2424  return NO_FACET;
2425  }
2426 
2427  index_t tet_vertex(index_t t, index_t lv) const {
2428  geo_debug_assert(is_simplicial_);
2429  geo_debug_assert(t < nb());
2430  geo_debug_assert(lv < 4);
2431  return cell_corners_.corner_vertex_[4*t+lv];
2432  }
2433 
2434  index_t find_tet_vertex(index_t t, index_t v) const {
2435  geo_debug_assert(is_simplicial_);
2436  geo_debug_assert(t < nb());
2437  geo_debug_assert(v < vertices_.nb());
2438  for(index_t lv=0; lv<4; ++lv) {
2439  if(cell_corners_.corner_vertex_[4*t+lv] == v) {
2440  return lv;
2441  }
2442  }
2443  return NO_VERTEX;
2444  }
2445 
2457  index_t t, index_t lf, index_t lv
2458  ) const {
2459  geo_debug_assert(is_simplicial_);
2460  geo_debug_assert(t < nb());
2461  geo_debug_assert(lf < 4);
2462  geo_debug_assert(lv < 3);
2463  return cell_corners_.vertex(
2464  4 * t + local_tet_facet_vertex_index(lf,lv)
2465  );
2466  }
2467 
2482  index_t t, index_t v1, index_t v2, index_t v3
2483  ) const {
2484  geo_debug_assert(is_simplicial_);
2485  for(index_t lf = 0; lf < 4; ++lf) {
2486  index_t w1 = tet_facet_vertex(t, lf, 0);
2487  index_t w2 = tet_facet_vertex(t, lf, 1);
2488  index_t w3 = tet_facet_vertex(t, lf, 2);
2489  if(
2490  (v1 == w1 && v2 == w2 && v3 == w3) ||
2491  (v1 == w2 && v2 == w3 && v3 == w1) ||
2492  (v1 == w3 && v2 == w1 && v3 == w2)
2493  ) {
2494  return lf;
2495  }
2496  }
2497  return NO_FACET;
2498  }
2499 
2509  geo_debug_assert(lf < 4);
2510  geo_debug_assert(lv < 3);
2511  return MeshCellDescriptors::tet_descriptor.facet_vertex[lf][lv];
2512  }
2513 
2514  protected:
2515 
2523  if(is_simplicial_) {
2524  is_simplicial_ = false;
2525  cell_ptr_.resize(nb()+1);
2526  cell_type_.assign(nb(), MESH_TET);
2527  for(index_t c=0; c<cell_ptr_.size(); ++c) {
2528  cell_ptr_[c] = 4*c;
2529  }
2530  }
2531  }
2532 
2545  index_t c1, index_t f1, index_t c2, index_t f2
2546  ) const;
2547 
2557  geo_debug_assert(c < nb());
2558  geo_debug_assert(v < vertices_.nb());
2559  for(index_t lv=0; lv<nb_vertices(c); ++lv) {
2560  if(vertex(c,lv) == v) {
2561  return lv;
2562  }
2563  }
2564  return NO_VERTEX;
2565  }
2566 
2579  index_t c1, index_t c2, index_t f2
2580  ) const {
2581  for(index_t f1=0; f1<nb_facets(c1); ++f1) {
2582  if(facets_match(c1,f1,c2,f2)) {
2583  return f1;
2584  }
2585  }
2586  return NO_FACET;
2587  }
2588 
2602  index_t c1, index_t lf1,
2603  index_t c2, index_t lf2
2604  ) const;
2605 
2606 
2621  index_t c1, index_t f1,
2622  index_t c2, index_t f2,
2623  index_t& e1, index_t& e2
2624  ) const;
2625 
2645  index_t c1, index_t lf1,
2646  const std::vector< std::pair<index_t, index_t> >& matches
2647  );
2648 
2654 
2655  protected:
2656  MeshVertices& vertices_;
2657  MeshCellCornersStore& cell_corners_;
2658  MeshCellFacetsStore& cell_facets_;
2659  friend class Mesh;
2660  friend class GeogramIOHandler;
2661  };
2662 
2663  /*************************************************************************/
2664 
2673  MESH_NONE = 0,
2674  MESH_VERTICES = 1,
2675  MESH_FACETS = 2,
2676  MESH_EDGES = 4,
2677  MESH_CELLS = 8,
2678  MESH_ALL_ELEMENTS = 15,
2679  MESH_FACET_CORNERS = 16,
2680  MESH_CELL_CORNERS = 32,
2681  MESH_CELL_FACETS = 64,
2682  MESH_ALL_SUBELEMENTS = 65
2683  };
2684 
2685  /*************************************************************************/
2686 
2693  class GEOGRAM_API Mesh {
2694  public:
2695  MeshVertices vertices;
2696  MeshEdges edges;
2697  MeshFacets facets;
2698  MeshFacetCornersStore facet_corners;
2699  MeshCells cells;
2700  MeshCellCornersStore cell_corners;
2701  MeshCellFacetsStore cell_facets;
2702 
2710  Mesh(index_t dimension=3, bool single_precision=false);
2711 
2715  virtual ~Mesh();
2716 
2727  void clear(bool keep_attributes=true, bool keep_memory=false);
2728 
2732  void show_stats(const std::string& tag = "Mesh") const;
2733 
2734 
2743 
2744 
2755  void copy(
2756  const Mesh& rhs,
2757  bool copy_attributes=true,
2758  MeshElementsFlags what=MESH_ALL_ELEMENTS
2759  );
2760 
2761 
2766  std::string get_attributes() const;
2767 
2774  std::string get_scalar_attributes() const;
2775 
2782  std::string get_vector_attributes(index_t max_dim = 0) const;
2783 
2789 
2797 
2805 
2806 
2814 
2822  MeshElementsFlags what
2823  ) const;
2824 
2832 
2841  const std::string& name
2842  );
2843 
2859  const std::string& full_attribute_name,
2860  MeshElementsFlags& where,
2861  std::string& attribute_name,
2862  index_t& component
2863  );
2864 
2865  protected:
2874  const std::string& tag, const std::string& subelement_name,
2875  const MeshSubElementsStore& subelements
2876  ) const;
2877 
2878  private:
2886  Mesh(const Mesh& rhs);
2887 
2895  const Mesh& operator=(const Mesh& rhs);
2896  };
2897 
2898  /*************************************************************************/
2899 }
2900 
2901 #endif
#define geo_assert(x)
Verifies that a condition is met.
Definition: assert.h:149
#define geo_debug_assert(x)
Verifies that a condition is met.
Definition: assert.h:195
Generic mechanism for attributes.
Managers a set of attributes attached to an object.
Definition: attributes.h:833
index_t size() const
Gets the size.
Definition: attributes.h:868
Stores the cell corners of a mesh (low-level store)
Definition: mesh.h:1741
const index_t * vertex_index_ptr(index_t c) const
Gets a pointer to the vertex that a corner is incident to.
Definition: mesh.h:1785
void set_vertex(index_t c, index_t v)
Sets the vertex that a corner is incident to.
Definition: mesh.h:1760
index_t vertex(index_t c) const
Gets the vertex that a corner is incident to.
Definition: mesh.h:1750
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
index_t * vertex_index_ptr(index_t c)
Gets a pointer to the vertex that a corner is incident to.
Definition: mesh.h:1773
Stores the cell facets of a mesh (low-level store)
Definition: mesh.h:1831
index_t adjacent_cell(index_t f) const
Gets a cell adjacent to a facet.
Definition: mesh.h:1845
const index_t * adjacent_cell_ptr(index_t f) const
Gets a const pointer to a cell adjacent to a facet.
Definition: mesh.h:1869
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
index_t * adjacent_cell_ptr(index_t f)
Gets a pointer to a cell adjacent to a facet.
Definition: mesh.h:1880
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
MeshCellFacetsStore(Mesh &mesh)
MeshCellFacetsStore constructor.
void set_adjacent_cell(index_t f, index_t c)
Sets a cell adjacent to a facet.
Definition: mesh.h:1857
Stores the cells of a mesh (low-level store)
Definition: mesh.h:1530
index_t facet(index_t c, index_t lf) const
Gets a facet of a cell by local facet index.
Definition: mesh.h:1676
bool are_simplices() const
Tests whether all the cells are tetrahedra.
Definition: mesh.h:1541
index_t corner(index_t c, index_t lv) const
Gets a corner of a cell by local vertex index.
Definition: mesh.h:1628
index_t nb_facets(index_t c) const
Gets the number of facets of a cell.
Definition: mesh.h:1643
index_t corners_end(index_t c) const
Gets the upper limit for iterating over the corners of a cell.
Definition: mesh.h:1617
MeshCellType type(index_t c) const
Gets the type of a cell.
Definition: mesh.h:1551
index_t facets_end(index_t c) const
Gets the upper limit for iterating over the facets of a cell.
Definition: mesh.h:1665
const CellDescriptor & descriptor(index_t c) const
Gets the descriptor of a cell.
Definition: mesh.h:1564
index_t nb_corners(index_t c) const
Gets the number of corners of a cell.
Definition: mesh.h:1595
index_t corners_begin(index_t c) const
Gets the first element for iterating over the corners of a cell.
Definition: mesh.h:1606
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
index_t nb_edges(index_t c) const
Gets the number of edges in a cell.
Definition: mesh.h:1687
static const CellDescriptor & cell_type_to_cell_descriptor(MeshCellType t)
Gets a descriptor by cell type.
Definition: mesh.h:1583
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
index_t facets_begin(index_t c) const
Gets the first element for iterating over the facets of a cell.
Definition: mesh.h:1654
The cells of a mesh.
Definition: mesh.h:1927
index_t create_cells(index_t nb_cells, MeshCellType type)
Creates a contiguous chunk of cells of the same type.
Definition: mesh.h:2088
void pop() override
Removes the last element.
void compute_borders()
Replaces the surfacic part of this mesh with the borders of the volumetric part.
void set_vertex(index_t c, index_t lv, index_t v)
Sets a vertex of a cell by local vertex index.
Definition: mesh.h:1960
index_t create_pyramids(index_t nb_pyramids)
Creates a contiguous chunk of pyramids.
Definition: mesh.h:2165
void assign_tet_mesh(vector< index_t > &tets, bool steal_args)
Copies a tetrahedron mesh into this Mesh.
index_t adjacent(index_t c, index_t lf) const
Gets a cell adjacent to another one by local facet index.
Definition: mesh.h:1971
void assign_tet_mesh(coord_index_t dim, vector< double > &vertices, vector< index_t > &tets, bool steal_args)
Copies a tetrahedron mesh into this Mesh.
bool triangular_facets_have_common_edge(index_t c1, index_t f1, index_t c2, index_t f2, index_t &e1, index_t &e2) const
Tests whether two triangular cell facets have a common edge.
bool facets_match(index_t c1, index_t f1, index_t c2, index_t f2) const
Tests whether two cell facets can be connected.
index_t create_connector(index_t v1, index_t v2, index_t v3, index_t v4, index_t adj1=NO_CELL, index_t adj2=NO_CELL, index_t adj3=NO_CELL)
Creates a connector.
Definition: mesh.h:2326
index_t tet_facet_vertex(index_t t, index_t lf, index_t lv) const
Gets a vertex of a tetrahedron by local facet index and local vertex index in facet.
Definition: mesh.h:2456
index_range corners(index_t c) const
Gets the corners of a cell.
Definition: mesh.h:2061
MeshCells(Mesh &mesh)
MeshCells constructor.
index_t edge_vertex(index_t c, index_t le, index_t lv) const
Gets a cell vertex by local edge index and local vertex index in the edge.
Definition: mesh.h:2032
void connect(bool remove_trivial_slivers=true, bool verbose_if_OK=false)
Connects the cells.
static index_t local_tet_facet_vertex_index(index_t lf, index_t lv)
Gives the local index of a vertex in a tetrahedron from its facet and vertex local indices.
Definition: mesh.h:2508
index_t create_prism(index_t v1, index_t v2, index_t v3, index_t v4, index_t v5, index_t v6, index_t adj1=NO_CELL, index_t adj2=NO_CELL, index_t adj3=NO_CELL, index_t adj4=NO_CELL, index_t adj5=NO_CELL)
Creates a prism.
Definition: mesh.h:2251
index_t nb_vertices(index_t c) const
Gets the number of vertices of a cell.
Definition: mesh.h:1940
index_t facet_vertex(index_t c, index_t lf, index_t lv) const
Gets a vertex of a cell by local facet index and local vertex index in the facet.
Definition: mesh.h:2005
void delete_elements(vector< index_t > &to_delete, bool remove_isolated_vertices=true) override
Deletes a set of elements.
index_t create_pyramid(index_t v1, index_t v2, index_t v3, index_t v4, index_t v5, index_t adj1=NO_CELL, index_t adj2=NO_CELL, index_t adj3=NO_CELL, index_t adj4=NO_CELL, index_t adj5=NO_CELL)
Creates a pyramid.
Definition: mesh.h:2289
index_t find_tet_facet(index_t t, index_t v1, index_t v2, index_t v3) const
Finds the local index of a facet in a tetrahedron by the global indices of its vertices.
Definition: mesh.h:2481
void permute_elements(vector< index_t > &permutation) override
Applies a permutation to the elements and their attributes.
void is_not_simplicial()
Indicates that the stored elements are no longer only tetrahedra.
Definition: mesh.h:2522
index_t facet_corner(index_t c, index_t lf, index_t lc) const
Gets a corner of a cell by local facet index and local corner index in the facet.
Definition: mesh.h:2019
index_t find_cell_vertex(index_t c, index_t v) const
Finds the local index of a vertex in a cell.
Definition: mesh.h:2556
index_t create_hexes(index_t nb_hexes)
Creates a contiguous chunk of hexahedra.
Definition: mesh.h:2147
index_t create_tets(index_t nb_tets)
Creates a contiguous chunk of tetrahedra.
Definition: mesh.h:2138
index_t edge_adjacent_facet(index_t c, index_t le, index_t lf) const
Gets a cell local facet index by local edge index and local facet index in the edge.
Definition: mesh.h:2050
void compute_borders(Attribute< index_t > &facet_cell)
Replaces the surfacic part of this mesh with the borders of the volumetric part.
bool create_connector(index_t c1, index_t lf1, const std::vector< std::pair< index_t, index_t > > &matches)
Creates a connector between a quadrandular facet and two triangular facets.
void set_adjacent(index_t c, index_t lf, index_t c2)
Sets a cell adjacent to another one by local facet index.
Definition: mesh.h:1982
void clear(bool keep_attributes=true, bool keep_memory=false) override
Removes all the elements and attributes.
index_t create_prisms(index_t nb_prisms)
Creates a contiguous chunk of prisms.
Definition: mesh.h:2156
index_t create_tet(index_t v1, index_t v2, index_t v3, index_t v4, index_t adj1=NO_CELL, index_t adj2=NO_CELL, index_t adj3=NO_CELL, index_t adj4=NO_CELL)
Creates a tetrahedron.
Definition: mesh.h:2177
index_t create_hex(index_t v1, index_t v2, index_t v3, index_t v4, index_t v5, index_t v6, index_t v7, index_t v8, index_t adj1=NO_CELL, index_t adj2=NO_CELL, index_t adj3=NO_CELL, index_t adj4=NO_CELL, index_t adj5=NO_CELL, index_t adj6=NO_CELL)
Creates an hexahedron.
Definition: mesh.h:2209
void connect_tets()
Optimized implementation of connect() used when the mesh is simplicial.
index_t facet_nb_vertices(index_t c, index_t lf) const
Gets the number of vertices in a cell facet.
Definition: mesh.h:1992
bool triangular_facet_matches_quad_facet(index_t c1, index_t lf1, index_t c2, index_t lf2) const
Tests whether a triangular facet matches a quad facet.
index_t find_cell_facet(index_t c1, index_t c2, index_t f2) const
Finds the local index of a facet in a cell that can be connected to a facet of another cell.
Definition: mesh.h:2578
index_t vertex(index_t c, index_t lv) const
Gets a vertex of a cell by local vertex index.
Definition: mesh.h:1950
The edges of a mesh.
Definition: mesh.h:626
index_t vertex(index_t e, index_t lv) const
Gets the index of an edge vertex.
Definition: mesh.h:637
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
void pop() override
Removes the last element.
void clear(bool keep_attributes=true, bool keep_memory=false) override
Removes all the elements and attributes.
index_t create_edge(index_t v1, index_t v2)
Creates a new edge.
Definition: mesh.h:700
index_t create_edge()
Creates a new edge.
Definition: mesh.h:682
void permute_elements(vector< index_t > &permutation) override
Applies a permutation to the elements and their attributes.
index_t * vertex_index_ptr(index_t c)
Gets a pointer to a vertex index by corner index.
Definition: mesh.h:662
const index_t * vertex_index_ptr(index_t c) const
Gets a pointer to a vertex index by corner index.
Definition: mesh.h:673
index_t create_edges(index_t nb)
Creates a batch of edges.
Definition: mesh.h:691
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
void delete_elements(vector< index_t > &to_delete, bool remove_isolated_vertices=true) override
Deletes a set of elements.
void set_vertex(index_t e, index_t lv, index_t v)
Sets a vertex of an edge.
Definition: mesh.h:649
Base class for mesh elements.
Definition: mesh.h:243
virtual void delete_elements(vector< index_t > &to_delete, bool remove_isolated_vertices=true)=0
Deletes a set of elements.
static bool has_non_zero(const GEO::vector< index_t > &I)
Tests whether a vector contains a non-zero value.
Definition: mesh.h:302
virtual void clear(bool keep_attributes=true, bool keep_memory=false)=0
Removes all the elements and attributes.
virtual void pop()=0
Removes the last element.
virtual void permute_elements(vector< index_t > &permutation)=0
Applies a permutation to the elements and their attributes.
Stores the facet corners of a mesh (low-level store)
Definition: mesh.h:867
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
index_t adjacent_facet(index_t c) const
Gets the facet that a corner is adjacent to.
Definition: mesh.h:887
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
void set_vertex_no_check(index_t c, index_t v)
Sets the vertex that a corner is incident to.
Definition: mesh.h:939
index_t vertex(index_t c) const
Gets the vertex that a corner is incident to.
Definition: mesh.h:876
void set_adjacent_facet(index_t c, index_t f)
Sets the facet that a corner is adjacent to.
Definition: mesh.h:950
const index_t * adjacent_facet_ptr(index_t c) const
Gets a pointer to the the facet index that a corner is adjacent to.
Definition: mesh.h:899
index_t * vertex_index_ptr(index_t c)
Gets a pointer to the vertex that a corner is incident to.
Definition: mesh.h:963
index_t * adjacent_facet_ptr(index_t c)
Gets a pointer to the the facet index that a corner is adjacent to.
Definition: mesh.h:912
const index_t * vertex_index_ptr(index_t c) const
Gets a pointer to the vertex that a corner is incident to.
Definition: mesh.h:975
void set_vertex(index_t c, index_t v)
Sets the vertex that a corner is incident to.
Definition: mesh.h:923
Stores the facets of a mesh (low-level store)
Definition: mesh.h:753
index_t corner(index_t f, index_t lv) const
Gets a corner by facet and local vertex index.
Definition: mesh.h:796
index_t corners_end(index_t f) const
Gets the upper limit for iterating over the corners of a facet.
Definition: mesh.h:774
index_t nb_corners(index_t f) const
Gets the number of corners in a facet.
Definition: mesh.h:784
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
bool are_simplices() const
Tests whether all the facets are triangles.
Definition: mesh.h:809
const index_t * corners_begin_ptr(index_t f) const
Gets a pointer to the first element for iterating over the corners of a facet.
Definition: mesh.h:819
index_t corners_begin(index_t f) const
Gets the first element for iterating over the corners of a facet.
Definition: mesh.h:763
The facets of a mesh.
Definition: mesh.h:1028
index_t create_triangle(index_t v1, index_t v2, index_t v3)
Creates a triangle.
Definition: mesh.h:1261
void compute_borders()
Replaces the edges of this mesh with the borders of the surfacic part.
void clear(bool keep_attributes=true, bool keep_memory=false) override
Removes all the elements and attributes.
index_t create_quad(index_t v1, index_t v2, index_t v3, index_t v4)
Creates a quad.
Definition: mesh.h:1282
index_t create_polygon(const vector< index_t > &vertices)
Creates a polygonal facet.
Definition: mesh.h:1344
void is_not_simplicial()
Indicates that the stored elements are no longer only triangles.
Definition: mesh.h:1439
void triangulate()
Triangulates the facets.
MeshFacets(Mesh &mesh)
MeshFacets constructor.
index_t vertex(index_t f, index_t lv) const
Gets a vertex by facet and local vertex index.
Definition: mesh.h:1054
index_t find_edge(index_t f, index_t v1, index_t v2)
Finds an edge by vertex indices.
Definition: mesh.h:1172
void reserve(index_t nb_to_reserve)
Reserves space for new facets.
Definition: mesh.h:1233
void permute_elements(vector< index_t > &permutation) override
Applies a permutation to the elements and their attributes.
index_t nb_vertices(index_t f) const
Gets the number of vertices of a facet.
Definition: mesh.h:1043
void is_simplicial()
Indicates that the stored elements are only triangles.
Definition: mesh.h:1425
void delete_elements(vector< index_t > &to_delete, bool remove_isolated_vertices=true) override
Deletes a set of elements.
void connect()
Connects the facets.
void flip(index_t f)
Flips a facet.
index_t create_polygon(index_t nb_vertices)
Creates a polygonal facet.
Definition: mesh.h:1300
index_t create_polygon(index_t nb_vertices, const index_t *vertices)
Creates a polygonal facet.
Definition: mesh.h:1322
void set_vertex(index_t f, index_t lv, index_t v)
Sets a vertex by facet and local vertex index.
Definition: mesh.h:1065
index_t find_common_vertex(index_t f1, index_t f2) const
finds a common vertex shared by two facets
Definition: mesh.h:1091
index_range corners(index_t f) const
Gets the corners of a facet.
Definition: mesh.h:1412
void pop() override
Removes the last element.
index_t find_vertex(index_t f, index_t v) const
Gets the local index of a vertex in a facet.
Definition: mesh.h:1076
index_t find_adjacent(index_t f, index_t f2) const
Gets the local index of a facet adjacent to another one.
Definition: mesh.h:1119
index_t prev_corner_around_facet(index_t f, index_t c) const
Gets the predecessor of a corner around a facet.
Definition: mesh.h:1159
void assign_triangle_mesh(coord_index_t dim, vector< double > &vertices, vector< index_t > &triangles, bool steal_args)
Copies a triangle mesh into this Mesh.
index_t create_quads(index_t nb_quads)
Creates a contiguous chunk of quads.
Definition: mesh.h:1252
index_t create_facets(index_t nb_facets, index_t nb_vertices_per_polygon)
Creates a contiguous chunk of facets.
Definition: mesh.h:1203
index_t adjacent(index_t f, index_t le) const
Gets an adjacent facet by facet and local edge index.
Definition: mesh.h:1108
void set_adjacent(index_t f, index_t le, index_t f2)
Sets an adjacent facet by facet and local edge index.
Definition: mesh.h:1135
index_t create_triangles(index_t nb_triangles)
Creates a contiguous chunk of triangles.
Definition: mesh.h:1243
index_t next_corner_around_facet(index_t f, index_t c) const
Gets the successor of a corner around a facet.
Definition: mesh.h:1146
Base class for mesh sub-element storage.
Definition: mesh.h:70
index_as_iterator begin() const
Used by range-based for.
Definition: mesh.h:108
virtual ~MeshSubElementsStore()
MeshElementStore destructor.
MeshSubElementsStore(Mesh &mesh)
Constructs a new MeshSubElementStore.
index_t create_sub_element()
Creates attributes for a sub-element.
Definition: mesh.h:180
virtual void clear_store(bool keep_attributes, bool keep_memory=false)
Removes all the elements and attributes.
index_t create_sub_elements(index_t nb)
Creates a contiguous chunk of attributes for sub-elements.
Definition: mesh.h:159
index_t nb() const
Gets the number of (sub-)elements.
Definition: mesh.h:89
void reserve_store(index_t nb_to_reserve)
Reserves space for new elements.
Definition: mesh.h:148
index_as_iterator end() const
Used by range-based for.
Definition: mesh.h:116
void copy(const MeshSubElementsStore &rhs, bool copy_attributes=true)
Copies a MeshSubElementsStore into this one.
Definition: mesh.h:214
void adjust_store()
Makes the size of the store tightly match the number of the elements.
Definition: mesh.h:201
AttributesManager & attributes() const
Gets the attributes manager.
Definition: mesh.h:100
virtual void resize_store(index_t new_size)
Resizes this MeshSubElementsStore.
The vertices of a mesh.
Definition: mesh.h:323
void pop() override
Removes the last element.
void resize_store(index_t new_size) override
Resizes this MeshSubElementsStore.
const double * point_ptr(index_t v) const
Gets a point.
Definition: mesh.h:455
void clear(bool keep_attributes=true, bool keep_memory=false) override
Removes all the elements and attributes.
float * single_precision_point_ptr(index_t v)
Gets a (single-precision) point.
Definition: mesh.h:523
index_t create_vertex(const double *coords)
Creates a new vertex.
Definition: mesh.h:353
void assign_points(const double *points, index_t dim, index_t nb_pts)
Assigns all the points.
const vec3 & point(index_t v) const
Gets a point.
Definition: mesh.h:496
void remove_isolated()
Removes the vertices that have no mesh element incident to them.
void set_dimension(index_t dim)
Sets the dimension of the vertices.
Definition: mesh.h:440
void set_double_precision()
Sets double precision mode.
void clear_store(bool keep_attributes, bool keep_memory=false) override
Removes all the elements and attributes.
const float * single_precision_point_ptr(index_t v) const
Gets a (single-precision) point.
Definition: mesh.h:510
void permute_elements(vector< index_t > &permutation) override
Applies a permutation to the elements and their attributes.
void assign_points(vector< double > &points, index_t dim, bool steal_arg)
Assigns all the points.
bool double_precision() const
Tests whether vertices are stored in double-precision mode.
Definition: mesh.h:419
bool single_precision() const
Tests whether vertices are stored in single-precision mode.
Definition: mesh.h:408
index_t dimension() const
Gets the dimension of the vertices.
Definition: mesh.h:427
index_t create_vertices(index_t nb)
Creates a contiguous chunk of vertices.
Definition: mesh.h:375
double * point_ptr(index_t v)
Gets a point.
Definition: mesh.h:468
void set_single_precision()
Sets single precision mode.
vec3 & point(index_t v)
Gets a point.
Definition: mesh.h:482
index_t create_vertex()
Creates a new vertex.
Definition: mesh.h:344
void delete_elements(vector< index_t > &to_delete, bool remove_isolated_vertices=true) override
Deletes a set of elements.
Represents a mesh.
Definition: mesh.h:2693
const MeshSubElementsStore & get_subelements_by_index(index_t i) const
Gets a MeshSubElementsStore by index.
Mesh(index_t dimension=3, bool single_precision=false)
Mesh constructor.
void copy(const Mesh &rhs, bool copy_attributes=true, MeshElementsFlags what=MESH_ALL_ELEMENTS)
Copies a mesh onto this one.
MeshElementsFlags
Indicates the mesh elements (vertices, facets or cells) present in a mesh.
Definition: mesh.h:2672
index_t nb_subelements_types() const
Gets the number of subelements types.
void assert_is_valid()
Does some validity checks.
MeshSubElementsStore & get_subelements_by_type(MeshElementsFlags what)
Gets a MeshSubElementsStore by subelements type.
static std::string subelements_type_to_name(MeshElementsFlags what)
Gets a subelement name by subelement type.
void clear(bool keep_attributes=true, bool keep_memory=false)
Removes all the elements and attributes of this mesh.
virtual ~Mesh()
Mesh destructor.
std::string get_attributes() const
Gets the list of all attributes.
static bool parse_attribute_name(const std::string &full_attribute_name, MeshElementsFlags &where, std::string &attribute_name, index_t &component)
Extracts localisation, name and optional component from an attribute name.
void display_attributes(const std::string &tag, const std::string &subelement_name, const MeshSubElementsStore &subelements) const
Displays the list of attributes to the Logger.
MeshSubElementsStore & get_subelements_by_index(index_t i)
Gets a MeshSubElementsStore by index.
const MeshSubElementsStore & get_subelements_by_type(MeshElementsFlags what) const
Gets a MeshSubElementsStore by subelements type.
std::string get_vector_attributes(index_t max_dim=0) const
Gets the list of all vector attributes.
std::string get_scalar_attributes() const
Gets the list of all scalar attributes.
static MeshElementsFlags name_to_subelements_type(const std::string &name)
Gets a subelement type by subelement name.
void show_stats(const std::string &tag="Mesh") const
Displays number of vertices, facets and borders.
Wraps an integer to be used with the range-based for construct.
Definition: range.h:66
A generic index_range bounded by two "non-iterators".
Definition: range.h:106
T * data()
Gets a pointer to the array of elements.
Definition: memory.h:774
index_t size() const
Gets the number of elements.
Definition: memory.h:674
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
void copy(void *to, const void *from, size_t size)
Copies a memory block.
Definition: memory.h:129
CellDescriptor * cell_type_to_cell_descriptor[GEO::MESH_NB_CELL_TYPES]
Maps a cell type to the associated cell descriptor.
uint8_t uint8
Definition: numeric.h:135
Global Vorpaline namespace.
Definition: basic.h:55
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
void tessellate_facets(Mesh &M, index_t max_nb_vertices)
Subdivides the facets with more than nb_vertices.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Definition: numeric.h:363
C++-20 like helpers for manipulating ranges of integers.
Lookup tables that describe the combinatorics of each cell type.
Definition: mesh.h:1475
index_t nb_vertices_in_facet[6]
Definition: mesh.h:1483
index_t facet_vertex[6][4]
Definition: mesh.h:1488
index_t nb_vertices
Definition: mesh.h:1477
index_t nb_facets
Definition: mesh.h:1480
index_t edge_adjacent_facet[12][2]
Definition: mesh.h:1502
index_t nb_edges
Definition: mesh.h:1492
index_t edge_vertex[12][2]
Definition: mesh.h:1497