summaryrefslogtreecommitdiff
path: root/src/export.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2011-09-12 22:31:02 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2011-09-12 22:31:02 (GMT)
commit133a705feef86f11d5afc7fb69ed30585db9e533 (patch)
treef886e81c8853cdc1b26f557ad435e78c3c347a6b /src/export.cc
parenteb79c56ece95f5508e9ee12326995a84a1f9a5f2 (diff)
parentb927e9e1511ca655b4c15b003343ddffc08b0938 (diff)
merging
Merge remote branch 'upstream/master' into visitortests Conflicts: src/cgaladv.cc src/export.cc src/openscad.cc src/polyset.cc src/transform.cc
Diffstat (limited to 'src/export.cc')
-rw-r--r--src/export.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/export.cc b/src/export.cc
index e46a14f..bb389a0 100644
--- a/src/export.cc
+++ b/src/export.cc
@@ -32,6 +32,7 @@
#include <QProgressDialog>
#include <QTextStream>
#include <errno.h>
+#include <fstream>
#ifdef ENABLE_CGAL
#include "cgal.h"
@@ -52,6 +53,14 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output
+ std::ofstream output(filename.toUtf8());
+ if (!output.is_open()) {
+ PRINTA("Can't open STL file \"%1\" for STL export: %2",
+ filename, QString(strerror(errno)));
+ set_output_handler(NULL, NULL);
+ return;
+ }
+
output << "solid OpenSCAD_Model\n";
int facet_count = 0;
@@ -73,10 +82,15 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
double x3 = CGAL::to_double(v3.point().x());
double y3 = CGAL::to_double(v3.point().y());
double z3 = CGAL::to_double(v3.point().z());
- QString vs1, vs2, vs3;
- vs1.sprintf("%f %f %f", x1, y1, z1);
- vs2.sprintf("%f %f %f", x2, y2, z2);
- vs3.sprintf("%f %f %f", x3, y3, z3);
+ std::stringstream stream;
+ stream << x1 << " " << y1 << " " << z1;
+ std::string vs1 = stream.str();
+ stream.str("");
+ stream << x2 << " " << y2 << " " << z2;
+ std::string vs2 = stream.str();
+ stream.str("");
+ stream << x3 << " " << y3 << " " << z3;
+ std::string vs3 = stream.str();
if (vs1 != vs2 && vs1 != vs3 && vs2 != vs3) {
double nx = (y1-y2)*(z1-z3) - (z1-z2)*(y1-y3);
@@ -105,6 +119,7 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
}
output << "endsolid OpenSCAD_Model\n";
+ output.close();
setlocale(LC_NUMERIC, ""); // Set default locale
}
contact: Jan Huwald // Impressum