diff options
author | chrysn <chrysn@fsfe.org> | 2013-06-25 08:18:45 (GMT) |
---|---|---|
committer | chrysn <chrysn@fsfe.org> | 2013-06-25 12:25:03 (GMT) |
commit | b7170fe3498767649b444e7a0fd7c0ebb522848a (patch) | |
tree | c57c3b95186f28bcd99e65188d77c3012f9fc783 /src/openscad.cc | |
parent | 0eb64d8f7afe10ee270e3463a49cd8713d6bb664 (diff) |
add .term output for CSG term export
Diffstat (limited to 'src/openscad.cc')
-rw-r--r-- | src/openscad.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/openscad.cc b/src/openscad.cc index 483d03e..e657cb0 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -48,6 +48,9 @@ #include "PolySetCGALEvaluator.h" #endif +#include "csgterm.h" +#include "CSGTermEvaluator.h" + #include <QApplication> #include <QString> #include <QDir> @@ -314,6 +317,7 @@ int main(int argc, char **argv) const char *csg_output_file = NULL; const char *png_output_file = NULL; const char *ast_output_file = NULL; + const char *term_output_file = NULL; bool null_output = false; QString suffix = QFileInfo(output_file).suffix().toLower(); @@ -323,6 +327,7 @@ int main(int argc, char **argv) else if (suffix == "csg") csg_output_file = output_file; else if (suffix == "png") png_output_file = output_file; else if (suffix == "ast") ast_output_file = output_file; + else if (suffix == "term") term_output_file = output_file; else if (strcmp(output_file, "null") == 0) null_output = true; else { fprintf(stderr, "Unknown suffix for output file %s\n", output_file); @@ -397,6 +402,27 @@ int main(int argc, char **argv) fstream.close(); } } + else if (term_output_file) { + std::vector<shared_ptr<CSGTerm> > highlight_terms; + std::vector<shared_ptr<CSGTerm> > background_terms; + + CSGTermEvaluator csgrenderer(tree, &psevaluator); + shared_ptr<CSGTerm> root_raw_term = csgrenderer.evaluateCSGTerm(*root_node, highlight_terms, background_terms); + + fs::current_path(original_path); + std::ofstream fstream(term_output_file); + if (!fstream.is_open()) { + PRINTB("Can't open file \"%s\" for export", term_output_file); + } + else { + if (!root_raw_term) + fstream << "No top-level CSG object\n"; + else { + fstream << root_raw_term->dump() << "\n"; + } + fstream.close(); + } + } else { #ifdef ENABLE_CGAL if ((null_output || png_output_file) && !vm.count("render")) { |