Merge remote-tracking branch 'remotes/origin/tm_sla_png_minz'

This commit is contained in:
bubnikv 2019-03-28 09:14:37 +01:00
commit fc49abc2a4
319 changed files with 496 additions and 116392 deletions

View file

@ -92,64 +92,13 @@ void BackgroundSlicingProcess::process_fff()
}
}
// Pseudo type for specializing LayerWriter trait class
struct SLAZipFmt {};
// The implementation of creating zipped archives with wxWidgets
template<> class LayerWriter<SLAZipFmt> {
wxFileName fpath;
wxFFileOutputStream zipfile;
wxZipOutputStream zipstream;
wxStdOutputStream pngstream;
public:
inline LayerWriter(const std::string& zipfile_path):
fpath(zipfile_path),
zipfile(zipfile_path),
zipstream(zipfile),
pngstream(zipstream)
{
if(!is_ok())
throw std::runtime_error("Cannot create zip file.");
}
~LayerWriter() {
// In case of an error (disk space full) zipstream destructor would
// crash.
pngstream.clear();
zipstream.CloseEntry();
}
inline void next_entry(const std::string& fname) {
zipstream.PutNextEntry(fname);
}
inline std::string get_name() const {
return fpath.GetName().ToUTF8().data();
}
template<class T> inline LayerWriter& operator<<(const T& arg) {
pngstream << arg; return *this;
}
bool is_ok() const {
return pngstream.good() && zipstream.IsOk() && zipfile.IsOk();
}
inline void close() {
zipstream.Close();
zipfile.Close();
}
};
void BackgroundSlicingProcess::process_sla()
{
assert(m_print == m_sla_print);
m_print->process();
if (this->set_step_started(bspsGCodeFinalize)) {
if (! m_export_path.empty()) {
m_sla_print->export_raster<SLAZipFmt>(m_export_path);
m_sla_print->export_raster(m_export_path);
m_print->set_status(100, "Masked SLA file exported to " + m_export_path);
} else if (! m_upload_job.empty()) {
prepare_upload();
@ -449,8 +398,8 @@ void BackgroundSlicingProcess::prepare_upload()
}
run_post_process_scripts(source_path.string(), m_fff_print->config());
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
} else {
m_sla_print->export_raster<SLAZipFmt>(source_path.string());
} else {
m_sla_print->export_raster(source_path.string());
// TODO: Also finalize upload path like with FFF when there are statistics for SLA print
}