From 25628f1d24a6902e7f7d18befeb751b0a7305fd5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 29 Mar 2023 22:21:15 +0200 Subject: svg-flatten: Add stroked SVG output --- svg-flatten/src/out_svg.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'svg-flatten/src') diff --git a/svg-flatten/src/out_svg.cpp b/svg-flatten/src/out_svg.cpp index 80a5bdd..5ec061c 100644 --- a/svg-flatten/src/out_svg.cpp +++ b/svg-flatten/src/out_svg.cpp @@ -32,7 +32,8 @@ SimpleSVGOutput::SimpleSVGOutput(ostream &out, bool only_polys, int digits_frac, m_digits_frac(digits_frac), m_dark_color(dark_color), m_clear_color(clear_color), - m_current_color(dark_color) + m_current_color(dark_color), + m_stroke_width(std::nan("0")) { } @@ -57,21 +58,36 @@ SimpleSVGOutput &SimpleSVGOutput::operator<<(GerberPolarityToken pol) { return *this; } +SimpleSVGOutput &SimpleSVGOutput::operator<<(const ApertureToken &ap) { + m_stroke_width = ap.m_has_aperture ? ap.m_size : std::nan("0"); + return *this; +} + SimpleSVGOutput &SimpleSVGOutput::operator<<(const Polygon &poly) { //cerr << "svg: got poly of size " << poly.size() << endl; - if (poly.size() < 3) { - cerr << "Warning: " << poly.size() << "-element polygon passed to SimpleGerberOutput" << endl; + if (std::isnan(m_stroke_width) && poly.size() < 3) { + cerr << "Warning: " << poly.size() << "-element polygon passed to SimpleSVGOutput in fill mode" << endl; return *this; } - m_out << "" << endl; return *this; -- cgit