diff --git a/include/utils/SVG.h b/include/utils/SVG.h index c4418ef86f..2a4d4cbe55 100644 --- a/include/utils/SVG.h +++ b/include/utils/SVG.h @@ -4,6 +4,9 @@ #ifndef SVG_H #define SVG_H +#include + +#include #include // for file output #include "AABB.h" @@ -188,6 +191,34 @@ class SVG : NoCopy */ void writeCoordinateGrid(const coord_t grid_size = MM2INT(1), const Color color = Color::BLACK, const float stroke_width = 0.1, const float font_size = 10) const; + /*! + * Draws the provided Voronoi diagram. + * + * @tparam T numeric type + * @param voronoi The Voronoi diagram to draw. + * @param color The colour to draw the diagram with. + * @param stroke_width The width of the lines. + */ + template + void writeVoronoiDiagram(const boost::polygon::voronoi_diagram& voronoi_diagram, const Color color = Color::BLACK, const float stroke_width = 0.1) const { + for (const auto& edge: voronoi_diagram.edges()) + { + if (!edge.is_finite()) + { + continue; + } + + const auto& v0 = edge.vertex0(); + const auto& v1 = edge.vertex1(); + + if (v0 == nullptr || v1 == nullptr) + { + continue; + } + + writeLine(Point(v0->x(), v0->y()), Point(v1->x(), v1->y()), color, stroke_width); + } + } }; template