diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/export.cc | 10 | ||||
-rw-r--r-- | src/export.h | 8 | ||||
-rw-r--r-- | src/mainwin.cc | 18 | ||||
-rw-r--r-- | src/openscad.cc | 28 |
4 files changed, 33 insertions, 31 deletions
diff --git a/src/export.cc b/src/export.cc index 0c60ea3..9a5eb55 100644 --- a/src/export.cc +++ b/src/export.cc @@ -42,7 +42,7 @@ 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, QTextStream &output, QProgressDialog *pd) +void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *pd) { CGAL_Polyhedron P; root_N->p3->convert_to_Polyhedron(P); @@ -110,15 +110,17 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo setlocale(LC_NUMERIC, ""); // Set default locale } -void export_off(CGAL_Nef_polyhedron*, QTextStream&, QProgressDialog*) +void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog*) { - PRINTF("WARNING: OFF import is not implemented yet."); + CGAL_Polyhedron P; + root_N->p3->convert_to_Polyhedron(P); + output << P; } /*! Saves the current 2D CGAL Nef polyhedron as DXF to the given absolute filename. */ -void export_dxf(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialog *) +void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output, QProgressDialog *) { 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 0298611..cba0b23 100644 --- a/src/export.h +++ b/src/export.h @@ -3,10 +3,12 @@ #ifdef ENABLE_CGAL +#include <iostream> + void cgal_nef3_to_polyset(class PolySet *ps, class CGAL_Nef_polyhedron *root_N); -void export_stl(CGAL_Nef_polyhedron *root_N, class QTextStream &output, class QProgressDialog *pd); -void export_off(CGAL_Nef_polyhedron *root_N, class QTextStream &output, QProgressDialog *pd); -void export_dxf(CGAL_Nef_polyhedron *root_N, class QTextStream &output, QProgressDialog *pd); +void export_stl(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); #endif #endif diff --git a/src/mainwin.cc b/src/mainwin.cc index e1ab8f0..c937279 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -75,6 +75,8 @@ #include "qlanguagefactory.h" #endif +#include <fstream> + #include <algorithm> #include <boost/foreach.hpp> #include <boost/lambda/lambda.hpp> @@ -1403,15 +1405,14 @@ void MainWindow::actionExportSTLorOFF(bool) pd->show(); QApplication::processEvents(); - QFile file(stl_filename); - if (!file.open(QIODevice::ReadWrite)) { + std::ofstream fstream(stl_filename.toUtf8()); + if (!fstream.is_open()) { PRINTA("Can't open file \"%1\" for export", stl_filename); } else { - QTextStream fstream(&file); if (stl_mode) export_stl(this->root_N, fstream, pd); else export_off(this->root_N, fstream, pd); - file.close(); + fstream.close(); PRINTF("%s export finished.", stl_mode ? "STL" : "OFF"); } @@ -1458,14 +1459,13 @@ void MainWindow::actionExportDXF() return; } - QFile file(dxf_filename); - if (!file.open(QIODevice::ReadWrite)) { - PRINTA("Can't open file \"%1\" for export", dxf_filename); + std::ofstream fstream(dxf_filename.toUtf8()); + if (!fstream.is_open()) { + PRINTA("Can't open file \"%s\" for export", dxf_filename); } else { - QTextStream fstream(&file); export_dxf(this->root_N, fstream, NULL); - file.close(); + fstream.close(); PRINTF("DXF export finished."); } diff --git a/src/openscad.cc b/src/openscad.cc index a75d629..7ecf988 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -39,6 +39,7 @@ #include <string> #include <vector> +#include <fstream> #ifdef ENABLE_CGAL #include "CGAL_Nef_polyhedron.h" @@ -318,38 +319,35 @@ int main(int argc, char **argv) } if (stl_output_file) { - QFile file(stl_output_file); - if (!file.open(QIODevice::ReadWrite)) { - PRINTA("Can't open file \"%1\" for export", stl_output_file); + std::ofstream fstream(stl_output_file); + if (!fstream.is_open()) { + PRINTF("Can't open file \"%s\" for export", stl_output_file); } else { - QTextStream fstream(&file); export_stl(&root_N, fstream, NULL); - file.close(); + fstream.close(); } } if (off_output_file) { - QFile file(stl_output_file); - if (!file.open(QIODevice::ReadWrite)) { - PRINTA("Can't open file \"%1\" for export", stl_output_file); + std::ofstream fstream(stl_output_file); + if (!fstream.is_open()) { + PRINTF("Can't open file \"%s\" for export", stl_output_file); } else { - QTextStream fstream(&file); export_off(&root_N, fstream, NULL); - file.close(); + fstream.close(); } } if (dxf_output_file) { - QFile file(dxf_output_file); - if (!file.open(QIODevice::ReadWrite)) { - PRINTA("Can't open file \"%1\" for export", dxf_output_file); + std::ofstream fstream(dxf_output_file); + if (!fstream.is_open()) { + PRINTF("Can't open file \"%s\" for export", dxf_output_file); } else { - QTextStream fstream(&file); export_dxf(&root_N, fstream, NULL); - file.close(); + fstream.close(); } } |