// Copyright (c) 1997 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), // and Tel-Aviv University (Israel). All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Guillaume Damiand // Mostafa Ashraf #ifndef CGAL_DRAW_POLYGON_2_H #define CGAL_DRAW_POLYGON_2_H #include #include #include #ifdef DOXYGEN_RUNNING namespace CGAL { /*! \ingroup PkgDrawPolygon2 opens a new window and draws `ap`, an instance of the `CGAL::Polygon_2` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires `CGAL_Qt5`, 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_Qt5` and add the definition `CGAL_USE_BASIC_VIEWER`. \tparam P an instance of the `CGAL::Polygon_2` class. \param ap the polygon to draw. */ template void draw(const P& ap); } /* namespace CGAL */ #endif #ifdef CGAL_USE_BASIC_VIEWER #include #include #include namespace CGAL { namespace draw_function_for_p2 { template void compute_elements(CGAL::Graphic_buffer &graphic_buffer, const P2 *p2) { typedef typename P2::Point_2 Point; if (p2->is_empty()) return; Point prev = p2->vertex(p2->size() - 1); CGAL::IO::Color c(75, 160, 255); graphic_buffer.face_begin(c); for (typename P2::Vertex_const_iterator i = p2->vertices_begin(); i != p2->vertices_end(); ++i) { graphic_buffer.add_point(*i); // Add vertex graphic_buffer.add_segment(prev, *i); // Add segment with previous point graphic_buffer.add_point_in_face(*i); // Add point in face prev = *i; } graphic_buffer.face_end(); } } // namespace draw_function_for_p2 template void add_in_graphic_buffer_p2(CGAL::Graphic_buffer &graphic_buffer, const P2 *p2 = nullptr) { if (p2 != nullptr) { draw_function_for_p2::compute_elements(graphic_buffer, p2); } } // Specialization of draw function. #define CGAL_P2_TYPE CGAL::Polygon_2 template void draw(const CGAL_P2_TYPE &ap2, const char *title = "Polygon_2 Basic Viewer") { // Drawing_functor // drawingFunctor; CGAL::Graphic_buffer buffer; add_in_graphic_buffer_p2(buffer, &ap2); draw_buffer(buffer); } } // End namespace CGAL #endif // CGAL_USE_BASIC_VIEWER #endif // CGAL_DRAW_POLYGON_2_H