Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
simple_mesh_application.h
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 H_GEOGRAM_GFX_GUI_SIMPLE_MESH_APPLICATION_H
41#define H_GEOGRAM_GFX_GUI_SIMPLE_MESH_APPLICATION_H
42
44#include <geogram_gfx/gui/simple_application.h>
46
47namespace GEO {
48
53 public:
57 SimpleMeshApplication(const std::string& name);
58
59 protected:
60
64 void geogram_initialize(int argc, char** argv) override;
65
69 std::string supported_read_file_extensions() override;
70
74 std::string supported_write_file_extensions() override;
75
79 void draw_object_properties() override;
80
84 void draw_scene() override;
85
89 void GL_initialize() override;
90
94 void GL_terminate() override;
95
99 bool load(const std::string& filename) override;
100
104 bool save(const std::string& filename) override;
105
111 SimpleMeshApplication* result =
112 dynamic_cast<SimpleMeshApplication*>(
113 SimpleApplication::instance()
114 );
115 geo_assert(result != nullptr);
116 return result;
117 }
118
119 protected:
120
126 virtual void draw_points();
127 virtual void draw_edges();
128 virtual void draw_surface();
129 virtual void draw_volume();
130
142 const Mesh& M_in, double* xyzmin, double* xyzmax, bool animate
143 );
144
150
156
162
168
169 protected:
170
176 return &mesh_;
177 }
178
184 return &mesh_gfx_;
185 }
186
191 show_vertices_ = true;
192 }
193
198 show_vertices_ = false;
199 }
200
205 show_surface_ = true;
206 }
207
212 show_surface_ = false;
213 }
214
218 void show_volume() {
219 show_volume_ = true;
220 }
221
225 void hide_volume() {
226 show_volume_ = false;
227 }
228
232 virtual void show_attributes();
233
237 virtual void hide_attributes();
238
243 void autorange();
244
249 std::string attribute_names();
250
256 void set_attribute(const std::string& attribute);
257
258 protected:
259 Mesh mesh_;
260 MeshGfx mesh_gfx_;
261
262 float anim_speed_;
263 float anim_time_;
264
265 bool show_vertices_;
266 bool show_vertices_selection_;
267 float vertices_size_;
268 vec4f vertices_color_;
269 float vertices_transparency_;
270
271 bool show_surface_;
272 bool show_surface_sides_;
273 bool show_mesh_;
274 float mesh_width_;
275 vec4f mesh_color_;
276
277 bool show_surface_borders_;
278 vec4f surface_color_;
279 vec4f surface_color_2_;
280
281 bool show_volume_;
282 float cells_shrink_;
283 vec4f volume_color_;
284 bool show_colored_cells_;
285 bool show_hexes_;
286 bool show_connectors_;
287
288 bool show_attributes_;
289 index_t current_colormap_index_;
290 std::string attribute_;
291 MeshElementsFlags attribute_subelements_;
292 std::string attribute_name_;
293 float attribute_min_;
294 float attribute_max_;
295 };
296
297 /*****************************************************************/
298}
299
300#endif
#define geo_assert(x)
Verifies that a condition is met.
Definition assert.h:149
Draws a mesh using OpenGL.
Definition mesh_gfx.h:60
Represents a mesh.
Definition mesh.h:2648
An Application that manipulates a single Mesh.
void hide_surface()
Makes the surface facets invisible.
static SimpleMeshApplication * instance()
Gets the instance.
void get_bbox(const Mesh &M_in, double *xyzmin, double *xyzmax, bool animate)
Gets the bounding box of a mesh animation.
void GL_terminate() override
Deallocates OpenGL and GLUP objects.
void GL_initialize() override
Initializes OpenGL and GLUP objects.
virtual void show_attributes()
Makes the attributes visible.
void autorange()
Adjusts the current minimum and maximum attribute value to the currently bound attribute if any.
std::string supported_write_file_extensions() override
Gets the list of supported file extensions for writing.
static void increment_cells_shrink_callback()
increments the cells shrinkage.
void hide_vertices()
Makes the vertices invisible.
MeshGfx * mesh_gfx()
Gets the mesh graphics.
SimpleMeshApplication(const std::string &name)
Application constructor.
bool save(const std::string &filename) override
Saves the current content to a file.
virtual void draw_points()
Called at the beginning of draw_scene().
std::string attribute_names()
Gets the list of attribute names.
static void decrement_cells_shrink_callback()
decrements the cells shrinkage.
void show_volume()
Makes the volume cells visible.
static void decrement_anim_time_callback()
derements the animation time in the current instance.
void show_vertices()
Makes the vertices visible.
void geogram_initialize(int argc, char **argv) override
std::string supported_read_file_extensions() override
Gets the list of supported file extensions for reading.
void hide_volume()
Makes the volume cells invisible.
void draw_object_properties() override
Draws the contents of the object properties window.
bool load(const std::string &filename) override
Loads a file.
void show_surface()
Makes the surface facets visible.
void set_attribute(const std::string &attribute)
Sets the currently displayed attribute.
void draw_scene() override
Draws the scene.
virtual void hide_attributes()
Makes the attributes invisible.
static void increment_anim_time_callback()
increments the animation time in the current instance.
#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...
A class to display a mesh using OpenGL/GLUP.
Global Vorpaline namespace.
Definition algorithm.h:64
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:287