Geogram Version 1.8.5
A programming library of geometric algorithms
|
Draws a mesh using OpenGL. More...
#include <geogram_gfx/mesh/mesh_gfx.h>
Classes | |
struct | Filter |
Filters primitives based on their id and on an attribute. More... | |
Public Member Functions | |
MeshGfx () | |
MeshGfx constructor. | |
~MeshGfx () | |
MeshGfx destructor. | |
MeshGfx (const MeshGfx &rhs)=delete | |
Forbids MeshGfx copy.. | |
MeshGfx & | operator= (const MeshGfx &rhs)=delete |
Forbids MeshGfx copy.. | |
void | draw_vertices () |
Draws the vertices of the mesh. | |
void | draw_edges () |
Draws the edges of the mesh. | |
void | draw_surface () |
Draws the surfacic part of the mesh. | |
void | draw_surface_borders () |
Draws the borders of the surfacic part of the mesh. | |
void | draw_volume () |
Draws the volumetric part of the mesh. | |
bool | get_show_mesh () const |
Gets the mesh visibility flag. | |
void | set_show_mesh (bool x) |
Sets the mesh visibility flag. | |
index_t | get_mesh_width () const |
Gets the mesh width. | |
void | set_mesh_width (index_t x) |
Sets the mesh width. | |
index_t | get_mesh_border_width () const |
Gets the mesh border width. | |
void | set_mesh_border_width (index_t x) |
Sets the mesh border width. | |
double | get_shrink () const |
Gets the cells shrink coefficient. | |
void | set_shrink (double x) |
Sets the cells shrink coefficient. | |
bool | get_animate () const |
Gets the animate flag. | |
void | set_animate (bool x) |
Gets the animate flag. | |
double | get_time () const |
Gets the time of the animation. | |
void | set_time (double x) |
Gets the time of the animation. | |
bool | get_draw_cells (MeshCellType type) const |
Gets the cell visibility flag. | |
void | set_draw_cells (MeshCellType type, bool x) |
Sets the cell visibility flag. | |
void | set_points_color (float r, float g, float b, float a=1.0f) |
Sets the points color. | |
void | get_points_color (float &r, float &g, float &b, float &a) const |
Gets the points color. | |
void | set_points_size (float x) |
Sets the point size. | |
float | get_points_size () const |
Gets the point size. | |
void | set_mesh_color (float r, float g, float b, float a=1.0f) |
Sets the mesh color. | |
void | get_mesh_color (float &r, float &g, float &b, float &a) const |
Gets the mesh color. | |
void | set_surface_color (float r, float g, float b, float a=1.0f) |
Sets the surface color. | |
void | get_surface_color (float &r, float &g, float &b, float &a) const |
Gets the surface color. | |
void | set_backface_surface_color (float r, float g, float b, float a=1.0f) |
Sets the surface color for backfacing faces. | |
void | set_cells_color (float r, float g, float b, float a=1.0f) |
Sets the color used to display mesh cells. | |
void | get_cells_color (float &r, float &g, float &b, float &a) const |
Gets the cells color. | |
void | set_cells_colors_by_type () |
Sets a different color for each mesh cell type. | |
bool | get_lighting () const |
Gets the lighing flag. | |
void | set_lighting (bool x) |
Sets the lighting flag. | |
void | set_mesh (const Mesh *M) |
Sets the mesh. | |
const Mesh * | mesh () const |
Gets the mesh. | |
void | set_picking_mode (MeshElementsFlags what) |
Sets picking mode. | |
MeshElementsFlags | get_picking_mode () const |
Gets the current picking mode. | |
void | set_object_picking_id (index_t id) |
Sets the object-wide picking id. | |
index_t | get_object_picking_id () const |
Gets the object-wide picking id. | |
void | set_vertices_selection (const std::string &name) |
Sets the vertices selection. | |
const std::string & | get_vertices_selection () const |
Gets the vertices selection. | |
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 | 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 | unset_scalar_attribute () |
Unsets scalar attribute display. | |
void | set_filter (MeshElementsFlags subelements, const std::string &name="filter") |
Sets primitive filtering. | |
void | unset_filters () |
Unset primitive filtering. | |
void | cleanup () |
Deallocates OpenGL objects. | |
Protected Member Functions | |
void | draw_vertices_array () |
void | draw_vertices_immediate_plain () |
void | draw_vertices_immediate_attrib () |
void | draw_vertices_selection () |
void | draw_edges_array () |
void | draw_edges_immediate_plain () |
void | draw_edges_immediate_attrib () |
void | draw_triangles () |
void | draw_triangles_array () |
void | draw_triangles_immediate_plain () |
void | draw_triangles_immediate_attrib () |
void | draw_quads () |
void | draw_quads_array () |
void | draw_quads_immediate_plain () |
void | draw_quads_immediate_attrib () |
void | draw_triangles_and_quads () |
void | draw_triangles_and_quads_array () |
void | draw_triangles_and_quads_immediate_plain () |
void | draw_triangles_and_quads_immediate_attrib () |
void | draw_polygons () |
void | draw_polygons_plain () |
void | draw_polygons_attrib () |
void | draw_tets () |
void | draw_tets_array () |
void | draw_tets_immediate_plain () |
void | draw_tets_immediate_attrib () |
void | draw_hybrid () |
void | draw_hybrid_array () |
void | draw_hybrid_immediate_plain () |
void | draw_hybrid_immediate_attrib () |
void | set_cells_color (MeshCellType type, float r, float g, float b) |
void | draw_attribute_as_tex_coord (index_t element) |
void | draw_vertex_with_attribute (index_t vertex) |
void | draw_surface_vertex_with_attribute (index_t vertex, index_t facet, index_t corner) |
void | draw_volume_vertex_with_attribute (index_t vertex, index_t cell, index_t cell_corner) |
void | draw_vertex (index_t v) |
void | draw_surface_mesh_with_lines () |
void | set_GLUP_parameters () |
Sets GLUP drawing parameters. | |
void | set_GLUP_picking (MeshElementsFlags what) |
Sets GLUP picking mode for drawing primitives of a given type, or deactivates GLUP picking if MeshGfx picking mode is deactivated. | |
void | set_GLUP_vertex_color_from_picking_id (index_t id) |
Encodes an id as the current vertex color. | |
void | update_buffer_objects_if_needed () |
Updates the Vertex Buffer Objects and Vertex Array Objects. | |
void | update_attribute_buffer_objects_if_needed () |
Updates the buffer objects used to display attributes. | |
void | bind_attribute_buffer_object (GLuint VAO) |
Binds the attribute buffer object to a Vertex Array Object. | |
void | unbind_attribute_buffer_object (GLuint VAO) |
Unbinds the attribute buffer object from a Vertex Array Object. | |
void | bind_vertices_VBO () |
Binds the vertices VBO to the current VAO. | |
void | begin_attributes () |
Setups drawing for attributes. | |
void | end_attributes () |
Deactivates drawing for attributes. | |
bool | can_use_array_mode (GLUPprimitive prim) const |
Tests whether array mode can be used to draw a specified GLUP primitive. | |
void | update_surface_elements () |
void | update_volume_elements () |
bool | hw_filtering_supported () const |
Tests whether hardware primitive filtering is supported. | |
void | draw_sequences (const MeshSubElementsStore &elements, std::function< void(index_t, index_t)> draw) |
Generic function to extract element sequences to draw. | |
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. | |
Draws a mesh using OpenGL.
Definition at line 60 of file mesh_gfx.h.
|
protected |
Setups drawing for attributes.
If no attribute is bound, does nothing.
|
protected |
Binds the attribute buffer object to a Vertex Array Object.
[in] | VAO | one of vertices_VAO_, edges_VAO_, facets_VAO_ or cells_VAO_. If zero, the function does nothing. |
|
protected |
Tests whether array mode can be used to draw a specified GLUP primitive.
[in] | prim | the GLUP primitive |
|
inlineprotected |
Definition at line 693 of file mesh_gfx.h.
|
inlineprotected |
Generic function to extract element sequences to draw.
Tests the filter if set, and finds all intervals of primitives to render. For each interval, it calls glupBasePickingId(GLUPuint64(begin)) so that picking Ids are correct.
[in] | elements | the MeshSubElementsStore to render |
[in] | draw | the function to be called for each (begin,end) sequence of elements to be drawn, where begin is the index of the first element, and end one position past the index of the last element. |
Definition at line 1027 of file mesh_gfx.h.
|
inlineprotected |
Generic function to extract element sequences to draw.
Tests the filter if set, and finds all intervals of primitives to render. For each interval, it calls glupBasePickingId(GLUPuint64(begin)) so that picking Ids are correct.
[in] | elements | the MeshSubElementsStore to render |
[in] | predicate | a function that tests which elements should be drawn or not |
[in] | draw | the function to be called for each (begin,end) sequence of elements to be drawn, where begin is the index of the first element, and end one position past the index of the last element. |
Definition at line 1081 of file mesh_gfx.h.
|
inlineprotected |
Definition at line 723 of file mesh_gfx.h.
|
inlineprotected |
Definition at line 749 of file mesh_gfx.h.
|
inlineprotected |
Definition at line 716 of file mesh_gfx.h.
void GEO::MeshGfx::draw_vertices | ( | ) |
Draws the vertices of the mesh.
If a vertices selection is set, only the vertices in the selection are drawn
|
inlineprotected |
Definition at line 736 of file mesh_gfx.h.
|
inline |
Gets the animate flag.
When animate mode is activated and the mesh has 6d vertices, then an animation is displayed. The first three coordinates correspond to the vertex position at initial time (t=0). The last three coordinates correspond to the vertex position at final time (t=1).
true | if animation is used |
false | otherwise |
Definition at line 224 of file mesh_gfx.h.
|
inline |
Gets the cells color.
[out] | r,g,b,a | the components of the cells color, in (0.0 .. 1.0) |
Definition at line 438 of file mesh_gfx.h.
|
inline |
Gets the cell visibility flag.
It is possible to specify cell visibility flags for each individual cell type.
[in] | type | one of MESH_TET, MESH_HEX, MESH_PRISM, MESH_PYRAMID |
true | if the cells of type should be displayed |
false | otherwise |
Definition at line 277 of file mesh_gfx.h.
|
inline |
Gets the lighing flag.
true | if lighting should be used |
false | otherwise |
Definition at line 468 of file mesh_gfx.h.
|
inline |
Gets the mesh border width.
The mesh border width is the one used by draw_surface_borders()
Definition at line 169 of file mesh_gfx.h.
|
inline |
Gets the mesh color.
[out] | r,g,b,a | the components of the mesh color, in (0.0 .. 1.0) |
Definition at line 360 of file mesh_gfx.h.
|
inline |
Gets the mesh width.
The mesh width is taken into account when the mesh visibility flag is set (by set_show_mesh()), when drawing facets and cells.
Definition at line 147 of file mesh_gfx.h.
|
inline |
Gets the object-wide picking id.
Definition at line 538 of file mesh_gfx.h.
|
inline |
Gets the current picking mode.
Definition at line 517 of file mesh_gfx.h.
|
inline |
Gets the points color.
[out] | r,g,b,a | the components of the points color, in (0.0 .. 1.0) |
Definition at line 314 of file mesh_gfx.h.
|
inline |
Gets the point size.
Definition at line 335 of file mesh_gfx.h.
|
inline |
Gets the mesh visibility flag.
The mesh visibility flags specifies whether mesh edges should be drawn. The used color can be specified by set_mesh_color()
true | if mesh edges should be displayed |
false | otherwise |
Definition at line 120 of file mesh_gfx.h.
|
inline |
Gets the cells shrink coefficient.
The cells shrink coefficient is used to display cells slighly smaller than what they are. Cells shrinking is only supported in GLSL mode.
Definition at line 191 of file mesh_gfx.h.
|
inline |
Gets the surface color.
[out] | r,g,b,a | the components of the surface color, in (0.0 .. 1.0) |
Definition at line 393 of file mesh_gfx.h.
|
inline |
Gets the time of the animation.
Used if animate mode is set.
Definition at line 249 of file mesh_gfx.h.
|
inline |
Gets the vertices selection.
Definition at line 559 of file mesh_gfx.h.
|
protected |
Tests whether hardware primitive filtering is supported.
On some higher profiles (GLUP150, GLUP440), it is possible to filter primitives in the shaders. It reduces GPU transfers by making it possible to reuse the same VBOs even when the list of objects to display changes.
|
inline |
Gets the mesh.
Definition at line 492 of file mesh_gfx.h.
|
inline |
Gets the animate flag.
When animate mode is activated and the mesh has 6d vertices, then an animation is displayed. The first three coordinates correspond to the vertex position at initial time (t=0). The last three coordinates correspond to the vertex position at final time (t=1).
[in] | x | true if animation should be used, false otherwise |
Definition at line 238 of file mesh_gfx.h.
|
inline |
Sets the surface color for backfacing faces.
Specifies the color used to display the backfaces of the surfacic part of the mesh.
[in] | r,g,b,a | the components of the surface color, in (0.0 .. 1.0) |
Definition at line 408 of file mesh_gfx.h.
|
inline |
Sets the color used to display mesh cells.
[in] | r,g,b,a | the components of the cells color, in (0.0 .. 1.0) |
Definition at line 423 of file mesh_gfx.h.
|
inlineprotected |
Definition at line 687 of file mesh_gfx.h.
|
inline |
Sets a different color for each mesh cell type.
it uses the following colors:
Definition at line 454 of file mesh_gfx.h.
|
inline |
Sets the cell visibility flag.
It is possible to specify cell visibility flags for each individual cell type.
[in] | type | one of MESH_TET, MESH_HEX, MESH_PRISM, MESH_PYRAMID |
[in] | x | true if mesh cells of type type should be displayed, false otherwise. |
Definition at line 290 of file mesh_gfx.h.
void GEO::MeshGfx::set_filter | ( | MeshElementsFlags | subelements, |
const std::string & | name = "filter" |
||
) |
Sets primitive filtering.
Primitive filtering deactivates display of some primitives based on their id and an attribute. The attribute is of type Numeric::uint8. If the attribute value is zero, then the corresponding primitive is not displayed.
[in] | subelements | one of MESH_VERTICES, MESH_FACETS, MESH_CELLS, MESH_ALL_ELEMENTS |
[in] | name | the name of the attribute with the filter. Default is "filter" |
|
protected |
Sets GLUP picking mode for drawing primitives of a given type, or deactivates GLUP picking if MeshGfx picking mode is deactivated.
[in] | what | one of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_CELLS. |
|
protected |
Encodes an id as the current vertex color.
This is required for drawing polygons, that cannot use standard GLUP primitives and picking.
|
inline |
Sets the lighting flag.
[in] | x | true if lighting should be used, false otherwise. |
Definition at line 477 of file mesh_gfx.h.
void GEO::MeshGfx::set_mesh | ( | const Mesh * | M | ) |
Sets the mesh.
[in] | M | a pointer to the mesh that should be displayed. |
|
inline |
Sets the mesh border width.
The mesh border width is the one used by draw_surface_borders()
[in] | x | the mesh width (minimum is 1) |
Definition at line 179 of file mesh_gfx.h.
|
inline |
Sets the mesh color.
Specifies the mesh color to be used if mesh edges should be displayed.
[in] | r,g,b,a | the components of the mesh color, in (0.0 .. 1.0) |
Definition at line 347 of file mesh_gfx.h.
|
inline |
Sets the mesh width.
The mesh width is taken into account when the mesh visibility flag is set (by set_show_mesh()), when drawing facets and cells.
[in] | x | the mesh width (minimum is 1) |
Definition at line 159 of file mesh_gfx.h.
|
inline |
Sets the object-wide picking id.
When the object-wide picking id is set, it is used to draw all primitives in the picking buffer.
[in] | id | the object-wide picking id, or index_t(-1) if normal per-primitive picking should be used. |
Definition at line 529 of file mesh_gfx.h.
|
inline |
Sets picking mode.
If picking mode is MESH_NONE, then normal drawing is activated, else the color is replaced with the index of the elements.
[in] | what | a bitwise or ('|') combination of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_CELLS, or MESH_NONE if picking mode should be deactivated |
Definition at line 507 of file mesh_gfx.h.
|
inline |
Sets the points color.
Specifies the color used to display points
[in] | r,g,b,a | the components of the points color, in (0.0 .. 1.0) |
Definition at line 301 of file mesh_gfx.h.
|
inline |
Sets the point size.
[in] | x | the point size (minimum 1) |
Definition at line 326 of file mesh_gfx.h.
void GEO::MeshGfx::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.
[in] | subelements | one of MESH_VERTICES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_CORNERS, MESH_CELL_FACETS |
[in] | name | name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
[in] | attr_min | value of the attribute that is bound to the leftmost color in the colormap |
[in] | attr_max | value of the attribute that is bound to the rightmost color in the colormap |
[in] | colormap_texture | the texture to be used to display the attribute colors |
[in] | repeat | the number of times the colorramp should be repeated within the specified range. |
|
inline |
Sets the mesh visibility flag.
[in] | x | the new value of the mesh visibility flag. |
The mesh visibility flags specifies whether mesh edges should be drawn. The used color can be specified by set_mesh_color()
Definition at line 135 of file mesh_gfx.h.
|
inline |
Sets the cells shrink coefficient.
The cells shrink coefficient is used to display cells slighly smaller than what they are. Cells shrinking is only supported in GLSL mode.
[in] | x | the cells shrink coefficient, betwe 0.0 (no shrink) and 1.0 (full shrink) |
Definition at line 203 of file mesh_gfx.h.
|
inline |
Sets the surface color.
Specifies the color used to display the surfacic part of the mesh. It specifies the color of both frontfacing and backfacing faces.
[in] | r,g,b,a | the components of the surface color, in (0.0 .. 1.0) |
Definition at line 376 of file mesh_gfx.h.
void GEO::MeshGfx::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.
[in] | subelements | the subelements that have texture coordinates. |
[in] | attribute_name | the name of the attribute that has the texture coordinates. Can be a 2d or 3d vector attribute. |
[in] | texture | the texture. |
[in] | repeat | the number of times the texture should be repeated in the unit square in texture space. |
|
inline |
Gets the time of the animation.
Used if animate mode is set.
[in] | x | the time of the animation, betwe 0.0 (initial) and 1.0 (final) |
Definition at line 260 of file mesh_gfx.h.
|
inline |
Sets the vertices selection.
If set, the vertices selection is used to determine which vertices should be drawn by draw_vertices().
[in] | name | the name of a Property<bool> bound to the vertices of the mesh. |
Definition at line 550 of file mesh_gfx.h.
|
protected |
Unbinds the attribute buffer object from a Vertex Array Object.
[in] | VAO | one of vertices_VAO_, edges_VAO_, facets_VAO_ or cells_VAO_. If zero, the function does nothing. |
|
inline |
Unsets scalar attribute display.
Definition at line 611 of file mesh_gfx.h.
|
protected |
Updates the buffer objects used to display attributes.
The buffer objects are updated if attribute_buffer_objects_dirty_ is set, then attribute_buffer_objects_dirty_ is reset. If attribute_buffer_objects_dirty_ is not set, it checks whether the sizes of the buffer objects match the size of the mesh arrays.
|
protected |
Updates the Vertex Buffer Objects and Vertex Array Objects.
The buffer objects are updated if buffer_objects_dirty_ is set, then buffer_objects_dirty_ is reset. If buffer_objects_dirty_ is not set, it checks whether the sizes of the buffer objects match the size of the mesh arrays.
|
protected |
Definition at line 893 of file mesh_gfx.h.
|
protected |
Definition at line 936 of file mesh_gfx.h.
|
protected |
Definition at line 938 of file mesh_gfx.h.
|
protected |
Definition at line 937 of file mesh_gfx.h.
|
protected |
Definition at line 935 of file mesh_gfx.h.
|
protected |
Definition at line 941 of file mesh_gfx.h.
|
protected |
Definition at line 934 of file mesh_gfx.h.
|
protected |
Definition at line 939 of file mesh_gfx.h.
|
protected |
Definition at line 940 of file mesh_gfx.h.
|
protected |
Definition at line 920 of file mesh_gfx.h.
|
protected |
Definition at line 901 of file mesh_gfx.h.
|
protected |
Definition at line 919 of file mesh_gfx.h.
|
protected |
Definition at line 931 of file mesh_gfx.h.
|
protected |
Definition at line 902 of file mesh_gfx.h.
|
protected |
Definition at line 903 of file mesh_gfx.h.
|
protected |
Definition at line 1004 of file mesh_gfx.h.
|
protected |
Definition at line 926 of file mesh_gfx.h.
|
protected |
Definition at line 912 of file mesh_gfx.h.
|
protected |
Definition at line 895 of file mesh_gfx.h.
|
protected |
Definition at line 929 of file mesh_gfx.h.
|
protected |
Definition at line 924 of file mesh_gfx.h.
|
protected |
Definition at line 944 of file mesh_gfx.h.
|
protected |
Definition at line 930 of file mesh_gfx.h.
|
protected |
Definition at line 1003 of file mesh_gfx.h.
|
protected |
Definition at line 925 of file mesh_gfx.h.
|
protected |
Definition at line 917 of file mesh_gfx.h.
|
protected |
Definition at line 905 of file mesh_gfx.h.
|
protected |
Definition at line 921 of file mesh_gfx.h.
|
protected |
Definition at line 914 of file mesh_gfx.h.
|
protected |
Definition at line 891 of file mesh_gfx.h.
|
protected |
Definition at line 899 of file mesh_gfx.h.
|
protected |
Definition at line 890 of file mesh_gfx.h.
|
protected |
Definition at line 908 of file mesh_gfx.h.
|
protected |
Definition at line 907 of file mesh_gfx.h.
|
protected |
Definition at line 898 of file mesh_gfx.h.
|
protected |
Definition at line 896 of file mesh_gfx.h.
|
protected |
Definition at line 916 of file mesh_gfx.h.
|
protected |
Definition at line 942 of file mesh_gfx.h.
|
protected |
Definition at line 889 of file mesh_gfx.h.
|
protected |
Definition at line 892 of file mesh_gfx.h.
|
protected |
Definition at line 900 of file mesh_gfx.h.
|
protected |
Definition at line 943 of file mesh_gfx.h.
|
protected |
Definition at line 894 of file mesh_gfx.h.
|
protected |
Definition at line 915 of file mesh_gfx.h.
|
protected |
Definition at line 932 of file mesh_gfx.h.
|
protected |
Definition at line 1002 of file mesh_gfx.h.
|
protected |
Definition at line 910 of file mesh_gfx.h.
|
protected |
Definition at line 923 of file mesh_gfx.h.
|
protected |
Definition at line 928 of file mesh_gfx.h.