From 4df2edd9c1248a72e92be81dd3a82e9a9557d5d5 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Fri, 28 Apr 2023 12:26:31 +0200 Subject: [PATCH] Replace draw_buffer by draw_graphic_storage --- .../doc/Basic_viewer/CGAL/Graphic_storage.h | 36 ++++++++++++++----- .../Basic_viewer/draw_mesh_and_points.cpp | 2 +- .../include/CGAL/Qt/Basic_viewer_qt.h | 4 +-- .../include/CGAL/draw_linear_cell_complex.h | 4 +-- Nef_3/include/CGAL/draw_nef_3.h | 4 +-- .../CGAL/draw_periodic_2_triangulation_2.h | 2 +- Point_set_3/include/CGAL/draw_point_set_3.h | 4 +-- Polygon/include/CGAL/draw_polygon_2.h | 4 +-- .../include/CGAL/draw_polygon_with_holes_2.h | 4 +-- Polyhedron/include/CGAL/draw_polyhedron.h | 4 +-- .../include/CGAL/draw_straight_skeleton_2.h | 4 +-- Surface_mesh/include/CGAL/draw_surface_mesh.h | 4 +-- .../include/CGAL/draw_face_graph_with_paths.h | 6 ++-- .../polygon_triangulation_drawing_functor.h | 2 +- .../include/CGAL/draw_triangulation_2.h | 4 +-- .../include/CGAL/draw_triangulation_3.h | 4 +-- .../include/CGAL/draw_voronoi_diagram_2.h | 2 +- 17 files changed, 57 insertions(+), 37 deletions(-) diff --git a/Basic_viewer/doc/Basic_viewer/CGAL/Graphic_storage.h b/Basic_viewer/doc/Basic_viewer/CGAL/Graphic_storage.h index de77b753e06..2f0b5901cc6 100644 --- a/Basic_viewer/doc/Basic_viewer/CGAL/Graphic_storage.h +++ b/Basic_viewer/doc/Basic_viewer/CGAL/Graphic_storage.h @@ -4,7 +4,7 @@ namespace CGAL { /*! \ingroup PkgBasicViewerClasses -The class `Graphic_storage` store points, segments and triangles. Elements can be added, possibly with associated colors. Non triangular faces can be directly added, and triangulated internally. +The class `Graphic_storage` store points, segments and triangles. Elements can be added, possibly with associated colors. Non triangular faces can be directly added, and are triangulated internally. \tparam BufferType the type used for point coordinates: float by default. @@ -12,55 +12,75 @@ The class `Graphic_storage` store points, segments and triangles. Elements can b template class Graphic_storage { - template void add_point(const KPoint &p); + /// Add the given point in this storage. + template + void add_point(const KPoint &p); + /// Add the given colored point in this storage. template void add_point(const KPoint &p, const CGAL::IO::Color &acolor); + /// Add the given segment in this storage. template void add_segment(const KPoint &p1, const KPoint &p2); + /// Add the given colored segment in this storage. template void add_segment(const KPoint &p1, const KPoint &p2, const CGAL::IO::Color &acolor); + /// Add the given ray in the storage: an half line starting from p and having v as direction. template void add_ray(const KPoint &p, const KVector &v); + /// Add the given colored ray in the storage: an half line starting from p and having v as direction. template void add_ray(const KPoint &p, const KVector &v, const CGAL::IO::Color &acolor); + /// Add the given line in the storage, defined by p and v as direction. template void add_line(const KPoint &p, const KVector &v); + /// Add the given colored line in the storage, defined by p and v as direction. template void add_line(const KPoint &p, const KVector &v, const CGAL::IO::Color &acolor); + /// start a new face. + void face_begin(); + + /// start a new colored face. + void face_begin(const CGAL::IO::Color &acolor); + + /// @return true iff a face is started. + bool is_a_face_started() const; + + /// add the given point in the current face. template bool add_point_in_face(const KPoint &kp); + /// add the given point in the current face, having the vertex normal. template bool add_point_in_face(const KPoint &kp, const KVector &p_normal); - bool is_a_face_started() const; - - void face_begin(); - - void face_begin(const CGAL::IO::Color &acolor); - + /// end the current face. void face_end(); + /// @return true iff the storage has no element. bool is_empty() const; + /// clear the storage, i.e. remove all points, segments, triangles and text. void clear(); + /// add the given text at the given position in the storage. template void add_text(const KPoint &kp, const char *txt); + /// add the given text at the given position in the storage. template void add_text(const KPoint &kp, const std::string &txt); + /// clear all the texts. void m_texts_clear(); }; diff --git a/Basic_viewer/examples/Basic_viewer/draw_mesh_and_points.cpp b/Basic_viewer/examples/Basic_viewer/draw_mesh_and_points.cpp index 744f9829988..7a2058b2d3a 100644 --- a/Basic_viewer/examples/Basic_viewer/draw_mesh_and_points.cpp +++ b/Basic_viewer/examples/Basic_viewer/draw_mesh_and_points.cpp @@ -58,7 +58,7 @@ int main(void) CGAL::Graphic_storage graphic_buffer; CGAL::add_in_graphic_buffer(point_set, graphic_buffer, Drawing_functor_green_points()); CGAL::add_in_graphic_buffer(output_mesh, graphic_buffer); - CGAL::draw_buffer(graphic_buffer); + CGAL::draw_graphic_storage(graphic_buffer); } else { return EXIT_FAILURE; } diff --git a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h index 4fa0c1ea583..254e9fb724d 100644 --- a/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h +++ b/GraphicsView/include/CGAL/Qt/Basic_viewer_qt.h @@ -1667,7 +1667,7 @@ protected: }; template -void draw_buffer(Graphic_storage& graphic_buffer, +void draw_graphic_storage(Graphic_storage& graphic_buffer, const char *title="CGAL Basic Viewer") { #if defined(CGAL_TEST_SUITE) @@ -1692,7 +1692,7 @@ void draw_buffer(Graphic_storage& graphic_buffer, } // template -// void draw_buffer(Graphic_storage &graphic_buffer, +// void draw_graphic_storage(Graphic_storage &graphic_buffer, // const std::function *)>& onPress, // const char *title="CGAL Basic Viewer") // { diff --git a/Linear_cell_complex/include/CGAL/draw_linear_cell_complex.h b/Linear_cell_complex/include/CGAL/draw_linear_cell_complex.h index 8dc57de4cc0..25c69790707 100644 --- a/Linear_cell_complex/include/CGAL/draw_linear_cell_complex.h +++ b/Linear_cell_complex/include/CGAL/draw_linear_cell_complex.h @@ -290,7 +290,7 @@ void draw(const CGAL_LCC_TYPE& alcc, const DrawingFunctor& drawing_functor, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(alcc, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } // Specialization of draw function for a LCC, without a drawing functor. @@ -302,7 +302,7 @@ void draw(const CGAL_LCC_TYPE& alcc, const char *title="LCC Basic Viewer") { CGAL::Graphic_storage buffer; add_in_graphic_buffer(alcc, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Nef_3/include/CGAL/draw_nef_3.h b/Nef_3/include/CGAL/draw_nef_3.h index fd0ff089777..f4242edd06a 100644 --- a/Nef_3/include/CGAL/draw_nef_3.h +++ b/Nef_3/include/CGAL/draw_nef_3.h @@ -288,7 +288,7 @@ void draw(const CGAL_NEF3_TYPE &anef, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(anef, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template buffer; add_in_graphic_buffer(anef, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h index 7ed6f505875..1b0c38a68f6 100644 --- a/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/draw_periodic_2_triangulation_2.h @@ -227,7 +227,7 @@ void draw(const CGAL_P2T2_TYPE& ap2t2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ap2t2, buffer, drawing_functor); - draw_buffer(buffer); + draw_graphic_storage(buffer); } template diff --git a/Point_set_3/include/CGAL/draw_point_set_3.h b/Point_set_3/include/CGAL/draw_point_set_3.h index 447db4f7d78..4b8bd016bff 100644 --- a/Point_set_3/include/CGAL/draw_point_set_3.h +++ b/Point_set_3/include/CGAL/draw_point_set_3.h @@ -98,7 +98,7 @@ void draw(const Point_set_3& apointset, { Graphic_storage buffer; add_in_graphic_buffer(apointset, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -107,7 +107,7 @@ void draw(const Point_set_3& apointset, { Graphic_storage buffer; add_in_graphic_buffer(apointset, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Polygon/include/CGAL/draw_polygon_2.h b/Polygon/include/CGAL/draw_polygon_2.h index 6ae50e0fe77..2562d0efe35 100644 --- a/Polygon/include/CGAL/draw_polygon_2.h +++ b/Polygon/include/CGAL/draw_polygon_2.h @@ -128,7 +128,7 @@ void draw(const CGAL_P2_TYPE &ap2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ap2, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -138,7 +138,7 @@ void draw(const CGAL_P2_TYPE &ap2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ap2, buffer, drawingfunctor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Polygon/include/CGAL/draw_polygon_with_holes_2.h b/Polygon/include/CGAL/draw_polygon_with_holes_2.h index c94f39d7cb9..33006449e79 100644 --- a/Polygon/include/CGAL/draw_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/draw_polygon_with_holes_2.h @@ -156,7 +156,7 @@ void draw(const CGAL_P2_WITH_HOLES_TYPE& ap2, const DrawingFunctor &drawing_func { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ap2, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -165,7 +165,7 @@ void draw(const CGAL_P2_WITH_HOLES_TYPE& ap2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ap2, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Polyhedron/include/CGAL/draw_polyhedron.h b/Polyhedron/include/CGAL/draw_polyhedron.h index 05ed00e25a5..19c96d92188 100644 --- a/Polyhedron/include/CGAL/draw_polyhedron.h +++ b/Polyhedron/include/CGAL/draw_polyhedron.h @@ -63,7 +63,7 @@ void draw(const CGAL_POLY_TYPE& apoly, { CGAL::Graphic_storage buffer; add_in_graphic_buffer_for_fg(apoly, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template buffer; add_in_graphic_buffer_for_fg(apoly, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Straight_skeleton_2/include/CGAL/draw_straight_skeleton_2.h b/Straight_skeleton_2/include/CGAL/draw_straight_skeleton_2.h index 80689e79dc5..8736fd07080 100644 --- a/Straight_skeleton_2/include/CGAL/draw_straight_skeleton_2.h +++ b/Straight_skeleton_2/include/CGAL/draw_straight_skeleton_2.h @@ -188,7 +188,7 @@ void draw(const CGAL_SS_TYPE &ass2, const DrawingFunctor &drawingfunctor, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ass2, buffer, drawingfunctor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -197,7 +197,7 @@ void draw(const CGAL_SS_TYPE &ass2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ass2, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Surface_mesh/include/CGAL/draw_surface_mesh.h b/Surface_mesh/include/CGAL/draw_surface_mesh.h index f630b813337..f68fa485697 100644 --- a/Surface_mesh/include/CGAL/draw_surface_mesh.h +++ b/Surface_mesh/include/CGAL/draw_surface_mesh.h @@ -59,7 +59,7 @@ void draw(const Surface_mesh& amesh, { CGAL::Graphic_storage buffer; add_in_graphic_buffer_for_fg(amesh, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -69,7 +69,7 @@ void draw(const Surface_mesh& amesh, { CGAL::Graphic_storage buffer; add_in_graphic_buffer_for_fg(amesh, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER 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 35d7495c826..486ad649010 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 @@ -411,7 +411,7 @@ void draw(const Mesh& mesh, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(mesh, buffer, &paths, amark); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -424,7 +424,7 @@ void draw(const Mesh& mesh, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(mesh, buffer, drawing_functor, &paths, amark); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -437,7 +437,7 @@ void draw(const Mesh& mesh, std::vector> paths=l; CGAL::Graphic_storage buffer; add_in_graphic_buffer(mesh, buffer, &paths, amark); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } } // End namespace CGAL diff --git a/Triangulation_2/examples/Triangulation_2/polygon_triangulation_drawing_functor.h b/Triangulation_2/examples/Triangulation_2/polygon_triangulation_drawing_functor.h index 9c63c3bf8af..6880a4921b3 100644 --- a/Triangulation_2/examples/Triangulation_2/polygon_triangulation_drawing_functor.h +++ b/Triangulation_2/examples/Triangulation_2/polygon_triangulation_drawing_functor.h @@ -76,7 +76,7 @@ void draw(const CGAL_CT2_TYPE &ct2, const DrawingFunctor &drawingfunctor, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(ct2, buffer, drawingfunctor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Triangulation_2/include/CGAL/draw_triangulation_2.h b/Triangulation_2/include/CGAL/draw_triangulation_2.h index e57a6e0a37f..0e777ffdd43 100644 --- a/Triangulation_2/include/CGAL/draw_triangulation_2.h +++ b/Triangulation_2/include/CGAL/draw_triangulation_2.h @@ -159,7 +159,7 @@ void draw(const CGAL_T2_TYPE &at2, const DrawingFunctor &drawingfunctor, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(at2, buffer, drawingfunctor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -168,7 +168,7 @@ void draw(const CGAL_T2_TYPE& at2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(at2, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Triangulation_3/include/CGAL/draw_triangulation_3.h b/Triangulation_3/include/CGAL/draw_triangulation_3.h index 788763d4e32..0a171fc30df 100644 --- a/Triangulation_3/include/CGAL/draw_triangulation_3.h +++ b/Triangulation_3/include/CGAL/draw_triangulation_3.h @@ -163,7 +163,7 @@ void draw(const CGAL_T3_TYPE &at3, const DrawingFunctor &drawingfunctor, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(at3, buffer, drawingfunctor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template @@ -171,7 +171,7 @@ void draw(const CGAL_T3_TYPE &at3, const char *title="T3 Basic Viewer") { CGAL::Graphic_storage buffer; add_in_graphic_buffer(at3, buffer); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } #endif // CGAL_USE_BASIC_VIEWER diff --git a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h index 74a5687ed11..20bcffc914a 100644 --- a/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h +++ b/Voronoi_diagram_2/include/CGAL/draw_voronoi_diagram_2.h @@ -369,7 +369,7 @@ void draw(const CGAL_VORONOI_TYPE& av2, { CGAL::Graphic_storage buffer; add_in_graphic_buffer(av2, buffer, drawing_functor); - draw_buffer(buffer, title); + draw_graphic_storage(buffer, title); } template