40 #ifdef RINGMESH_WITH_GRAPHICS 42 #include <geogram_gfx/glup_viewer/glup_viewer_gui.h> 56 class RINGMESH_API RINGMeshApplication :
public GEO::Application
61 enum struct ViewerType
69 RINGMeshApplication(
int argc,
char** argv );
70 ~RINGMeshApplication() =
default;
75 static RINGMeshApplication* instance();
77 std::string supported_read_file_extensions()
override;
78 std::string supported_geogram_read_file_extensions();
79 void init_graphics()
override;
80 bool load(
const std::string& filename )
override;
81 void draw_scene()
override;
82 void draw_object_properties()
override;
83 void draw_viewer_properties()
override;
84 void draw_application_menus()
override;
86 bool load_geogram(
const std::string& filename );
87 bool can_load_geogram(
const std::string& filename );
88 void browse_geogram(
const std::string& path );
89 void update_region_of_interest();
91 static void show_color_table_popup( ImColor& color );
94 void create_point( std::string name =
"debug",
99 void create_aabbox( std::string name =
"box",
108 template < index_t DIMENSION >
109 class GeoModelViewerBase
116 OldNewStatus& operator=(
bool value )
122 bool need_to_update()
const 124 return old_status != new_status;
128 old_status = new_status;
130 bool old_status{
false };
131 bool new_status{
false };
137 bool visible_vertices_{
false };
138 ImColor vertex_color_;
139 int vertex_size_{ 1 };
144 RINGMeshApplication& app,
const std::string& filename );
145 virtual ~GeoModelViewerBase() =
default;
147 virtual void draw_scene();
148 virtual void draw_object_properties();
149 void draw_viewer_properties();
150 void draw_colormap();
152 void reset_attribute_name();
153 void set_attribute_names(
const std::vector< std::string >& names );
155 void draw_entity_style_editor(
156 const std::string& label, EntityStyle& style );
157 void draw_entity_vertex_style_editor(
158 const std::string& label, EntityStyle& style );
159 void update_entity_visibility();
160 virtual void update_all_entity_visibility(
bool value );
162 void toggle_corner_visibility( index_t corner_id );
163 void toggle_line_and_boundaries_visibility( index_t line_id );
164 void toggle_surface_and_boundaries_visibility( index_t surface_id );
165 void toggle_geological_entity_visibility(
166 const gmge_id& entity_id );
167 virtual void toggle_mesh_entity_and_boundaries_visibility(
168 const gmme_id& entity_id );
170 virtual ViewerType type() = 0;
173 RINGMeshApplication& app_;
174 bool is_visible_{
true };
175 GeoModel< DIMENSION > GM_;
176 GeoModelGfx< DIMENSION > GM_gfx_;
177 Box< DIMENSION > bbox_;
178 std::vector< std::string > entity_types_;
179 int selected_entity_type_{ 0 };
180 int selected_entity_id_{ 0 };
182 bool show_corners_{
true };
183 EntityStyle corner_style_;
184 bool show_lines_{
true };
185 EntityStyle line_style_;
186 bool show_surface_{
true };
187 EntityStyle surface_style_;
188 bool show_voi_{
false };
189 bool show_colormap_{
false };
191 bool mesh_visible_{
true };
193 bool show_attributes_{
false };
194 float attribute_min_{ 0 };
195 float attribute_max_{ 0 };
200 template < index_t DIMENSION >
201 class GeoModelViewer final :
public GeoModelViewerBase< DIMENSION >
212 MeshViewer( RINGMeshApplication& app,
const std::string& filename );
213 ~MeshViewer() =
default;
215 void draw_object_properties();
219 std::string attribute_names();
220 void set_attribute(
const std::string& attribute );
223 RINGMeshApplication& app_;
224 bool is_visible_{
true };
226 GEO::MeshGfx mesh_gfx_;
230 bool show_vertices_{
false };
231 float vertices_size_{ 1 };
232 ImColor vertices_color_;
234 bool show_surface_{
true };
235 bool show_surface_colors_{
true };
236 bool show_mesh_{
true };
237 bool show_surface_borders_{
false };
239 bool show_volume_{
false };
240 float cells_shrink_{ 0 };
241 bool show_colored_cells_{
false };
242 bool show_hexes_{
true };
244 bool show_attributes_{
false };
245 GLuint current_colormap_texture_{ 0 };
246 std::string attribute_ = std::string{
"vertices.point_fp32[0]" };
247 GEO::MeshElementsFlags attribute_subelements_{ GEO::MESH_VERTICES };
248 std::string attribute_name_;
249 float attribute_min_{ 0 };
250 float attribute_max_{ 0 };
253 template < index_t DIMENSION >
254 void draw_geomodel_viewer_properties(
255 std::vector< std::unique_ptr< GeoModelViewer< DIMENSION > > >&
260 std::vector< std::unique_ptr< GeoModelViewer3D > > geomodels3d_;
261 std::vector< std::unique_ptr< GeoModelViewer2D > > geomodels2d_;
262 std::vector< std::unique_ptr< MeshViewer > > meshes_;
263 std::string ringmesh_file_extensions_;
264 std::string geogram_file_extensions_;
265 index_t current_viewer_{ NO_ID };
268 static std::vector< std::vector< ImColor > > color_table_;
272 class RINGMeshApplication::GeoModelViewer< 2 > final
273 :
public GeoModelViewerBase< 2 >
276 GeoModelViewer( RINGMeshApplication& app,
const std::string& filename );
277 ViewerType type()
override 279 return ViewerType::GEOMODEL2D;
284 class RINGMeshApplication::GeoModelViewer< 3 > final
285 :
public GeoModelViewerBase< 3 >
288 GeoModelViewer( RINGMeshApplication& app,
const std::string& filename );
289 ViewerType type()
override 291 return ViewerType::GEOMODEL3D;
294 void draw_scene()
override;
295 void draw_object_properties()
override;
296 void update_all_entity_visibility(
bool value )
override;
298 void toggle_colored_cells();
299 void toggle_colored_regions();
300 void toggle_colored_layers();
301 void toggle_region_and_boundaries_visibility( index_t region_id );
302 void toggle_mesh_entity_and_boundaries_visibility(
303 const gmme_id& entity_id )
override;
306 bool show_hex_{
true };
307 bool show_prism_{
true };
308 bool show_pyramid_{
true };
309 bool show_tetra_{
true };
312 bool meshed_regions_{
false };
313 bool show_volume_{
false };
314 EntityStyle volume_style_;
316 OldNewStatus colored_cells_;
317 OldNewStatus show_colored_regions_;
318 OldNewStatus show_colored_layers_;
#define ringmesh_disable_copy_and_move(Class)
Classes to build GeoModel from various inputs.