40#ifndef H_OGF_MESH_GFX_SHADERS_MESH_GROB_SHADER_H
41#define H_OGF_MESH_GFX_SHADERS_MESH_GROB_SHADER_H
43#include <OGF/mesh_gfx/common/common.h>
68 enum CullingMode {NO_CULL, CULL_FRONT, CULL_BACK};
70 enum PaintingMode {SOLID_COLOR, ATTRIBUTE, COLOR, TEXTURE};
75 gom_attribute(abstract,
"true")
100 virtual void pick(MeshElementsFlags what);
163 bool get_has_edges()
const {
165 mesh_grob() !=
nullptr &&
166 mesh_grob()->edges.nb() != 0;
178 mesh_grob() !=
nullptr &&
179 mesh_grob()->facets.nb() != 0;
191 mesh_grob() !=
nullptr &&
192 mesh_grob()->cells.nb() != 0;
205 mesh_grob() !=
nullptr &&
206 mesh_grob()->cells.nb() != 0 &&
207 !mesh_grob()->cells.are_simplices();
222 mesh_grob() !=
nullptr &&
223 mesh_grob()->vertices.dimension() >= 6;
226 bool get_has_vertices_selection()
const {
227 return mesh_grob() !=
nullptr &&
228 mesh_grob()->vertices.attributes().is_defined(
"selection");
232 bool get_has_weird_cells()
const {
233 return mesh_grob() !=
nullptr &&
234 mesh_grob()->cells.attributes().is_defined(
"weird");
237 std::string get_scalar_attributes()
const {
239 if(mesh_grob() !=
nullptr) {
240 result = mesh_grob()->get_scalar_attributes();
245 std::string get_vector_attributes()
const {
247 if(mesh_grob() !=
nullptr) {
248 result = mesh_grob()->get_vector_attributes(3);
253 bool get_has_vertices_filter()
const {
255 mesh_grob()->vertices.nb() != 0 &&
256 mesh_grob()->vertices.attributes().is_defined(
"filter") ;
259 bool get_has_edges_filter()
const {
261 mesh_grob()->edges.nb() != 0 &&
262 mesh_grob()->edges.attributes().is_defined(
"filter") ;
265 bool get_has_facets_filter()
const {
267 mesh_grob()->facets.nb() != 0 &&
268 mesh_grob()->facets.attributes().is_defined(
"filter") ;
271 bool get_has_cells_filter()
const {
273 mesh_grob()->cells.nb() != 0 &&
274 mesh_grob()->cells.attributes().is_defined(
"filter") ;
283 return static_cast<MeshGrob*
>(grob());
313 void pick(MeshElementsFlags what)
override;
372 bool get_attributes()
const {
373 return (painting_mode_ == ATTRIBUTE);
381 gom_attribute(visible_if,
"attributes")
391 void set_time_smooth(
double x) {
412 void set_painting(PaintingMode value);
419 return painting_mode_;
427 gom_attribute(visible_if,
"attributes")
428 void set_attribute_min(
double value) {
429 attribute_min_ = value;
439 return attribute_min_;
447 gom_attribute(visible_if,
"attributes")
448 void set_attribute_max(
double value) {
449 attribute_max_ = value;
459 return attribute_max_;
467 gom_attribute(visible_if,
"attributes")
468 gom_attribute(handler, "combo_box")
469 gom_attribute(values, "$scalar_attributes")
470 void set_attribute(const std::
string& value);
476 const std::
string& get_attribute()
const {
484 gom_attribute(visible_if,
"attributes")
486 colormap_style_ = value;
487 colormap_texture_.reset();
492 return colormap_style_;
501 return (painting_mode_ == TEXTURE);
510 return (painting_mode_ == COLOR);
519 gom_attribute(visible_if,
"texturing")
521 texture_filename_ = value;
532 return texture_filename_;
539 gom_attribute(visible_if,
"texturing")
540 gom_attribute(handler, "combo_box")
541 gom_attribute(values, "$vector_attributes")
542 void set_tex_coords(const std::
string& value);
548 const std::
string& get_tex_coords()
const {
549 return tex_coord_attribute_;
557 gom_attribute(visible_if,
"coloring")
558 gom_attribute(handler, "combo_box")
559 gom_attribute(values, "$vector_attributes")
560 void set_colors(const std::
string& value) {
564 set_tex_coords(value);
575 return get_tex_coords();
583 gom_attribute(visible_if,
"texturing")
585 tex_coord_repeat_ = value;
595 return tex_coord_repeat_;
605 gom_attribute(visible_if,
"texturing")
606 void set_normal_map(
bool value) {
607 tex_normal_mapping_ = value;
617 return tex_normal_mapping_;
626 gfx_.set_lighting(value);
636 return gfx_.get_lighting();
666 gom_attribute(visible_if,
"has_facets")
668 surface_style_ = value;
677 return surface_style_;
684 gom_attribute(visible_if,
"has_facets_filter")
685 void set_facets_filter(
bool value) {
686 facets_filter_ = value;
688 MESH_FACETS, value ?
"filter" :
""
693 bool get_facets_filter()
const {
694 return facets_filter_;
701 gom_attribute(visible_if,
"has_facets")
702 void set_culling_mode(const CullingMode value) {
703 culling_mode_ = value;
712 return culling_mode_;
720 gom_attribute(visible_if,
"has_facets or has_cells")
745 gom_attribute(visible_if,
"has_facets")
746 void set_two_sided(
bool value) {
765 gom_attribute(visible_if,
"has_cells")
767 volume_style_ = value;
778 return volume_style_;
786 gom_attribute(visible_if,
"has_cells_filter")
787 void set_cells_filter(
bool value) {
789 MESH_CELLS, value ?
"filter" :
""
791 cells_filter_ = value;
795 bool get_cells_filter()
const {
796 return cells_filter_;
806 gom_attribute(visible_if,
"is_hybrid")
807 void set_colored_cells(
bool value) {
808 colored_cells_ = value;
818 return colored_cells_;
827 gom_attribute(visible_if,
"is_hybrid")
828 void set_tets(
bool value) {
847 gom_attribute(visible_if,
"is_hybrid")
848 void set_hexes(
bool value) {
868 gom_attribute(visible_if,
"is_hybrid")
869 void set_prisms(
bool value) {
889 gom_attribute(visible_if,
"is_hybrid")
890 void set_pyramids(
bool value) {
910 gom_attribute(visible_if,
"is_hybrid")
911 void set_connectors(
bool value) {
930 gom_attribute(visible_if,
"has_edges")
932 edges_style_ = value;
953 gom_attribute(visible_if,
"has_facets or has_cells")
977 gom_attribute(visible_if,
"has_facets")
979 border_style_ = value;
990 return border_style_;
999 vertices_style_ = value;
1009 return vertices_style_;
1017 gom_attribute(visible_if,
"has_vertices_filter")
1018 void set_vertices_filter(
bool value) {
1020 MESH_VERTICES, value ?
"filter" :
""
1022 vertices_filter_ = value;
1026 bool get_vertices_filter()
const {
1027 return vertices_filter_;
1034 gom_attribute(visible_if,
"has_edges_filter")
1035 void set_edges_filter(
bool value) {
1036 edges_filter_ = value;
1038 MESH_EDGES, value ?
"filter" :
""
1043 bool get_edges_filter()
const {
1044 return edges_filter_;
1054 gom_attribute(visible_if,
"has_vertices_selection")
1055 void set_vert_select_style(const PointStyle& value) {
1056 vertices_selection_style_ = value;
1065 return vertices_selection_style_;
1074 gom_attribute(visible_if,
"has_cells")
1076 gfx_.set_shrink(
double(value)/10.0);
1087 return index_t(gfx_.get_shrink()*10.0);
1101 gom_attribute(visible_if,
"has_time")
1102 void set_animate(
bool value) {
1126 gom_attribute(visible_if,
"has_time and animate")
1127 gom_attribute(handler, "slider_int")
1128 gom_attribute(min, "0")
1129 gom_attribute(max, "20")
1131 time_ = double(value) / 20.0;
1144 gom_attribute(visible_if,
"has_cells")
1145 void set_slivers(
double value) {
1150 double get_slivers()
const {
1154 gom_attribute(visible_if,
"has_weird_cells")
1155 void set_weird_cells(
bool x) {
1160 bool get_weird_cells()
const {
1161 return weird_cells_;
1164 bool get_glsl_source_visible()
const {
1168 gom_attribute(visible_if,
"glsl_source_visible")
1169 void set_glsl_source(const std::
string& value) {
1170 glsl_source_ = value;
1171 update_glsl_program();
1174 const std::string& get_glsl_source()
const {
1175 return glsl_source_;
1183 void draw_slivers();
1184 void draw_weird_cells();
1185 void draw_surface_with_glsl_shader();
1186 void update_glsl_program();
1191 PaintingMode painting_mode_;
1193 std::string attribute_;
1194 MeshElementsFlags attribute_subelements_;
1195 std::string attribute_name_;
1196 double attribute_min_;
1197 double attribute_max_;
1201 MeshElementsFlags tex_coord_subelements_;
1202 std::string tex_coord_attribute_;
1203 std::string tex_coord_name_;
1205 bool tex_normal_mapping_;
1210 bool facets_filter_;
1211 CullingMode culling_mode_;
1217 bool colored_cells_;
1228 bool vertices_filter_;
1238 bool glsl_program_changed_;
1239 double glsl_start_time_;
1241 std::string glsl_source_;
1242 GLuint glsl_program_;
1266 gom_attribute(handler,
"combo_box")
1267 gom_attribute(values, "$scalar_attributes")
1268 void set_region(const std::
string& value) {
1274 const std::string& get_region()
const {
1278 void set_amount(
index_t value) {
1292 std::string region_;
Draws a mesh using OpenGL.
Vector with aligned memory allocation.
Exploded view, moves regions apart.
void draw() override
Draws the Grob.
~ExplodedViewMeshGrobShader() override
PlainMeshGrobShader destructor.
ExplodedViewMeshGrobShader(MeshGrob *grob)
PlainMeshGrobShader constructor.
Base class for drawing and picking MeshGrob.
virtual void hide_borders()
Makes surface borders invisible and triggers a drawing event.
virtual void hide_vertices()
Makes vertices invisible and triggers a drawing event.
virtual void show_borders()
Makes surface borders visible and triggers a drawing event.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
MeshGrobShader(MeshGrob *grob)
MeshGrobShader constructor.
bool get_has_cells() const
Tests whether the MeshGrob attached to this shader has cells.
virtual void hide_mesh()
Makes the mesh invisible and triggers a drawing event.
virtual void show_mesh()
Makes the mesh visible and triggers a drawing event.
virtual void show_vertices()
Makes vertices visible and triggers a drawing event.
virtual void show_vertices_selection()
Makes vertices selection visible and triggers a drawing event.
virtual void pick(MeshElementsFlags what)
Picks an element of a mesh.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
bool get_has_time() const
Tests whether the MeshGrob attached to this shader stores a time evolution.
MeshGrob * mesh_grob() const
Gets the MeshGrob.
virtual void hide_vertices_selection()
Makes vertices selection invisible and triggers a drawing event.
bool get_is_hybrid() const
Tests whether the MeshGrob attached to this shader is a volumetric hybrid mesh.
void draw() override
Draws the Grob.
~MeshGrobShader() override
MeshGrobShader destructor.
bool get_has_facets() const
Tests whether the MeshGrob attached to this shader has facets.
A Grob wrapper around Geogram's Mesh class.
The default implementation of MeshGrobShader.
const SurfaceStyle & get_volume_style() const
Gets the style used to draw the volumetric cells.
~PlainMeshGrobShader() override
PlainMeshGrobShader destructor.
const EdgeStyle & get_mesh_style() const
Gets the style used to draw the mesh in the facets and in the cells.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
bool get_clipping() const
Gets whether clipping should be used.
index_t get_specular() const
Gets the current surface specular factor.
void hide_mesh() override
Makes the mesh invisible and triggers a drawing event.
bool get_tets() const
Tests whether tetrahedra are displayed.
void hide_borders() override
Makes surface borders invisible and triggers a drawing event.
bool get_texturing() const
Tests whether texturing is active.
void show_mesh() override
Makes the mesh visible and triggers a drawing event.
bool get_coloring() const
Tests whether coloring is active.
bool get_hexes() const
Tests whether hexahedra are displayed.
PlainMeshGrobShader(MeshGrob *grob)
PlainMeshGrobShader constructor.
PaintingMode get_painting() const
Gets painting mode.
void hide_vertices() override
Makes vertices invisible and triggers a drawing event.
index_t get_time() const
Gets the time parameter used for time interpolation.
const ImageFileName & get_tex_image() const
Gets the image used for texturing.
bool get_colored_cells() const
Tests whether volumetric cells are colored by type.
void show_borders() override
Makes surface borders visible and triggers a drawing event.
double get_attribute_min() const
Gets the minimum of the displayed range for attribute values.
void set_lighting(bool value)
Sets whether lighting should be used.
const EdgeStyle & get_edges_style() const
Gets the style used to draw the edges.
void show_vertices() override
Makes vertices visible and triggers a drawing event.
void draw() override
Draws the Grob.
const SurfaceStyle & get_surface_style() const
Gets the current surface drawing style.
bool get_lighting() const
Gets whether lighting is used.
index_t get_shrink() const
Gets the shrinking coefficient of the volumetric cells.
bool get_normal_map() const
Gets normal mapping mode.
void show_vertices_selection() override
Makes vertices selection visible and triggers a drawing event.
bool get_two_sided() const
Tests whether different colors are used for inside/outside.
void pick(MeshElementsFlags what) override
Picks an element of a mesh.
bool get_animate() const
Tests whether time interpolation should be used.
bool get_pyramids() const
Tests whether pyramids are displayed.
double get_attribute_max() const
Gets the maximum of the displayed range for attribute values.
const PointStyle & get_vert_select_style() const
Gets the vertices selection style.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
bool get_prisms() const
Tests whether prisms are displayed.
CullingMode get_culling_mode() const
Gets the current culling mode.
const std::string & get_colors() const
Gets the name of the displayed attribute.
bool get_connectors() const
Tests whether connectors are displayed.
double get_time_smooth() const
Gets the time as floating point parameter.
const PointStyle & get_vertices_style() const
Gets the style used to draw the vertices.
const EdgeStyle & get_border_style() const
Gets the style used to draw the border of the surface.
index_t get_tex_repeat() const
Gets the texture repeat factor.
void set_vertices_style(const PointStyle &value)
Sets the style used to draw the vertices.
void hide_vertices_selection() override
Makes vertices selection invisible and triggers a drawing event.
void set_transparency(Transparency x) override
Transparent rendering mode.
update()
Redraws the scene.
void set_clipping(bool value)
Sets whether clipping should be active.
Base class for Grob shader.
A class to display a mesh using OpenGL/GLUP.
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Global Graphite namespace.
The base class for all object shaders.
The style used to display colormapped colors.
Drawing style for mesh edges.
Drawing style for points.
Drawing style for polygons.