// Copyright (c) 2018-2020 GeometryFactory (France) // All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Guillaume Damiand // Mostafa Ashraf #ifndef CGAL_DRAW_SURFACE_MESH_H #define CGAL_DRAW_SURFACE_MESH_H #ifdef DOXYGEN_RUNNING /*! \ingroup PkgDrawSurfaceMesh Open a new window and draw `asm`, an instance of the `CGAL::Surface_mesh` class. The function is blocking, that is the program continues as soon as the user closes the window. This function requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`. \tparam SM an instance of the `CGAL::Surface_mesh` class. \param asm the surface mesh to draw. */ template void draw(const SM& asm); #else // DOXYGEN_RUNNING #include #include #include #include #include #include namespace CGAL { // Check if there are any color maps that could be used template struct Graphics_scene_options_surface_mesh : public Graphics_scene_options, typename boost::graph_traits<::CGAL::Surface_mesh>::vertex_descriptor, typename boost::graph_traits<::CGAL::Surface_mesh>::edge_descriptor, typename boost::graph_traits<::CGAL::Surface_mesh>::face_descriptor> { using SM = ::CGAL::Surface_mesh; using vertex_descriptor = typename boost::graph_traits::vertex_descriptor; using edge_descriptor = typename boost::graph_traits::edge_descriptor; using face_descriptor = typename boost::graph_traits::face_descriptor; Graphics_scene_options_surface_mesh(const SM& amesh) { bool found=false; std::tie(vcolors, found)= amesh.template property_map("v:color"); if(found) { this->colored_vertex=[](const SM &, vertex_descriptor)->bool { return true; }; this->vertex_color=[this](const SM &, vertex_descriptor v)->CGAL::IO::Color { return get(vcolors, v); }; } else { this->colored_vertex=[](const SM &, vertex_descriptor)->bool { return false; }; } std::tie(ecolors, found)= amesh.template property_map("e:color"); if(found) { this->colored_edge=[](const SM &, edge_descriptor)->bool { return true; }; this->edge_color=[this](const SM &, edge_descriptor e)->CGAL::IO::Color { return get(ecolors, e); }; } else { this->colored_edge=[](const SM &, edge_descriptor)->bool { return false; }; } std::tie(fcolors, found)= amesh.template property_map("f:color"); if(found) { this->colored_face=[](const SM &, face_descriptor)->bool { return true; }; this->face_color=[this](const SM &, face_descriptor f)->CGAL::IO::Color { return get(fcolors, f); }; } else { this->colored_face=[](const SM &, face_descriptor)->bool { return false; }; } } private: typename SM::template Property_map vcolors; typename SM::template Property_map ecolors; typename SM::template Property_map fcolors; }; template void add_to_graphics_scene(const Surface_mesh& amesh, CGAL::Graphics_scene &graphics_scene, const GSOptions &gs_options) { add_to_graphics_scene_for_fg(amesh, graphics_scene, gs_options); } template void add_to_graphics_scene(const Surface_mesh& amesh, CGAL::Graphics_scene &graphics_scene) { add_to_graphics_scene_for_fg(amesh, graphics_scene, Graphics_scene_options_surface_mesh(amesh)); } #ifdef CGAL_USE_BASIC_VIEWER // Specialization of draw function. template void draw(const Surface_mesh& amesh, const char* title="Surface_mesh Basic Viewer") { CGAL::Graphics_scene buffer; add_to_graphics_scene(amesh, buffer); draw_graphics_scene(buffer, title); } template void draw(const Surface_mesh& amesh, const GSOptions &gs_options, const char* title="Surface_mesh Basic Viewer") { CGAL::Graphics_scene buffer; add_to_graphics_scene(amesh, buffer, gs_options); draw_graphics_scene(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER } // End namespace CGAL #endif // DOXYGEN_RUNNING #endif // CGAL_DRAW_SURFACE_MESH_H