From 4a3a9f15820543790c7e7c4e9bcb6da6fea78033 Mon Sep 17 00:00:00 2001
From: jaseg <git@jaseg.de>
Date: Fri, 31 Mar 2023 16:35:41 +0200
Subject: Fix remaining commands for layer rework

---
 svg-flatten/src/main.cpp    | 17 ++++++++---------
 svg-flatten/src/svg_doc.cpp | 20 ++++++++++----------
 2 files changed, 18 insertions(+), 19 deletions(-)

(limited to 'svg-flatten/src')

diff --git a/svg-flatten/src/main.cpp b/svg-flatten/src/main.cpp
index 122b75b..b684ce4 100644
--- a/svg-flatten/src/main.cpp
+++ b/svg-flatten/src/main.cpp
@@ -242,12 +242,12 @@ int main(int argc, char **argv) {
     PolygonSink *sink = nullptr;
     PolygonSink *flattener = nullptr;
     PolygonSink *dilater = nullptr;
-    cerr << "Render sink stack:" << endl;
+    //cerr << "Render sink stack:" << endl;
     if (fmt == "svg") {
         string dark_color = args["svg_dark_color"] ? args["svg_dark_color"].as<string>() : "#000000";
         string clear_color = args["svg_clear_color"] ? args["svg_clear_color"].as<string>() : "#ffffff";
         sink = new SimpleSVGOutput(*out_f, only_polys, precision, dark_color, clear_color);
-        cerr << "  * SVG sink " << endl;
+        //cerr << "  * SVG sink " << endl;
 
     } else if (fmt == "gbr" || fmt == "grb" || fmt == "gerber" || fmt == "gerber-outline") {
         outline_mode = fmt == "gerber-outline";
@@ -258,7 +258,7 @@ int main(int argc, char **argv) {
         }
 
         sink = new SimpleGerberOutput(*out_f, only_polys, 4, precision, gerber_scale, {0,0}, args["flip_gerber_polarity"]);
-        cerr << "  * Gerber sink " << endl;
+        //cerr << "  * Gerber sink " << endl;
 
     } else if (fmt == "s-exp" || fmt == "sexp" || fmt == "kicad") {
         if (!args["sexp_mod_name"]) {
@@ -269,7 +269,7 @@ int main(int argc, char **argv) {
         sink = new KicadSexpOutput(*out_f, args["sexp_mod_name"], sexp_layer, only_polys);
         force_flatten = true;
         is_sexp = true;
-        cerr << "  * KiCAD SExp sink " << endl;
+        //cerr << "  * KiCAD SExp sink " << endl;
 
     } else {
         cerr << "Error: Unknown output format \"" << fmt << "\"" << endl;
@@ -281,13 +281,13 @@ int main(int argc, char **argv) {
     if (args["dilate"]) {
         dilater = new Dilater(*top_sink, args["dilate"].as<double>());
         top_sink = dilater;
-        cerr << "  * Dilater " << endl;
+        //cerr << "  * Dilater " << endl;
     }
 
     if (args["flatten"] || (force_flatten && !args["no_flatten"])) {
         flattener = new Flattener(*top_sink);
         top_sink = flattener;
-        cerr << "  * Flattener " << endl;
+        //cerr << "  * Flattener " << endl;
     }
 
     /* Because the C++ stdlib is bullshit */
@@ -311,7 +311,7 @@ int main(int argc, char **argv) {
     /* Check argument */
     ImageVectorizer *vec = makeVectorizer(vectorizer);
     if (!vec) {
-        cerr << "Unknown vectorizer \"" << vectorizer << "\"." << endl;
+        cerr << "Error: Unknown vectorizer \"" << vectorizer << "\"." << endl;
         argagg::fmt_ostream fmt(cerr);
         fmt << usage.str() << argparser;
         return EXIT_FAILURE;
@@ -406,13 +406,12 @@ int main(int argc, char **argv) {
     }
 
     if (args["skip_usvg"]) {
-        cerr << "Info: Skipping usvg" << endl; 
         frob = barf;
 
     } else {
 #ifndef NOFORK
         //cerr << "calling usvg on " << barf << " and " << frob << endl; 
-        vector<string> command_line = {"--keep-named-groups"};
+        vector<string> command_line;
 
         string options[] = {
             "usvg-dpi",
diff --git a/svg-flatten/src/svg_doc.cpp b/svg-flatten/src/svg_doc.cpp
index afb3a68..d61027b 100644
--- a/svg-flatten/src/svg_doc.cpp
+++ b/svg-flatten/src/svg_doc.cpp
@@ -43,13 +43,13 @@ bool gerbolyze::SVGDocument::load(istream &in, double scale) {
     /* Load XML document */
     auto res = svg_doc.load(in);
     if (!res) {
-        cerr << "Cannot parse input file" << endl;
+        cerr << "Error: Cannot parse input file" << endl;
         return false;
     }
 
     root_elem = svg_doc.child("svg");
     if (!root_elem) {
-        cerr << "Input file is missing root <svg> element" << endl;
+        cerr << "Error: Input file is missing root <svg> element" << endl;
         return false;
     }
 
@@ -207,7 +207,7 @@ void gerbolyze::SVGDocument::export_svg_group(RenderContext &ctx, const pugi::xm
 
             ImageVectorizer *vec = ctx.settings().m_vec_sel.select(node);
             if (!vec) {
-                cerr << "Cannot resolve vectorizer for node \"" << node.attribute("id").value() << "\"" << endl;
+                cerr << "Warning: Cannot resolve vectorizer for node \"" << node.attribute("id").value() << "\", ignoring." << endl;
                 continue;
             }
 
@@ -218,7 +218,7 @@ void gerbolyze::SVGDocument::export_svg_group(RenderContext &ctx, const pugi::xm
         } else if (name == "defs") {
             /* ignore */
         } else {
-            cerr << "  Unexpected child: <" << node.name() << ">" << endl;
+            cerr << "Warning: Ignoring unexpected child: <" << node.name() << ">" << endl;
         }
     }
 }
@@ -266,11 +266,11 @@ void gerbolyze::SVGDocument::export_svg_path(RenderContext &ctx, const pugi::xml
     bool has_fill = fill_color;
     bool has_stroke = stroke_color && ctx.mat().doc2phys_min(stroke_width) > ctx.settings().stroke_width_cutoff;
 
-    cerr << "processing svg path" << endl;
-    cerr << "  * " << (has_stroke ? "has stroke" : "no stroke") << " / " << (has_fill ? "has fill" : "no fill") << endl;
-    cerr << "  * " << fill_paths.size() << " fill paths" << endl;
-    cerr << "  * " << stroke_closed.size() << " closed strokes" << endl;
-    cerr << "  * " << stroke_open.size() << " open strokes" << endl;
+    //cerr << "processing svg path" << endl;
+    //cerr << "  * " << (has_stroke ? "has stroke" : "no stroke") << " / " << (has_fill ? "has fill" : "no fill") << endl;
+    //cerr << "  * " << fill_paths.size() << " fill paths" << endl;
+    //cerr << "  * " << stroke_closed.size() << " closed strokes" << endl;
+    //cerr << "  * " << stroke_open.size() << " open strokes" << endl;
 
     /* In outline mode, identify drills before applying clip */
     if (ctx.settings().outline_mode && has_fill && fill_color != GRB_PATTERN_FILL) {
@@ -570,7 +570,7 @@ void gerbolyze::SVGDocument::render_to_list(const RenderSettings &rset, vector<p
 void gerbolyze::SVGDocument::setup_viewport_clip() {
     /* Set up view port clip path */
     Path vb_path;
-    cerr << "setting up viewport clip at " << vb_x << ", " << vb_y << " with size " << vb_w << ", " << vb_h << endl;
+    //cerr << "setting up viewport clip at " << vb_x << ", " << vb_y << " with size " << vb_w << ", " << vb_h << endl;
     for (d2p &p : vector<d2p> {
             {vb_x,      vb_y},
             {vb_x+vb_w, vb_y},
-- 
cgit