///|/ Copyright (c) Prusa Research 2022 - 2023 Tomáš Mészáros @tamasmeszaros ///|/ ///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher ///|/ #ifndef SLAARCHIVE_HPP #define SLAARCHIVE_HPP #include #include "libslic3r/SLA/RasterBase.hpp" #include "libslic3r/Execution/ExecutionTBB.hpp" #include "libslic3r/GCode/ThumbnailData.hpp" namespace Slic3r { class SLAPrint; class SLAPrinterConfig; class SLAArchiveWriter { protected: std::vector m_layers; virtual std::unique_ptr create_raster() const = 0; virtual sla::RasterEncoder get_encoder() const = 0; public: virtual ~SLAArchiveWriter() = default; // Fn have to be thread safe: void(sla::RasterBase& raster, size_t lyrid); template void draw_layers( size_t layer_num, Fn && drawfn, CancelFn cancelfn = []() { return false; }, const EP & ep = {}) { m_layers.resize(layer_num); execution::for_each( ep, size_t(0), m_layers.size(), [this, &drawfn, &cancelfn](size_t idx) { if (cancelfn()) return; sla::EncodedRaster &enc = m_layers[idx]; auto rst = create_raster(); drawfn(*rst, idx); enc = rst->encode(get_encoder()); }, execution::max_concurrency(ep)); } // Export the print into an archive using the provided filename. virtual void export_print(const std::string fname, const SLAPrint &print, const ThumbnailsList &thumbnails, const std::string &projectname = "") = 0; // Factory method to create an archiver instance static std::unique_ptr create( const std::string &archtype, const SLAPrinterConfig &); }; } // namespace Slic3r #endif // SLAARCHIVE_HPP