diff options
author | jaseg <git@jaseg.de> | 2021-01-30 14:17:42 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-01-30 14:17:42 +0100 |
commit | a6540b73dabc3af766643657b226f942ef05656c (patch) | |
tree | 9d2ae518ddb23493efc4bfdba16fb1982602646d /src/out_flattener.cpp | |
parent | eac89409b80c8f61efc98a20b4d742c878cde637 (diff) | |
download | gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.gz gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.bz2 gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.zip |
Multi-layer module export working
Diffstat (limited to 'src/out_flattener.cpp')
-rw-r--r-- | src/out_flattener.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/out_flattener.cpp b/src/out_flattener.cpp index 5816f88..8868ca2 100644 --- a/src/out_flattener.cpp +++ b/src/out_flattener.cpp @@ -144,15 +144,19 @@ Flattener &Flattener::operator<<(GerberPolarityToken pol) { return *this; } -Flattener &Flattener::operator<<(const Polygon &poly) { - static int i=0, j=0; +Flattener &Flattener::operator<<(const LayerNameToken &layer_name) { + flush_polys_to_sink(); + m_sink << layer_name; + cerr << "Flattener forwarding layer name to sink: \"" << layer_name.m_name << "\"" << endl; + + return *this; +} +Flattener &Flattener::operator<<(const Polygon &poly) { if (m_current_polarity == GRB_POL_DARK) { d->add_dark_polygon(poly); - cerr << "dark primitive " << i++ << endl; } else { /* clear */ - cerr << "clear primitive " << j++ << endl; d->add_clear_polygon(poly); render_out_clear_polys(); } @@ -160,10 +164,8 @@ Flattener &Flattener::operator<<(const Polygon &poly) { return *this; } -void Flattener::footer() { - if (m_current_polarity == GRB_POL_CLEAR) { - render_out_clear_polys(); - } +void Flattener::flush_polys_to_sink() { + *this << GRB_POL_DARK; /* force render */ m_sink << GRB_POL_DARK; for (auto &poly : d->dark_polys) { @@ -174,6 +176,12 @@ void Flattener::footer() { m_sink << poly_out; } + d->clear_polys.clear(); + d->dark_polys.clear(); +} + +void Flattener::footer() { + flush_polys_to_sink(); m_sink.footer(); } |