summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/export.cc37
-rw-r--r--src/export.h6
-rw-r--r--src/mainwin.cc15
-rw-r--r--src/openscad.cc6
-rw-r--r--tests/cgalstlsanitytest.cc2
-rw-r--r--tests/cgaltest.cc2
6 files changed, 33 insertions, 35 deletions
diff --git a/src/export.cc b/src/export.cc
index 8abd5fa..9414ebe 100644
--- a/src/export.cc
+++ b/src/export.cc
@@ -29,10 +29,6 @@
#include "polyset.h"
#include "dxfdata.h"
-#include <QApplication>
-#include <QProgressDialog>
-#include <errno.h>
-
#ifdef ENABLE_CGAL
#include "CGAL_Nef_polyhedron.h"
#include "cgal.h"
@@ -41,10 +37,12 @@
Saves the current 3D CGAL Nef polyhedron as STL to the given file.
The file must be open.
*/
-void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *pd)
+void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output)
{
+ CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
+ try {
CGAL_Polyhedron P;
- root_N->p3->convert_to_Polyhedron(P);
+ root_N->p3->convert_to_Polyhedron(P);
typedef CGAL_Polyhedron::Vertex Vertex;
typedef CGAL_Polyhedron::Vertex_const_iterator VCI;
@@ -108,27 +106,36 @@ void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDial
output << " endfacet\n";
}
} while (hc != hc_end);
- if (pd) {
- pd->setValue(facet_count++);
- QApplication::processEvents();
- }
}
output << "endsolid OpenSCAD_Model\n";
setlocale(LC_NUMERIC, ""); // Set default locale
+
+ }
+ catch (CGAL::Assertion_exception e) {
+ PRINTF("CGAL error in CGAL_Nef_polyhedron3::convert_to_Polyhedron(): %s", e.what());
+ }
+ CGAL::set_error_behaviour(old_behaviour);
}
-void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog*)
+void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output)
{
- CGAL_Polyhedron P;
- root_N->p3->convert_to_Polyhedron(P);
- output << P;
+ CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
+ try {
+ CGAL_Polyhedron P;
+ root_N->p3->convert_to_Polyhedron(P);
+ output << P;
+ }
+ catch (CGAL::Assertion_exception e) {
+ PRINTF("CGAL error in CGAL_Nef_polyhedron3::convert_to_Polyhedron(): %s", e.what());
+ }
+ CGAL::set_error_behaviour(old_behaviour);
}
/*!
Saves the current 2D CGAL Nef polyhedron as DXF to the given absolute filename.
*/
-void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *)
+void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output)
{
setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output
// Some importers (e.g. Inkscape) needs a BLOCKS section to be present
diff --git a/src/export.h b/src/export.h
index dd6e3e0..9750c30 100644
--- a/src/export.h
+++ b/src/export.h
@@ -5,9 +5,9 @@
#include <iostream>
-void export_stl(class CGAL_Nef_polyhedron *root_N, std::ostream &output, class QProgressDialog *pd);
-void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *pd);
-void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *pd);
+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);
#endif
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 4979970..20f3c7c 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -1318,26 +1318,17 @@ void MainWindow::actionExportSTLorOFF(bool)
return;
}
- QProgressDialog *pd = new QProgressDialog(
- stl_mode ? "Exporting object to STL file..." : "Exporting object to OFF file...",
- QString(), 0, this->root_N->p3->number_of_facets() + 1);
- pd->setValue(0);
- pd->setAutoClose(false);
- pd->show();
- QApplication::processEvents();
-
std::ofstream fstream(stl_filename.toUtf8());
if (!fstream.is_open()) {
PRINTA("Can't open file \"%1\" for export", stl_filename);
}
else {
- if (stl_mode) export_stl(this->root_N, fstream, pd);
- else export_off(this->root_N, fstream, pd);
+ if (stl_mode) export_stl(this->root_N, fstream);
+ else export_off(this->root_N, fstream);
fstream.close();
PRINTF("%s export finished.", stl_mode ? "STL" : "OFF");
}
- delete pd;
clearCurrentOutput();
#endif /* ENABLE_CGAL */
@@ -1385,7 +1376,7 @@ void MainWindow::actionExportDXF()
PRINTA("Can't open file \"%s\" for export", dxf_filename);
}
else {
- export_dxf(this->root_N, fstream, NULL);
+ export_dxf(this->root_N, fstream);
fstream.close();
PRINTF("DXF export finished.");
}
diff --git a/src/openscad.cc b/src/openscad.cc
index 49e1aaf..9d5e44b 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -325,7 +325,7 @@ int main(int argc, char **argv)
PRINTF("Can't open file \"%s\" for export", stl_output_file);
}
else {
- export_stl(&root_N, fstream, NULL);
+ export_stl(&root_N, fstream);
fstream.close();
}
}
@@ -344,7 +344,7 @@ int main(int argc, char **argv)
PRINTF("Can't open file \"%s\" for export", off_output_file);
}
else {
- export_off(&root_N, fstream, NULL);
+ export_off(&root_N, fstream);
fstream.close();
}
}
@@ -359,7 +359,7 @@ int main(int argc, char **argv)
PRINTF("Can't open file \"%s\" for export", dxf_output_file);
}
else {
- export_dxf(&root_N, fstream, NULL);
+ export_dxf(&root_N, fstream);
fstream.close();
}
}
diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc
index 548ab44..5182efd 100644
--- a/tests/cgalstlsanitytest.cc
+++ b/tests/cgalstlsanitytest.cc
@@ -131,7 +131,7 @@ int main(int argc, char **argv)
outfile.open(outfilename);
std::stringstream out;
- export_stl(&N, out, NULL);
+ export_stl(&N, out);
if (out.str().find("nan") != string::npos) {
outfile << "Error: nan found\n";
retval = 2;
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index 4c23ee1..0c6f5e3 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
current_path(original_path);
if (!N.empty()) {
- export_stl(&N, std::cout, NULL);
+ export_stl(&N, std::cout);
}
Builtins::instance(true);
contact: Jan Huwald // Impressum