From 19e1d877aa0c9d7517a0f5e0aca03838871e962c Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 24 Apr 2020 12:46:35 +0200 Subject: [PATCH] Don't use sla::EncodedRaster in SLAImport, revive opencsg sandbox --- sandboxes/opencsg/CMakeLists.txt | 1 + sandboxes/opencsg/main.cpp | 2 +- src/libslic3r/SLA/AGGRaster.hpp | 9 +++++---- src/slic3r/Utils/SLAImport.cpp | 21 +++++++++++---------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/sandboxes/opencsg/CMakeLists.txt b/sandboxes/opencsg/CMakeLists.txt index ec1f4cae9..ace8f4d53 100644 --- a/sandboxes/opencsg/CMakeLists.txt +++ b/sandboxes/opencsg/CMakeLists.txt @@ -6,6 +6,7 @@ add_executable(opencsg_example WIN32 main.cpp Engine.hpp Engine.cpp ShaderCSGDisplay.hpp ShaderCSGDisplay.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/Jobs/Job.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/ProgressStatusBar.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.hpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.cpp) diff --git a/sandboxes/opencsg/main.cpp b/sandboxes/opencsg/main.cpp index adf9cc457..f5fb12493 100644 --- a/sandboxes/opencsg/main.cpp +++ b/sandboxes/opencsg/main.cpp @@ -26,7 +26,7 @@ #include "libslic3r/Format/3mf.hpp" #include "libslic3r/SLAPrint.hpp" -#include "slic3r/GUI/Job.hpp" +#include "slic3r/GUI/Jobs/Job.hpp" #include "slic3r/GUI/ProgressStatusBar.hpp" using namespace Slic3r::GL; diff --git a/src/libslic3r/SLA/AGGRaster.hpp b/src/libslic3r/SLA/AGGRaster.hpp index 37baed9e8..917f718e9 100644 --- a/src/libslic3r/SLA/AGGRaster.hpp +++ b/src/libslic3r/SLA/AGGRaster.hpp @@ -128,12 +128,13 @@ protected: } public: - template AGGRaster(const Resolution &res, + template + AGGRaster(const Resolution &res, const PixelDim & pd, const Trafo & trafo, - const TColor & foreground, - const TColor & background, - GammaFn && gammafn) + const TColor & foreground, + const TColor & background, + GammaFn && gammafn) : m_resolution(res) , m_pxdim_scaled(SCALING_FACTOR / pd.w_mm, SCALING_FACTOR / pd.h_mm) , m_buf(res.pixels()) diff --git a/src/slic3r/Utils/SLAImport.cpp b/src/slic3r/Utils/SLAImport.cpp index 442025a77..65ec46343 100644 --- a/src/slic3r/Utils/SLAImport.cpp +++ b/src/slic3r/Utils/SLAImport.cpp @@ -43,9 +43,11 @@ namespace Slic3r { namespace { +struct PNGBuffer { std::vector buf; std::string fname; }; + struct ArchiveData { boost::property_tree::ptree profile, config; - std::vector images; + std::vector images; }; static const constexpr char *CONFIG_FNAME = "config.ini"; @@ -66,7 +68,7 @@ boost::property_tree::ptree read_ini(const mz_zip_archive_file_stat &entry, return tree; } -sla::EncodedRaster read_png(const mz_zip_archive_file_stat &entry, +PNGBuffer read_png(const mz_zip_archive_file_stat &entry, MZ_Archive & zip, const std::string & name) { @@ -75,9 +77,8 @@ sla::EncodedRaster read_png(const mz_zip_archive_file_stat &entry, if (!mz_zip_reader_extract_file_to_mem(&zip.arch, entry.m_filename, buf.data(), buf.size(), 0)) throw std::runtime_error(zip.get_errorstr()); - - return sla::EncodedRaster(std::move(buf), - name.empty() ? entry.m_filename : name); + + return {std::move(buf), (name.empty() ? entry.m_filename : name)}; } ArchiveData extract_sla_archive(const std::string &zipfname, @@ -113,9 +114,9 @@ ArchiveData extract_sla_archive(const std::string &zipfname, if (boost::filesystem::path(name).extension().string() == ".png") { auto it = std::lower_bound( - arch.images.begin(), arch.images.end(), sla::EncodedRaster({}, name), - [](const sla::EncodedRaster &r1, const sla::EncodedRaster &r2) { - return std::less()(r1.extension(), r2.extension()); + arch.images.begin(), arch.images.end(), PNGBuffer{{}, name}, + [](const PNGBuffer &r1, const PNGBuffer &r2) { + return std::less()(r1.fname, r2.fname); }); arch.images.insert(it, read_png(entry, zip, name)); @@ -258,8 +259,8 @@ std::vector extract_slices_from_sla_archive( } } - auto &buf = arch.images[i]; - wxMemoryInputStream stream{buf.data(), buf.size()}; + PNGBuffer &png = arch.images[i]; + wxMemoryInputStream stream{png.buf.data(), png.buf.size()}; wxImage img{stream}; auto rings = marchsq::execute(img, 128, rstp.win);