Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
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
46#include <geogram/mesh/mesh.h>
47
53namespace 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
90
94 void draw_edges();
95
100
106
111
120 bool get_show_mesh() const {
121 return show_mesh_;
122 }
123
135 void set_show_mesh(bool x) {
136 show_mesh_ = x;
137 }
138
148 return mesh_width_;
149 }
150
160 mesh_width_ = x;
161 }
162
170 return mesh_border_width_;
171 }
172
180 mesh_border_width_ = x;
181 }
182
191 double get_shrink() const {
192 return shrink_;
193 }
194
203 void set_shrink(double x) {
204 shrink_ = x;
205 if(shrink_ < 0.0) {
206 shrink_ = 0.0;
207 } else if(shrink_ > 1.0) {
208 shrink_ = 1.0;
209 }
210 }
211
212
224 bool get_animate() const {
225 return animate_;
226 }
227
238 void set_animate(bool x) {
239 animate_ = x;
240 }
241
249 double get_time() const {
250 return time_;
251 }
252
260 void set_time(double x) {
261 time_ = x;
262 if(time_ < 0.0) {
263 time_ = 0.0;
264 } else if(time_ > 1.0) {
265 time_ = 1.0;
266 }
267 }
268
277 bool get_draw_cells(MeshCellType type) const {
278 return draw_cells_[type];
279 }
280
281
290 void set_draw_cells(MeshCellType type, bool x) {
291 draw_cells_[type] = x;
292 }
293
301 void set_points_color(float r, float g, float b, float a=1.0f) {
302 points_color_[0] = r;
303 points_color_[1] = g;
304 points_color_[2] = b;
305 points_color_[3] = a;
306 }
307
314 void get_points_color(float& r, float& g, float& b, float& a) const {
315 r = points_color_[0];
316 g = points_color_[1];
317 b = points_color_[2];
318 a = points_color_[3];
319 }
320
326 void set_points_size(float x) {
327 points_size_ = x;
328 }
329
335 float get_points_size() const {
336 return points_size_;
337 }
338
347 void set_mesh_color(float r, float g, float b, float a=1.0f) {
348 mesh_color_[0] = r;
349 mesh_color_[1] = g;
350 mesh_color_[2] = b;
351 mesh_color_[3] = a;
352 }
353
360 void get_mesh_color(float& r, float& g, float& b, float& a) const {
361 r = mesh_color_[0];
362 g = mesh_color_[1];
363 b = mesh_color_[2];
364 a = mesh_color_[3];
365 }
366
376 void set_surface_color(float r, float g, float b, float a=1.0f) {
377 surface_color_[0] = r;
378 surface_color_[1] = g;
379 surface_color_[2] = b;
380 surface_color_[3] = a;
381 backface_surface_color_[0] = r;
382 backface_surface_color_[1] = g;
383 backface_surface_color_[2] = b;
384 backface_surface_color_[3] = a;
385 }
386
393 void get_surface_color(float& r, float& g, float& b, float& a) const {
394 r = surface_color_[0];
395 g = surface_color_[1];
396 b = surface_color_[2];
397 a = surface_color_[3];
398 }
399
409 float r, float g, float b, float a=1.0f
410 ) {
411 backface_surface_color_[0] = r;
412 backface_surface_color_[1] = g;
413 backface_surface_color_[2] = b;
414 backface_surface_color_[3] = a;
415 }
416
423 void set_cells_color(float r, float g, float b, float a=1.0f) {
424 for(index_t i=0; i<MESH_NB_CELL_TYPES; ++i) {
425 cells_color_[i][0] = r;
426 cells_color_[i][1] = g;
427 cells_color_[i][2] = b;
428 cells_color_[i][3] = a;
429 }
430 }
431
438 void get_cells_color(float& r, float& g, float& b, float& a) const {
439 r = cells_color_[0][0];
440 g = cells_color_[0][1];
441 b = cells_color_[0][2];
442 a = cells_color_[0][3];
443 }
444
455 cells_colors_by_type_ = true;
456 set_cells_color(MESH_TET, 1.0f, 0.0f, 0.0f);
457 set_cells_color(MESH_HEX, 0.9f, 0.9f, 0.9f);
458 set_cells_color(MESH_PRISM, 0.0f, 1.0f, 0.0f);
459 set_cells_color(MESH_PYRAMID, 0.0f, 0.0f, 1.0f);
460 set_cells_color(MESH_CONNECTOR, 1.0f, 0.8f, 0.0f);
461 }
462
468 bool get_lighting() const {
469 return lighting_;
470 }
471
477 void set_lighting(bool x) {
478 lighting_ = x;
479 }
480
486 void set_mesh(const Mesh* M);
487
492 const Mesh* mesh() const {
493 return mesh_;
494 }
495
507 void set_picking_mode(MeshElementsFlags what) {
508 picking_mode_ = what;
509 }
510
517 MeshElementsFlags get_picking_mode() const {
518 return picking_mode_;
519 }
520
521
530 object_picking_id_ = id;
531 }
532
539 return object_picking_id_;
540 }
541
550 void set_vertices_selection(const std::string& name) {
551 vertices_selection_ = name;
552 }
553
559 const std::string& get_vertices_selection() const {
560 return vertices_selection_;
561 }
562
582 MeshElementsFlags subelements,
583 const std::string& name,
584 double attr_min, double attr_max,
585 GLuint colormap_texture,
586 index_t repeat = 1
587 );
588
600 MeshElementsFlags subelements,
601 const std::string& attribute_name,
602 GLuint texture,
603 index_t texture_dim,
604 index_t repeat = 1
605 );
606
607
612 attribute_subelements_ = MESH_NONE;
613 attribute_min_ = 0.0;
614 attribute_max_ = 0.0;
615 attribute_texture_ = 0;
616 attribute_repeat_ = 1;
617 attribute_dim_ = 0;
618 }
619
632 MeshElementsFlags subelements,
633 const std::string& name = "filter"
634 );
635
640
641
645 void cleanup();
646
647 protected:
648
649 void draw_vertices_array();
650 void draw_vertices_immediate_plain();
651 void draw_vertices_immediate_attrib();
652 void draw_vertices_selection();
653
654 void draw_edges_array();
655 void draw_edges_immediate_plain();
656 void draw_edges_immediate_attrib();
657
658 void draw_triangles();
659 void draw_triangles_array();
660 void draw_triangles_immediate_plain();
661 void draw_triangles_immediate_attrib();
662
663 void draw_quads();
664 void draw_quads_array();
665 void draw_quads_immediate_plain();
666 void draw_quads_immediate_attrib();
667
668 void draw_triangles_and_quads();
669 void draw_triangles_and_quads_array();
670 void draw_triangles_and_quads_immediate_plain();
671 void draw_triangles_and_quads_immediate_attrib();
672
673 void draw_polygons();
674 void draw_polygons_plain();
675 void draw_polygons_attrib();
676
677 void draw_tets();
678 void draw_tets_array();
679 void draw_tets_immediate_plain();
680 void draw_tets_immediate_attrib();
681
682 void draw_hybrid();
683 void draw_hybrid_array();
684 void draw_hybrid_immediate_plain();
685 void draw_hybrid_immediate_attrib();
686
687 void set_cells_color(MeshCellType type, float r, float g, float b) {
688 cells_color_[type][0] = r;
689 cells_color_[type][1] = g;
690 cells_color_[type][2] = b;
691 }
692
693 void draw_attribute_as_tex_coord(index_t element) {
694 if(picking_mode_ == MESH_NONE) {
695 switch(attribute_dim_) {
696 case 1:
697 glupPrivateTexCoord1d(scalar_attribute_[element]);
698 break;
699 case 2:
700 glupPrivateTexCoord2d(
701 tex_coord_attribute_[0][element],
702 tex_coord_attribute_[1][element]
703 );
704 break;
705 case 3:
706 glupPrivateTexCoord3d(
707 tex_coord_attribute_[0][element],
708 tex_coord_attribute_[1][element],
709 tex_coord_attribute_[2][element]
710 );
711 break;
712 }
713 }
714 }
715
716 void draw_vertex_with_attribute(index_t vertex) {
717 if(attribute_subelements_ == MESH_VERTICES) {
718 draw_attribute_as_tex_coord(vertex);
719 }
720 draw_vertex(vertex);
721 }
722
723 void draw_surface_vertex_with_attribute(
724 index_t vertex, index_t facet, index_t corner
725 ) {
726 if(attribute_subelements_ == MESH_VERTICES) {
727 draw_attribute_as_tex_coord(vertex);
728 } else if(attribute_subelements_ == MESH_FACETS) {
729 draw_attribute_as_tex_coord(facet);
730 } else if(attribute_subelements_ == MESH_FACET_CORNERS) {
731 draw_attribute_as_tex_coord(corner);
732 }
733 draw_vertex(vertex);
734 }
735
736 void draw_volume_vertex_with_attribute(
737 index_t vertex, index_t cell, index_t cell_corner
738 ) {
739 if(attribute_subelements_ == MESH_VERTICES) {
740 draw_attribute_as_tex_coord(vertex);
741 } else if(attribute_subelements_ == MESH_CELLS) {
742 draw_attribute_as_tex_coord(cell);
743 } else if(attribute_subelements_ == MESH_CELL_CORNERS) {
744 draw_attribute_as_tex_coord(cell_corner);
745 }
746 draw_vertex(vertex);
747 }
748
749 void draw_vertex(index_t v) {
750 if(do_animation_) {
751 if(mesh_->vertices.single_precision()) {
752 const GLUPfloat* p =
753 mesh_->vertices.single_precision_point_ptr(v);
754 float t = float(time_);
755 float s = 1.0f - float(time_);
756 glupPrivateVertex3f(
757 s*p[0] + t*p[3],
758 s*p[1] + t*p[4],
759 s*p[2] + t*p[5]
760 );
761 } else {
762 const GLUPdouble* p = mesh_->vertices.point_ptr(v);
763 double s = 1.0 - time_;
764 glupPrivateVertex3d(
765 s*p[0] + time_*p[3],
766 s*p[1] + time_*p[4],
767 s*p[2] + time_*p[5]
768 );
769 }
770 } else {
771 if(mesh_->vertices.single_precision()) {
772 if(mesh_->vertices.dimension() < 3) {
773 glupPrivateVertex2fv(
774 mesh_->vertices.single_precision_point_ptr(v)
775 );
776 } else {
777 glupPrivateVertex3fv(
778 mesh_->vertices.single_precision_point_ptr(v)
779 );
780 }
781 } else {
782 if(mesh_->vertices.dimension() < 3) {
783 glupPrivateVertex2dv(
784 mesh_->vertices.point_ptr(v)
785 );
786 } else {
787 glupPrivateVertex3dv(
788 mesh_->vertices.point_ptr(v)
789 );
790 }
791 }
792 }
793 }
794
795 void draw_surface_mesh_with_lines();
796
801
809 void set_GLUP_picking(MeshElementsFlags what);
810
811
818
819
829
830
840
841
850
851
859
864
870
875
876
883
884 void update_surface_elements();
885
886 void update_volume_elements();
887
888 protected:
889 bool show_mesh_;
890 index_t mesh_width_;
891 index_t mesh_border_width_;
892 double shrink_;
893 bool animate_;
894 double time_;
895 bool draw_cells_[MESH_NB_CELL_TYPES];
896 float points_size_;
897
898 float points_color_[4];
899 float mesh_color_[4];
900 float surface_color_[4];
901 float backface_surface_color_[4];
902 float cells_color_[MESH_NB_CELL_TYPES][4];
903 bool cells_colors_by_type_;
904
905 bool lighting_;
906
907 MeshElementsFlags picking_mode_;
908 index_t object_picking_id_;
909
910 std::string vertices_selection_;
911
912 bool do_animation_;
913
914 const Mesh* mesh_;
915 bool triangles_and_quads_;
916 bool quads_;
917 bool has_cells_[MESH_NB_CELL_TYPES];
918
919 bool buffer_objects_dirty_;
920 bool attributes_buffer_objects_dirty_;
921 bool long_vector_attribute_;
922
923 GLuint vertices_VAO_;
924 GLuint edges_VAO_;
925 GLuint facets_VAO_;
926 GLuint cells_VAO_;
927
928 GLuint vertices_VBO_;
929 GLuint edge_indices_VBO_;
930 GLuint facet_indices_VBO_;
931 GLuint cell_indices_VBO_;
932 GLuint vertices_attribute_VBO_;
933
934 MeshElementsFlags attribute_subelements_;
935 std::string attribute_name_;
936 index_t attribute_dim_;
937 double attribute_min_;
938 double attribute_max_;
939 GLuint attribute_texture_;
940 index_t attribute_texture_dim_;
941 index_t attribute_repeat_;
942 ReadOnlyScalarAttributeAdapter scalar_attribute_;
943 ReadOnlyScalarAttributeAdapter tex_coord_attribute_[3];
944 bool ES_profile_;
945
950 struct Filter {
951 Filter();
952 ~Filter();
953
967 bool begin(
968 AttributesManager& attributes_manager,
969 bool hw_primitive_filtering=true
970 );
971
975 void end();
976
981
988 bool test(index_t primitive_id) const {
989 return (
990 !attribute.is_bound() ||
991 attribute[primitive_id] != 0
992 );
993 }
994
995 std::string attribute_name;
997 GLuint VBO;
998 GLuint texture;
999 bool dirty;
1000 };
1001
1002 Filter vertices_filter_;
1003 Filter facets_filter_;
1004 Filter cells_filter_;
1005
1014
1028 const MeshSubElementsStore& elements,
1029 std::function<void(index_t, index_t)> draw
1030 ) {
1031 // GLUP hardware primitive filtering.
1032 // Not supported in all profiles.
1033 // If supported, primitives are filtered by the GPU,
1034 // else, they are filtered here explicitly.
1035 const bool hw_filtering = hw_filtering_supported();
1036
1037 Filter* filter = nullptr;
1038 if(&elements == &mesh_->vertices) {
1039 filter = &vertices_filter_;
1040 } else if(&elements == &mesh_->facets) {
1041 filter = &facets_filter_;
1042 } else if(&elements == &mesh_->cells) {
1043 filter = &cells_filter_;
1044 }
1045 geo_assert(filter != nullptr) ;
1046
1047 filter->begin(elements.attributes(), hw_filtering);
1048 index_t e = 0;
1049 while(e < elements.nb()) {
1050 while(e<elements.nb() && !(hw_filtering||filter->test(e))) {
1051 ++e;
1052 }
1053 if(e<elements.nb()) {
1054 index_t begin = e;
1055 while(e<elements.nb() && (hw_filtering||filter->test(e))) {
1056 ++e;
1057 }
1058 index_t end = e;
1059 glupBasePickingId(GLUPuint64(begin));
1060 draw(begin,end);
1061 }
1062 }
1063 filter->end();
1064 glupBasePickingId(0);
1065 }
1066
1082 const MeshSubElementsStore& elements,
1083 std::function<bool(index_t)> predicate,
1084 std::function<void(index_t, index_t)> draw
1085 ) {
1086 // GLUP hardware primitive filtering.
1087 // Not supported in all profiles.
1088 // If supported, primitives are filtered by the GPU,
1089 // else, they are filtered here explicitly.
1090 const bool hw_filtering = hw_filtering_supported();
1091
1092 Filter* filter = nullptr;
1093 if(&elements == &mesh_->vertices) {
1094 filter = &vertices_filter_;
1095 } else if(&elements == &mesh_->facets) {
1096 filter = &facets_filter_;
1097 } else if(&elements == &mesh_->cells) {
1098 filter = &cells_filter_;
1099 }
1100 geo_assert(filter != nullptr) ;
1101 filter->begin(elements.attributes(), hw_filtering);
1102
1103 index_t e = 0;
1104 while(e < elements.nb()) {
1105 while(
1106 e<elements.nb() && (
1107 !(hw_filtering || filter->test(e)) || !predicate(e))
1108 ) {
1109 ++e;
1110 }
1111 if(e<elements.nb()) {
1112 index_t begin = e;
1113 while(
1114 e<elements.nb() &&
1115 (hw_filtering || filter->test(e)) &&
1116 predicate(e)
1117 ) {
1118 ++e;
1119 }
1120 index_t end = e;
1121 glupBasePickingId(GLUPuint64(begin));
1122 draw(begin,end);
1123 }
1124 }
1125 filter->end();
1126 glupBasePickingId(0);
1127 }
1128
1129 };
1130
1131}
1132
1133#endif
GLUP: GL Useful Primitives.
GLUPprimitive
Symbolic values corresponding to GLUP primitive types.
Definition GLUP.h:504
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
Manages an attribute attached to a set of object.
Managers a set of attributes attached to an object.
Definition attributes.h:732
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:360
void get_points_color(float &r, float &g, float &b, float &a) const
Gets the points color.
Definition mesh_gfx.h:314
void bind_attribute_buffer_object(GLuint VAO)
Binds the attribute buffer object to a Vertex Array Object.
void cleanup()
Deallocates OpenGL objects.
const std::string & get_vertices_selection() const
Gets the vertices selection.
Definition mesh_gfx.h:559
void set_GLUP_parameters()
Sets GLUP drawing parameters.
void set_lighting(bool x)
Sets the lighting flag.
Definition mesh_gfx.h:477
void set_shrink(double x)
Sets the cells shrink coefficient.
Definition mesh_gfx.h:203
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:454
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:290
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:423
double get_shrink() const
Gets the cells shrink coefficient.
Definition mesh_gfx.h:191
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:326
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:438
index_t get_object_picking_id() const
Gets the object-wide picking id.
Definition mesh_gfx.h:538
MeshGfx()
MeshGfx constructor.
void set_picking_mode(MeshElementsFlags what)
Sets picking mode.
Definition mesh_gfx.h:507
bool get_draw_cells(MeshCellType type) const
Gets the cell visibility flag.
Definition mesh_gfx.h:277
void set_object_picking_id(index_t id)
Sets the object-wide picking id.
Definition mesh_gfx.h:529
float get_points_size() const
Gets the point size.
Definition mesh_gfx.h:335
bool get_lighting() const
Gets the lighing flag.
Definition mesh_gfx.h:468
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:376
void set_points_color(float r, float g, float b, float a=1.0f)
Sets the points color.
Definition mesh_gfx.h:301
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:159
void set_time(double x)
Gets the time of the animation.
Definition mesh_gfx.h:260
void set_vertices_selection(const std::string &name)
Sets the vertices selection.
Definition mesh_gfx.h:550
~MeshGfx()
MeshGfx destructor.
index_t get_mesh_width() const
Gets the mesh width.
Definition mesh_gfx.h:147
bool get_show_mesh() const
Gets the mesh visibility flag.
Definition mesh_gfx.h:120
const Mesh * mesh() const
Gets the mesh.
Definition mesh_gfx.h:492
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:408
bool get_animate() const
Gets the animate flag.
Definition mesh_gfx.h:224
void set_mesh_border_width(index_t x)
Sets the mesh border width.
Definition mesh_gfx.h:179
void unset_filters()
Unset primitive filtering.
index_t get_mesh_border_width() const
Gets the mesh border width.
Definition mesh_gfx.h:169
void set_show_mesh(bool x)
Sets the mesh visibility flag.
Definition mesh_gfx.h:135
void get_surface_color(float &r, float &g, float &b, float &a) const
Gets the surface color.
Definition mesh_gfx.h:393
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:1081
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:249
void set_animate(bool x)
Gets the animate flag.
Definition mesh_gfx.h:238
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.
MeshGfx & operator=(const MeshGfx &rhs)=delete
Forbids MeshGfx copy..
void unset_scalar_attribute()
Unsets scalar attribute display.
Definition mesh_gfx.h:611
MeshElementsFlags get_picking_mode() const
Gets the current picking mode.
Definition mesh_gfx.h:517
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:347
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:1027
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
AttributesManager & attributes() const
Gets the attributes manager.
Definition mesh.h:100
index_t nb() const
Gets the number of (sub-)elements.
Definition mesh.h:89
Represents a mesh.
Definition mesh.h:2648
Readonly access to an attribute as a double regardless its type.
#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 algorithm.h:64
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:287
Filters primitives based on their id and on an attribute.
Definition mesh_gfx.h:950
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:988
void deallocate()
Deallocates GPU objects.