diff --git a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h index 75e772ac603e..8b22d30faa3c 100644 --- a/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h +++ b/Surface_mesh_topology/include/CGAL/draw_face_graph_with_paths.h @@ -15,7 +15,6 @@ #include -#include #include #include @@ -38,7 +37,7 @@ template { - Graphics_scene_options_face_graph_with_paths(std::size_t nbpaths): m_nbpaths(nbpaths) + Graphics_scene_options_face_graph_with_paths() { color_of_path=[](std::size_t i)->CGAL::IO::Color { @@ -47,14 +46,11 @@ struct Graphics_scene_options_face_graph_with_paths : }; draw_path=[](std::size_t)->bool - { return true; } + { return true; }; } std::function color_of_path; std::function draw_path; - -protected: - std::size_t m_nbpaths; }; namespace draw_function_for_lcc @@ -146,9 +142,9 @@ void compute_face(const Mesh& mesh, const typename Get_map::storage_type& lcc, typename Get_map::type::Dart_const_descriptor dh, CGAL::Graphics_scene& graphics_scene, - GSOptions& gs_options) + GSOptions& gso) { - if(!gs_options.draw_face(lcc, dh)) + if(!gso.draw_face(lcc, dh)) { return; } typedef typename Get_map::type LCC; @@ -170,8 +166,8 @@ void compute_face(const Mesh& mesh, } while(cur!=dh); - if(gs_options.colored_face(lcc, dh)) - { graphics_scene.face_begin(gs_options.face_color(lcc, dh)); } + if(gso.colored_face(lcc, dh)) + { graphics_scene.face_begin(gso.face_color(lcc, dh)); } else { graphics_scene.face_begin(); } @@ -192,12 +188,12 @@ template void compute_edge(const Mesh &mesh, const typename Get_map::storage_type& lcc, typename Get_map::type::Dart_const_descriptor dh, - typename Get_map::type::size_type aamark, + typename Get_map::type::size_type amark, CGAL::Graphics_scene& graphics_scene, - GSOptions& gs_options, + GSOptions& gso, bool draw_marked_darts=true) { - if(!gs_options.draw_edge(lcc, dh)) + if(!gso.draw_edge(lcc, dh)) { return; } typedef typename Get_map::type LCC; @@ -242,19 +238,18 @@ template void compute_vertex(const Mesh &mesh, typename Get_map::type::Dart_const_descriptor dh, CGAL::Graphics_scene& graphics_scene, - GSOptions& gs_options) + GSOptions& gso) { - typedef typename CGAL::Get_traits::Kernel Kernel; - typedef typename CGAL::Get_traits::Point Point; - typedef typename CGAL::Get_traits::Vector Vector; - graphics_scene.add_point(get_point(mesh, dh)); + if(gso.draw_vertex(mesh, dh)) + { graphics_scene.add_point(get_point(mesh, dh)); } } -template +template void compute_path(const Mesh &mesh, const typename Get_map::storage_type& lcc, CGAL::Graphics_scene &graphics_scene, - const std::vector>* m_paths, + const GSOptions &gso, + const std::vector>* paths, std::size_t i, typename Get_map::type::size_type amark) { @@ -263,19 +258,19 @@ void compute_path(const Mesh &mesh, typedef typename CGAL::Get_traits::Point Point; typedef typename CGAL::Get_traits::Vector Vector; - if ((*m_paths)[i].is_empty() || !gs_options.draw_path(i)) + if ((*paths)[i].is_empty() || !gso.draw_path(i)) { return; } CGAL::Random random(static_cast(i)); CGAL::IO::Color color = get_random_color(random); - graphics_scene.add_point(get_point(mesh, (*m_paths)[i].get_ith_dart(0)), color); - for (std::size_t j=0; j<(*m_paths)[i].length(); ++j) + graphics_scene.add_point(get_point(mesh, (*paths)[i].get_ith_dart(0)), color); + for (std::size_t j=0; j<(*paths)[i].length(); ++j) { - if ( !lcc.is_marked( (*m_paths)[i].get_ith_dart(j), amark) ) + if ( !lcc.is_marked( (*paths)[i].get_ith_dart(j), amark) ) { - compute_edge(mesh, lcc, (*m_paths)[i].get_ith_dart(j), color, mesh, graphics_scene, lcc); - lcc.template mark_cell<1>((*m_paths)[i].get_ith_dart(j), amark); + compute_edge(mesh, lcc, (*paths)[i].get_ith_dart(j), color, graphics_scene); + lcc.template mark_cell<1>((*paths)[i].get_ith_dart(j), amark); } } } @@ -283,9 +278,9 @@ void compute_path(const Mesh &mesh, template void compute_elements(const Mesh &mesh, CGAL::Graphics_scene &graphics_scene, - const GSOptions &m_gs_options, - const std::vector>* m_paths, - typename Get_map::type::size_type amark) + const GSOptions &gso, + const std::vector>* paths, + typename Get_map::type::size_type mark) { typedef typename Get_map::type LCC; typedef typename LCC::size_type size_type; @@ -295,27 +290,27 @@ void compute_elements(const Mesh &mesh, typedef typename CGAL::Get_traits::Vector Vector; typedef typename LCC::Dart_const_descriptor Dart_const_descriptor; - typename Get_map::storage_type alcc(mesh); - typename LCC::Dart_range::const_iterator m_current_dart = lcc.darts().end(); - typename LCC::size_type m_oriented_mark = lcc.get_new_mark(); - std::size_t m_current_path = m_paths->size(); - typename LCC::size_type amark=amark==(std::numeric_limits::max)()? - LCC::INVALID_MARK:amark; // If !=INVALID_MARK, show darts marked with this mark + typename Get_map::storage_type lcc(mesh); + typename LCC::Dart_range::const_iterator current_dart = lcc.darts().end(); + typename LCC::size_type oriented_mark = lcc.get_new_mark(); + std::size_t current_path = paths->size(); + typename LCC::size_type amark=mark==(std::numeric_limits::max)()? + LCC::INVALID_MARK:mark; // If !=INVALID_MARK, show darts marked with this mark - lcc.orient(m_oriented_mark); + lcc.orient(oriented_mark); typename LCC::size_type markfaces = lcc.get_new_mark(); typename LCC::size_type markedges = lcc.get_new_mark(); typename LCC::size_type markvertices = lcc.get_new_mark(); - if (m_current_dart!=lcc.darts().end()) + /* if (current_dart!=lcc.darts().end()) { // We want to draw only one dart - Dart_const_descriptor selected_dart=m_current_dart; //lcc.dart_handle(m_current_dart); + Dart_const_descriptor selected_dart=current_dart; //lcc.dart_handle(current_dart); compute_edge(selected_dart, CGAL::IO::Color(255,0,0), mesh, graphics_scene, lcc); lcc.template mark_cell<1>(selected_dart, markedges); compute_vertex(selected_dart, mesh, graphics_scene); - if ( !m_nofaces ) + if (gso.are_faces_enabled()) { compute_face(selected_dart, mesh, graphics_scene, lcc); } for (typename LCC::Dart_range::const_iterator it=lcc.darts().begin(), @@ -328,35 +323,35 @@ void compute_elements(const Mesh &mesh, } } } - else + else */ { - if (m_current_path==m_paths->size()) + if (current_path==paths->size()) { - for (std::size_t i=0; isize(); ++i) - { compute_path(i, markedges, mesh, graphics_scene, m_paths, lcc); } + for (std::size_t i=0; isize(); ++i) + { compute_path(mesh, lcc, graphics_scene, gso, paths, i, markedges); } } - else if (m_current_path!=m_paths->size()+1) - { compute_path(m_current_path, markedges, mesh, graphics_scene, m_paths, lcc); } + else if (current_path!=paths->size()+1) + { compute_path(mesh, lcc, graphics_scene, gso, paths, current_path, markedges); } for (typename LCC::Dart_range::const_iterator it=lcc.darts().begin(), itend=lcc.darts().end(); it!=itend; ++it ) { - if (!m_nofaces && !lcc.is_marked(it, markfaces) && - !lcc.is_perforated(it) && lcc.is_marked(it, m_oriented_mark)) + if (gso.are_faces_enabled() && !lcc.is_marked(it, markfaces) && + !lcc.is_perforated(it) && lcc.is_marked(it, oriented_mark)) { - compute_face(it, mesh, graphics_scene, lcc); + compute_face(mesh, lcc, it, graphics_scene, gso); lcc.template mark_cell<2>(it, markfaces); } if ( !lcc.is_marked(it, markedges) ) { - compute_edge(it, mesh, graphics_scene, lcc, amark, draw_marked_darts); + compute_edge(mesh, lcc, it, amark, graphics_scene, gso, draw_marked_darts); lcc.template mark_cell<1>(it, markedges); } if ( !lcc.is_marked(it, markvertices) ) { - compute_vertex(it, mesh, graphics_scene); + compute_vertex(mesh, it, graphics_scene, gso); lcc.template mark_cell<0>(it, markvertices); } } @@ -372,15 +367,13 @@ void compute_elements(const Mesh &mesh, template void add_to_graphics_scene(const Mesh& mesh, CGAL::Graphics_scene& graphics_scene, + const GSOptions& gso, const std::vector>* paths, - const GSOptions& gs_options, typename Get_map::type::size_type amark= typename Get_map::type::INVALID_MARK) { - draw_function_for_face_graph_with_paths::compute_elements(mesh, - graphics_scene, - gs_options, - paths, amark); + draw_function_for_face_graph_with_paths::compute_elements(mesh, graphics_scene, + gso, paths, amark); } template @@ -391,13 +384,13 @@ void add_to_graphics_scene(const Mesh& mesh, typename Get_map::type::INVALID_MARK) { // Default graphics view options. - Graphics_scene_options::type::Dart_const_descriptor /*vh*/, typename Get_map::type::Dart_const_descriptor /*eh*/, typename Get_map::type::Dart_const_descriptor /*fh*/> - gs_options; + gso; - add_to_graphics_scene(mesh, graphics_scene, gs_options, paths, amark); + add_to_graphics_scene(mesh, graphics_scene, gso, paths, amark); } #ifdef CGAL_USE_BASIC_VIEWER @@ -417,13 +410,13 @@ void draw(const Mesh& mesh, template void draw(const Mesh& mesh, const std::vector >& paths, - const GSOptions& gs_options, + const GSOptions& gso, typename Get_map::type::size_type amark= (std::numeric_limits::type::size_type>::max)(), const char* title="Mesh Viewer With Path") { CGAL::Graphics_scene buffer; - add_to_graphics_scene(mesh, buffer, gs_options, &paths, amark); + add_to_graphics_scene(mesh, buffer, gso, &paths, amark); draw_graphics_scene(buffer, title); }