Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
mesh_gfx.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_GFX_MESH_GFX
41 #define GEOGRAM_GFX_MESH_GFX
42 
44 #include <geogram_gfx/GLUP/GLUP.h>
46 #include <geogram/mesh/mesh.h>
47 
53 namespace GEO {
54 
55  class MeshGfxImpl;
56 
61  public:
62 
67 
72 
76  MeshGfx(const MeshGfx& rhs) = delete;
77 
81  MeshGfx& operator=(const MeshGfx& rhs) = delete;
82 
89  void draw_vertices();
90 
94  void draw_edges();
95 
99  void draw_surface();
100 
106 
110  void draw_volume();
111 
120  bool get_show_mesh() const {
121  return show_mesh_;
122  }
123 
131  void set_show_mesh(bool x) {
132  show_mesh_ = x;
133  }
134 
144  return mesh_width_;
145  }
146 
156  mesh_width_ = x;
157  }
158 
166  return mesh_border_width_;
167  }
168 
176  mesh_border_width_ = x;
177  }
178 
187  double get_shrink() const {
188  return shrink_;
189  }
190 
199  void set_shrink(double x) {
200  shrink_ = x;
201  if(shrink_ < 0.0) {
202  shrink_ = 0.0;
203  } else if(shrink_ > 1.0) {
204  shrink_ = 1.0;
205  }
206  }
207 
208 
220  bool get_animate() const {
221  return animate_;
222  }
223 
234  void set_animate(bool x) {
235  animate_ = x;
236  }
237 
245  double get_time() const {
246  return time_;
247  }
248 
256  void set_time(double x) {
257  time_ = x;
258  if(time_ < 0.0) {
259  time_ = 0.0;
260  } else if(time_ > 1.0) {
261  time_ = 1.0;
262  }
263  }
264 
273  bool get_draw_cells(MeshCellType type) const {
274  return draw_cells_[type];
275  }
276 
277 
286  void set_draw_cells(MeshCellType type, bool x) {
287  draw_cells_[type] = x;
288  }
289 
297  void set_points_color(float r, float g, float b, float a=1.0f) {
298  points_color_[0] = r;
299  points_color_[1] = g;
300  points_color_[2] = b;
301  points_color_[3] = a;
302  }
303 
310  void get_points_color(float& r, float& g, float& b, float& a) const {
311  r = points_color_[0];
312  g = points_color_[1];
313  b = points_color_[2];
314  a = points_color_[3];
315  }
316 
322  void set_points_size(float x) {
323  points_size_ = x;
324  }
325 
331  float get_points_size() const {
332  return points_size_;
333  }
334 
343  void set_mesh_color(float r, float g, float b, float a=1.0f) {
344  mesh_color_[0] = r;
345  mesh_color_[1] = g;
346  mesh_color_[2] = b;
347  mesh_color_[3] = a;
348  }
349 
356  void get_mesh_color(float& r, float& g, float& b, float& a) const {
357  r = mesh_color_[0];
358  g = mesh_color_[1];
359  b = mesh_color_[2];
360  a = mesh_color_[3];
361  }
362 
372  void set_surface_color(float r, float g, float b, float a=1.0f) {
373  surface_color_[0] = r;
374  surface_color_[1] = g;
375  surface_color_[2] = b;
376  surface_color_[3] = a;
377  backface_surface_color_[0] = r;
378  backface_surface_color_[1] = g;
379  backface_surface_color_[2] = b;
380  backface_surface_color_[3] = a;
381  }
382 
389  void get_surface_color(float& r, float& g, float& b, float& a) const {
390  r = surface_color_[0];
391  g = surface_color_[1];
392  b = surface_color_[2];
393  a = surface_color_[3];
394  }
395 
405  float r, float g, float b, float a=1.0f
406  ) {
407  backface_surface_color_[0] = r;
408  backface_surface_color_[1] = g;
409  backface_surface_color_[2] = b;
410  backface_surface_color_[3] = a;
411  }
412 
419  void set_cells_color(float r, float g, float b, float a=1.0f) {
420  for(index_t i=0; i<MESH_NB_CELL_TYPES; ++i) {
421  cells_color_[i][0] = r;
422  cells_color_[i][1] = g;
423  cells_color_[i][2] = b;
424  cells_color_[i][3] = a;
425  }
426  }
427 
434  void get_cells_color(float& r, float& g, float& b, float& a) const {
435  r = cells_color_[0][0];
436  g = cells_color_[0][1];
437  b = cells_color_[0][2];
438  a = cells_color_[0][3];
439  }
440 
451  cells_colors_by_type_ = true;
452  set_cells_color(MESH_TET, 1.0f, 0.0f, 0.0f);
453  set_cells_color(MESH_HEX, 0.9f, 0.9f, 0.9f);
454  set_cells_color(MESH_PRISM, 0.0f, 1.0f, 0.0f);
455  set_cells_color(MESH_PYRAMID, 0.0f, 0.0f, 1.0f);
456  set_cells_color(MESH_CONNECTOR, 1.0f, 0.8f, 0.0f);
457  }
458 
464  bool get_lighting() const {
465  return lighting_;
466  }
467 
473  void set_lighting(bool x) {
474  lighting_ = x;
475  }
476 
482  void set_mesh(const Mesh* M);
483 
488  const Mesh* mesh() const {
489  return mesh_;
490  }
491 
503  void set_picking_mode(MeshElementsFlags what) {
504  picking_mode_ = what;
505  }
506 
513  MeshElementsFlags get_picking_mode() const {
514  return picking_mode_;
515  }
516 
517 
526  object_picking_id_ = id;
527  }
528 
535  return object_picking_id_;
536  }
537 
546  void set_vertices_selection(const std::string& name) {
547  vertices_selection_ = name;
548  }
549 
555  const std::string& get_vertices_selection() const {
556  return vertices_selection_;
557  }
558 
578  MeshElementsFlags subelements,
579  const std::string& name,
580  double attr_min, double attr_max,
581  GLuint colormap_texture,
582  index_t repeat = 1
583  );
584 
596  MeshElementsFlags subelements,
597  const std::string& attribute_name,
598  GLuint texture,
599  index_t texture_dim,
600  index_t repeat = 1
601  );
602 
603 
608  attribute_subelements_ = MESH_NONE;
609  attribute_min_ = 0.0;
610  attribute_max_ = 0.0;
611  attribute_texture_ = 0;
612  attribute_repeat_ = 1;
613  attribute_dim_ = 0;
614  }
615 
628  MeshElementsFlags subelements,
629  const std::string& name = "filter"
630  );
631 
636 
637 
641  void cleanup();
642 
643  protected:
644 
645  void draw_vertices_array();
646  void draw_vertices_immediate_plain();
647  void draw_vertices_immediate_attrib();
648  void draw_vertices_selection();
649 
650  void draw_edges_array();
651  void draw_edges_immediate_plain();
652  void draw_edges_immediate_attrib();
653 
654  void draw_triangles();
655  void draw_triangles_array();
656  void draw_triangles_immediate_plain();
657  void draw_triangles_immediate_attrib();
658 
659  void draw_quads();
660  void draw_quads_array();
661  void draw_quads_immediate_plain();
662  void draw_quads_immediate_attrib();
663 
664  void draw_triangles_and_quads();
665  void draw_triangles_and_quads_array();
666  void draw_triangles_and_quads_immediate_plain();
667  void draw_triangles_and_quads_immediate_attrib();
668 
669  void draw_polygons();
670  void draw_polygons_plain();
671  void draw_polygons_attrib();
672 
673  void draw_tets();
674  void draw_tets_array();
675  void draw_tets_immediate_plain();
676  void draw_tets_immediate_attrib();
677 
678  void draw_hybrid();
679  void draw_hybrid_array();
680  void draw_hybrid_immediate_plain();
681  void draw_hybrid_immediate_attrib();
682 
683  void set_cells_color(MeshCellType type, float r, float g, float b) {
684  cells_color_[type][0] = r;
685  cells_color_[type][1] = g;
686  cells_color_[type][2] = b;
687  }
688 
689  void draw_attribute_as_tex_coord(index_t element) {
690  if(picking_mode_ == MESH_NONE) {
691  switch(attribute_dim_) {
692  case 1:
693  glupPrivateTexCoord1d(scalar_attribute_[element]);
694  break;
695  case 2:
696  glupPrivateTexCoord2d(
697  tex_coord_attribute_[0][element],
698  tex_coord_attribute_[1][element]
699  );
700  break;
701  case 3:
702  glupPrivateTexCoord3d(
703  tex_coord_attribute_[0][element],
704  tex_coord_attribute_[1][element],
705  tex_coord_attribute_[2][element]
706  );
707  break;
708  }
709  }
710  }
711 
712  void draw_vertex_with_attribute(index_t vertex) {
713  if(attribute_subelements_ == MESH_VERTICES) {
714  draw_attribute_as_tex_coord(vertex);
715  }
716  draw_vertex(vertex);
717  }
718 
719  void draw_surface_vertex_with_attribute(
720  index_t vertex, index_t facet, index_t corner
721  ) {
722  if(attribute_subelements_ == MESH_VERTICES) {
723  draw_attribute_as_tex_coord(vertex);
724  } else if(attribute_subelements_ == MESH_FACETS) {
725  draw_attribute_as_tex_coord(facet);
726  } else if(attribute_subelements_ == MESH_FACET_CORNERS) {
727  draw_attribute_as_tex_coord(corner);
728  }
729  draw_vertex(vertex);
730  }
731 
732  void draw_volume_vertex_with_attribute(
733  index_t vertex, index_t cell, index_t cell_corner
734  ) {
735  if(attribute_subelements_ == MESH_VERTICES) {
736  draw_attribute_as_tex_coord(vertex);
737  } else if(attribute_subelements_ == MESH_CELLS) {
738  draw_attribute_as_tex_coord(cell);
739  } else if(attribute_subelements_ == MESH_CELL_CORNERS) {
740  draw_attribute_as_tex_coord(cell_corner);
741  }
742  draw_vertex(vertex);
743  }
744 
745  void draw_vertex(index_t v) {
746  if(do_animation_) {
747  if(mesh_->vertices.single_precision()) {
748  const GLUPfloat* p =
749  mesh_->vertices.single_precision_point_ptr(v);
750  float t = float(time_);
751  float s = 1.0f - float(time_);
752  glupPrivateVertex3f(
753  s*p[0] + t*p[3],
754  s*p[1] + t*p[4],
755  s*p[2] + t*p[5]
756  );
757  } else {
758  const GLUPdouble* p = mesh_->vertices.point_ptr(v);
759  double s = 1.0 - time_;
760  glupPrivateVertex3d(
761  s*p[0] + time_*p[3],
762  s*p[1] + time_*p[4],
763  s*p[2] + time_*p[5]
764  );
765  }
766  } else {
767  if(mesh_->vertices.single_precision()) {
768  if(mesh_->vertices.dimension() < 3) {
769  glupPrivateVertex2fv(
770  mesh_->vertices.single_precision_point_ptr(v)
771  );
772  } else {
773  glupPrivateVertex3fv(
774  mesh_->vertices.single_precision_point_ptr(v)
775  );
776  }
777  } else {
778  if(mesh_->vertices.dimension() < 3) {
779  glupPrivateVertex2dv(
780  mesh_->vertices.point_ptr(v)
781  );
782  } else {
783  glupPrivateVertex3dv(
784  mesh_->vertices.point_ptr(v)
785  );
786  }
787  }
788  }
789  }
790 
791  void draw_surface_mesh_with_lines();
792 
797 
805  void set_GLUP_picking(MeshElementsFlags what);
806 
807 
814 
815 
825 
826 
836 
837 
846 
847 
855 
860 
866 
871 
872 
879 
880  void update_surface_elements();
881 
882  void update_volume_elements();
883 
884  protected:
885  bool show_mesh_;
886  index_t mesh_width_;
887  index_t mesh_border_width_;
888  double shrink_;
889  bool animate_;
890  double time_;
891  bool draw_cells_[MESH_NB_CELL_TYPES];
892  float points_size_;
893 
894  float points_color_[4];
895  float mesh_color_[4];
896  float surface_color_[4];
897  float backface_surface_color_[4];
898  float cells_color_[MESH_NB_CELL_TYPES][4];
899  bool cells_colors_by_type_;
900 
901  bool lighting_;
902 
903  MeshElementsFlags picking_mode_;
904  index_t object_picking_id_;
905 
906  std::string vertices_selection_;
907 
908  bool do_animation_;
909 
910  const Mesh* mesh_;
911  bool triangles_and_quads_;
912  bool quads_;
913  bool has_cells_[MESH_NB_CELL_TYPES];
914 
915  bool buffer_objects_dirty_;
916  bool attributes_buffer_objects_dirty_;
917  bool long_vector_attribute_;
918 
919  GLuint vertices_VAO_;
920  GLuint edges_VAO_;
921  GLuint facets_VAO_;
922  GLuint cells_VAO_;
923 
924  GLuint vertices_VBO_;
925  GLuint edge_indices_VBO_;
926  GLuint facet_indices_VBO_;
927  GLuint cell_indices_VBO_;
928  GLuint vertices_attribute_VBO_;
929 
930  MeshElementsFlags attribute_subelements_;
931  std::string attribute_name_;
932  index_t attribute_dim_;
933  double attribute_min_;
934  double attribute_max_;
935  GLuint attribute_texture_;
936  index_t attribute_texture_dim_;
937  index_t attribute_repeat_;
938  ReadOnlyScalarAttributeAdapter scalar_attribute_;
939  ReadOnlyScalarAttributeAdapter tex_coord_attribute_[3];
940  bool ES_profile_;
941 
946  struct Filter {
947  Filter();
948  ~Filter();
949 
963  bool begin(
964  AttributesManager& attributes_manager,
965  bool hw_primitive_filtering=true
966  );
967 
971  void end();
972 
976  void deallocate();
977 
984  bool test(index_t primitive_id) const {
985  return (
986  !attribute.is_bound() ||
987  attribute[primitive_id] != 0
988  );
989  }
990 
991  std::string attribute_name;
992  Attribute<Numeric::uint8> attribute;
993  GLuint VBO;
994  GLuint texture;
995  bool dirty;
996  };
997 
998  Filter vertices_filter_;
999  Filter facets_filter_;
1000  Filter cells_filter_;
1001 
1010 
1024  const MeshSubElementsStore& elements,
1025  std::function<void(index_t, index_t)> draw
1026  ) {
1027  // GLUP hardware primitive filtering.
1028  // Not supported in all profiles.
1029  // If supported, primitives are filtered by the GPU,
1030  // else, they are filtered here explicitly.
1031  const bool hw_filtering = hw_filtering_supported();
1032 
1033  Filter* filter = nullptr;
1034  if(&elements == &mesh_->vertices) {
1035  filter = &vertices_filter_;
1036  } else if(&elements == &mesh_->facets) {
1037  filter = &facets_filter_;
1038  } else if(&elements == &mesh_->cells) {
1039  filter = &cells_filter_;
1040  }
1041  geo_assert(filter != nullptr) ;
1042 
1043  filter->begin(elements.attributes(), hw_filtering);
1044  index_t e = 0;
1045  while(e < elements.nb()) {
1046  while(e<elements.nb() && !(hw_filtering||filter->test(e))) {
1047  ++e;
1048  }
1049  if(e<elements.nb()) {
1050  index_t begin = e;
1051  while(e<elements.nb() && (hw_filtering||filter->test(e))) {
1052  ++e;
1053  }
1054  index_t end = e;
1055  glupBasePickingId(GLUPuint64(begin));
1056  draw(begin,end);
1057  }
1058  }
1059  filter->end();
1060  glupBasePickingId(0);
1061  }
1062 
1078  const MeshSubElementsStore& elements,
1079  std::function<bool(index_t)> predicate,
1080  std::function<void(index_t, index_t)> draw
1081  ) {
1082  // GLUP hardware primitive filtering.
1083  // Not supported in all profiles.
1084  // If supported, primitives are filtered by the GPU,
1085  // else, they are filtered here explicitly.
1086  const bool hw_filtering = hw_filtering_supported();
1087 
1088  Filter* filter = nullptr;
1089  if(&elements == &mesh_->vertices) {
1090  filter = &vertices_filter_;
1091  } else if(&elements == &mesh_->facets) {
1092  filter = &facets_filter_;
1093  } else if(&elements == &mesh_->cells) {
1094  filter = &cells_filter_;
1095  }
1096  geo_assert(filter != nullptr) ;
1097  filter->begin(elements.attributes(), hw_filtering);
1098 
1099  index_t e = 0;
1100  while(e < elements.nb()) {
1101  while(
1102  e<elements.nb() && (
1103  !(hw_filtering || filter->test(e)) || !predicate(e))
1104  ) {
1105  ++e;
1106  }
1107  if(e<elements.nb()) {
1108  index_t begin = e;
1109  while(
1110  e<elements.nb() &&
1111  (hw_filtering || filter->test(e)) &&
1112  predicate(e)
1113  ) {
1114  ++e;
1115  }
1116  index_t end = e;
1117  glupBasePickingId(GLUPuint64(begin));
1118  draw(begin,end);
1119  }
1120  }
1121  filter->end();
1122  glupBasePickingId(0);
1123  }
1124 
1125  };
1126 
1127 }
1128 
1129 #endif
GLUP: GL Useful Primitives.
GLUPprimitive
Symbolic values corresponding to GLUP primitive types.
Definition: GLUP.h:470
Slightly faster GLUP functions, not part of the API (do not use in client code).
#define geo_assert(x)
Verifies that a condition is met.
Definition: assert.h:149
Managers a set of attributes attached to an object.
Definition: attributes.h:834
Draws a mesh using OpenGL.
Definition: mesh_gfx.h:60
void draw_surface()
Draws the surfacic part of the mesh.
void get_mesh_color(float &r, float &g, float &b, float &a) const
Gets the mesh color.
Definition: mesh_gfx.h:356
void get_points_color(float &r, float &g, float &b, float &a) const
Gets the points color.
Definition: mesh_gfx.h:310
void bind_attribute_buffer_object(GLuint VAO)
Binds the attribute buffer object to a Vertex Array Object.
void cleanup()
Deallocates OpenGL objects.
void set_GLUP_parameters()
Sets GLUP drawing parameters.
void set_lighting(bool x)
Sets the lighting flag.
Definition: mesh_gfx.h:473
void set_shrink(double x)
Sets the cells shrink coefficient.
Definition: mesh_gfx.h:199
void update_attribute_buffer_objects_if_needed()
Updates the buffer objects used to display attributes.
void set_cells_colors_by_type()
Sets a different color for each mesh cell type.
Definition: mesh_gfx.h:450
void end_attributes()
Deactivates drawing for attributes.
void begin_attributes()
Setups drawing for attributes.
void set_draw_cells(MeshCellType type, bool x)
Sets the cell visibility flag.
Definition: mesh_gfx.h:286
void set_cells_color(float r, float g, float b, float a=1.0f)
Sets the color used to display mesh cells.
Definition: mesh_gfx.h:419
double get_shrink() const
Gets the cells shrink coefficient.
Definition: mesh_gfx.h:187
void set_texturing(MeshElementsFlags subelements, const std::string &attribute_name, GLuint texture, index_t texture_dim, index_t repeat=1)
Sets the parameters for texture mapping.
void set_points_size(float x)
Sets the point size.
Definition: mesh_gfx.h:322
void draw_volume()
Draws the volumetric part of the mesh.
void get_cells_color(float &r, float &g, float &b, float &a) const
Gets the cells color.
Definition: mesh_gfx.h:434
index_t get_object_picking_id() const
Gets the object-wide picking id.
Definition: mesh_gfx.h:534
MeshGfx()
MeshGfx constructor.
void set_picking_mode(MeshElementsFlags what)
Sets picking mode.
Definition: mesh_gfx.h:503
bool get_draw_cells(MeshCellType type) const
Gets the cell visibility flag.
Definition: mesh_gfx.h:273
void set_object_picking_id(index_t id)
Sets the object-wide picking id.
Definition: mesh_gfx.h:525
float get_points_size() const
Gets the point size.
Definition: mesh_gfx.h:331
bool get_lighting() const
Gets the lighing flag.
Definition: mesh_gfx.h:464
bool can_use_array_mode(GLUPprimitive prim) const
Tests whether array mode can be used to draw a specified GLUP primitive.
void set_GLUP_vertex_color_from_picking_id(index_t id)
Encodes an id as the current vertex color.
void set_GLUP_picking(MeshElementsFlags what)
Sets GLUP picking mode for drawing primitives of a given type, or deactivates GLUP picking if MeshGfx...
void set_surface_color(float r, float g, float b, float a=1.0f)
Sets the surface color.
Definition: mesh_gfx.h:372
void set_points_color(float r, float g, float b, float a=1.0f)
Sets the points color.
Definition: mesh_gfx.h:297
void draw_edges()
Draws the edges of the mesh.
void set_mesh(const Mesh *M)
Sets the mesh.
void set_mesh_width(index_t x)
Sets the mesh width.
Definition: mesh_gfx.h:155
const std::string & get_vertices_selection() const
Gets the vertices selection.
Definition: mesh_gfx.h:555
void set_time(double x)
Gets the time of the animation.
Definition: mesh_gfx.h:256
void set_vertices_selection(const std::string &name)
Sets the vertices selection.
Definition: mesh_gfx.h:546
~MeshGfx()
MeshGfx destructor.
index_t get_mesh_width() const
Gets the mesh width.
Definition: mesh_gfx.h:143
MeshGfx & operator=(const MeshGfx &rhs)=delete
Forbids MeshGfx copy..
bool get_show_mesh() const
Gets the mesh visibility flag.
Definition: mesh_gfx.h:120
void set_backface_surface_color(float r, float g, float b, float a=1.0f)
Sets the surface color for backfacing faces.
Definition: mesh_gfx.h:404
bool get_animate() const
Gets the animate flag.
Definition: mesh_gfx.h:220
void set_mesh_border_width(index_t x)
Sets the mesh border width.
Definition: mesh_gfx.h:175
void unset_filters()
Unset primitive filtering.
const Mesh * mesh() const
Gets the mesh.
Definition: mesh_gfx.h:488
index_t get_mesh_border_width() const
Gets the mesh border width.
Definition: mesh_gfx.h:165
void set_show_mesh(bool x)
Sets the mesh visibility flag.
Definition: mesh_gfx.h:131
void get_surface_color(float &r, float &g, float &b, float &a) const
Gets the surface color.
Definition: mesh_gfx.h:389
void draw_sequences_if(const MeshSubElementsStore &elements, std::function< bool(index_t)> predicate, std::function< void(index_t, index_t)> draw)
Generic function to extract element sequences to draw.
Definition: mesh_gfx.h:1077
void draw_vertices()
Draws the vertices of the mesh.
void update_buffer_objects_if_needed()
Updates the Vertex Buffer Objects and Vertex Array Objects.
MeshGfx(const MeshGfx &rhs)=delete
Forbids MeshGfx copy..
void draw_surface_borders()
Draws the borders of the surfacic part of the mesh.
double get_time() const
Gets the time of the animation.
Definition: mesh_gfx.h:245
void set_animate(bool x)
Gets the animate flag.
Definition: mesh_gfx.h:234
void set_scalar_attribute(MeshElementsFlags subelements, const std::string &name, double attr_min, double attr_max, GLuint colormap_texture, index_t repeat=1)
Sets the parameters for displaying a scalar attribute using texture mapping.
void bind_vertices_VBO()
Binds the vertices VBO to the current VAO.
void set_filter(MeshElementsFlags subelements, const std::string &name="filter")
Sets primitive filtering.
void unset_scalar_attribute()
Unsets scalar attribute display.
Definition: mesh_gfx.h:607
MeshElementsFlags get_picking_mode() const
Gets the current picking mode.
Definition: mesh_gfx.h:513
bool hw_filtering_supported() const
Tests whether hardware primitive filtering is supported.
void set_mesh_color(float r, float g, float b, float a=1.0f)
Sets the mesh color.
Definition: mesh_gfx.h:343
void draw_sequences(const MeshSubElementsStore &elements, std::function< void(index_t, index_t)> draw)
Generic function to extract element sequences to draw.
Definition: mesh_gfx.h:1023
void unbind_attribute_buffer_object(GLuint VAO)
Unbinds the attribute buffer object from a Vertex Array Object.
Base class for mesh sub-element storage.
Definition: mesh.h:70
index_t nb() const
Gets the number of (sub-)elements.
Definition: mesh.h:89
AttributesManager & attributes() const
Gets the attributes manager.
Definition: mesh.h:100
Represents a mesh.
Definition: mesh.h:2693
Readonly access to an attribute as a double regardless its type.
Definition: attributes.h:2080
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition: defs.h:55
Common include file, providing basic definitions. Should be included before anything else by all head...
The class that represents a mesh.
Global Vorpaline namespace.
Definition: basic.h:55
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Filters primitives based on their id and on an attribute.
Definition: mesh_gfx.h:946
bool begin(AttributesManager &attributes_manager, bool hw_primitive_filtering=true)
Begins rendering with primitive filtering.
void end()
Needs to be called after rendering.
bool test(index_t primitive_id) const
Tests an individual primitive.
Definition: mesh_gfx.h:984
void deallocate()
Deallocates GPU objects.