aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/src
diff options
context:
space:
mode:
Diffstat (limited to 'svg-flatten/src')
-rw-r--r--svg-flatten/src/out_gerber.cpp18
-rw-r--r--svg-flatten/src/svg_doc.cpp11
2 files changed, 24 insertions, 5 deletions
diff --git a/svg-flatten/src/out_gerber.cpp b/svg-flatten/src/out_gerber.cpp
index 94c01de..f842e15 100644
--- a/svg-flatten/src/out_gerber.cpp
+++ b/svg-flatten/src/out_gerber.cpp
@@ -34,7 +34,9 @@ SimpleGerberOutput::SimpleGerberOutput(ostream &out, bool only_polys, int digits
m_offset(offset),
m_scale(scale),
m_flip_pol(flip_polarity),
- m_outline_mode(outline_mode)
+ m_outline_mode(outline_mode),
+ m_current_aperture(0.0),
+ m_aperture_num(10) /* See gerber standard */
{
assert(1 <= digits_int && digits_int <= 9);
assert(0 <= digits_frac && digits_frac <= 9);
@@ -59,6 +61,20 @@ void SimpleGerberOutput::header_impl(d2p origin, d2p size) {
m_out << "D10*" << endl;
}
+SimpleGerberOutput& SimpleGerberOutput::operator<<(const ApertureToken &ap) {
+ if (ap.m_size == m_current_aperture) {
+ return *this;
+ }
+ m_current_aperture = ap.m_size;
+ m_aperture_num += 1;
+
+ double size = (ap.m_size > 0.0) ? ap.m_size : 0.05;
+ m_out << "%ADD" << m_aperture_num << "C," << size << "*%" << endl;
+ m_out << "D" << m_aperture_num << "*" << endl;
+
+ return *this;
+}
+
SimpleGerberOutput& SimpleGerberOutput::operator<<(GerberPolarityToken pol) {
assert(pol == GRB_POL_DARK || pol == GRB_POL_CLEAR);
diff --git a/svg-flatten/src/svg_doc.cpp b/svg-flatten/src/svg_doc.cpp
index 48ee56d..6d41aca 100644
--- a/svg-flatten/src/svg_doc.cpp
+++ b/svg-flatten/src/svg_doc.cpp
@@ -226,6 +226,8 @@ void gerbolyze::SVGDocument::export_svg_path(xform2d &mat, const RenderSettings
/* Load path from SVG path data and transform into document units. */
xform2d local_xf(mat);
local_xf.transform(xform2d(node.attribute("transform").value()));
+ /* FIXME transform stroke width here? */
+ stroke_width = local_xf.doc2phys_dist(stroke_width);
PolyTree ptree_stroke;
PolyTree ptree_fill;
@@ -307,7 +309,7 @@ void gerbolyze::SVGDocument::export_svg_path(xform2d &mat, const RenderSettings
if (rset.outline_mode) {
/* In outline mode, manually close polys */
poly.push_back(poly[0]);
- *polygon_sink << poly;
+ *polygon_sink << ApertureToken() << poly;
} else {
offx.AddPath(poly, join_type, etClosedLine);
@@ -320,7 +322,7 @@ void gerbolyze::SVGDocument::export_svg_path(xform2d &mat, const RenderSettings
dash_path(poly_copy, out, dasharray);
if (rset.outline_mode) {
- *polygon_sink << out;
+ *polygon_sink << ApertureToken(stroke_width) << out;
} else {
offx.AddPaths(out, join_type, end_type);
}
@@ -332,7 +334,7 @@ void gerbolyze::SVGDocument::export_svg_path(xform2d &mat, const RenderSettings
dash_path(poly, out, dasharray);
if (rset.outline_mode) {
- *polygon_sink << out;
+ *polygon_sink << ApertureToken(stroke_width) << out;
} else {
offx.AddPaths(out, join_type, end_type);
}
@@ -373,10 +375,11 @@ void gerbolyze::SVGDocument::export_svg_path(xform2d &mat, const RenderSettings
Paths s_polys;
dehole_polytree(ptree, s_polys);
- *polygon_sink << (stroke_color == GRB_DARK ? GRB_POL_DARK : GRB_POL_CLEAR) << s_polys;
+ *polygon_sink << ApertureToken() << (stroke_color == GRB_DARK ? GRB_POL_DARK : GRB_POL_CLEAR) << s_polys;
}
}
}
+ *polygon_sink << ApertureToken();
}
void gerbolyze::SVGDocument::render(const RenderSettings &rset, PolygonSink &sink, const ElementSelector *sel) {