summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-24 02:51:15 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-24 02:51:15 (GMT)
commite82b056e811f7a72e7fb94ecbc1683420831b05e (patch)
tree87ee9f9ce2e660429115b0cabaee5ff78fa6429f
parent2e65c6ddc5c73bfd3b76650c26268b5f54f7cd40 (diff)
basic parse of .png output filename. basic command line option "--render"
-rw-r--r--doc/openscad.13
-rw-r--r--src/export.cc13
-rw-r--r--src/export.h2
-rw-r--r--src/openscad.cc21
4 files changed, 38 insertions, 1 deletions
diff --git a/doc/openscad.1 b/doc/openscad.1
index a4c03dd..7fd911d 100644
--- a/doc/openscad.1
+++ b/doc/openscad.1
@@ -40,6 +40,9 @@ More than one \fB-D\fP options can be given.
.TP
.B \-v, \-\-version
Show version of program.
+.TP
+.B \-\-render
+If exporting an image, use a full CGAL render. (Default is an OpenCSG compile)
.SH AUTHOR
OpenSCAD was written by Clifford Wolf, Marius Kintel, and others.
.PP
diff --git a/src/export.cc b/src/export.cc
index 80670ea..2d5f5a4 100644
--- a/src/export.cc
+++ b/src/export.cc
@@ -195,6 +195,19 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output)
setlocale(LC_NUMERIC, ""); // Set default locale
}
+void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
+{
+ output << "solid OpenSCAD_Model\n";
+ output << "endsolid OpenSCAD_Model\n";
+}
+
+void export_png_with_opencsg(CGAL_Nef_polyhedron *root_N, std::ostream &output)
+{
+ output << "solid OpenSCAD_Model opencsg\n";
+ output << "endsolid OpenSCAD_Model opencsg\n";
+}
+
+
#endif
#ifdef DEBUG
diff --git a/src/export.h b/src/export.h
index 3897be0..b140db6 100644
--- a/src/export.h
+++ b/src/export.h
@@ -8,6 +8,8 @@
void export_stl(class CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output);
+void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output);
+void export_png_with_opencsg(CGAL_Nef_polyhedron *root_N, std::ostream &output);
#endif
diff --git a/src/openscad.cc b/src/openscad.cc
index 472b5d4..2f1c4d8 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -71,7 +71,7 @@ namespace fs = boost::filesystem;
static void help(const char *progname)
{
fprintf(stderr, "Usage: %s [ -o output_file [ -d deps_file ] ]\\\n"
- "%*s[ -m make_command ] [ -D var=val [..] ] filename\n",
+ "%*s[ -m make_command ] [ -D var=val [..] ] [ --render ] filename\n",
progname, int(strlen(progname))+8, "");
exit(1);
}
@@ -132,6 +132,7 @@ int main(int argc, char **argv)
desc.add_options()
("help,h", "help message")
("version,v", "print the version")
+ ("render", "if exporting an image, do a full CGAL render")
("o,o", po::value<string>(), "out-file")
("s,s", po::value<string>(), "stl-file")
("x,x", po::value<string>(), "dxf-file")
@@ -242,12 +243,14 @@ int main(int argc, char **argv)
const char *off_output_file = NULL;
const char *dxf_output_file = NULL;
const char *csg_output_file = NULL;
+ const char *png_output_file = NULL;
QString suffix = QFileInfo(output_file).suffix().toLower();
if (suffix == "stl") stl_output_file = output_file;
else if (suffix == "off") off_output_file = output_file;
else if (suffix == "dxf") dxf_output_file = output_file;
else if (suffix == "csg") csg_output_file = output_file;
+ else if (suffix == "png") png_output_file = output_file;
else {
fprintf(stderr, "Unknown suffix for output file %s\n", output_file);
exit(1);
@@ -309,6 +312,7 @@ int main(int argc, char **argv)
if ( stl_output_file ) geom_out = std::string(stl_output_file);
else if ( off_output_file ) geom_out = std::string(off_output_file);
else if ( dxf_output_file ) geom_out = std::string(dxf_output_file);
+ else if ( png_output_file ) geom_out = std::string(png_output_file);
else {
PRINTB("Output file:%s\n",output_file);
PRINT("Sorry, don't know how to write deps for that file type. Exiting\n");
@@ -373,6 +377,21 @@ int main(int argc, char **argv)
fstream.close();
}
}
+
+ if (png_output_file) {
+ std::ofstream fstream(png_output_file);
+ if (!fstream.is_open()) {
+ PRINTB("Can't open file \"%s\" for export", png_output_file);
+ }
+ else {
+ if (vm.count("render")) {
+ export_png_with_cgal(&root_N, fstream);
+ } else {
+ export_png_with_opencsg(&root_N, fstream);
+ }
+ fstream.close();
+ }
+ }
}
delete root_node;
#else
contact: Jan Huwald // Impressum