Don't use sla::EncodedRaster in SLAImport, revive opencsg sandbox

This commit is contained in:
tamasmeszaros 2020-04-24 12:46:35 +02:00
parent 17170b81b5
commit 19e1d877aa
4 changed files with 18 additions and 15 deletions

View File

@ -6,6 +6,7 @@ add_executable(opencsg_example WIN32
main.cpp main.cpp
Engine.hpp Engine.cpp Engine.hpp Engine.cpp
ShaderCSGDisplay.hpp ShaderCSGDisplay.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/ProgressStatusBar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.hpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.cpp) ${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.cpp)

View File

@ -26,7 +26,7 @@
#include "libslic3r/Format/3mf.hpp" #include "libslic3r/Format/3mf.hpp"
#include "libslic3r/SLAPrint.hpp" #include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/Job.hpp" #include "slic3r/GUI/Jobs/Job.hpp"
#include "slic3r/GUI/ProgressStatusBar.hpp" #include "slic3r/GUI/ProgressStatusBar.hpp"
using namespace Slic3r::GL; using namespace Slic3r::GL;

View File

@ -128,12 +128,13 @@ protected:
} }
public: public:
template<class GammaFn> AGGRaster(const Resolution &res, template<class GammaFn>
AGGRaster(const Resolution &res,
const PixelDim & pd, const PixelDim & pd,
const Trafo & trafo, const Trafo & trafo,
const TColor & foreground, const TColor & foreground,
const TColor & background, const TColor & background,
GammaFn && gammafn) GammaFn && gammafn)
: m_resolution(res) : m_resolution(res)
, m_pxdim_scaled(SCALING_FACTOR / pd.w_mm, SCALING_FACTOR / pd.h_mm) , m_pxdim_scaled(SCALING_FACTOR / pd.w_mm, SCALING_FACTOR / pd.h_mm)
, m_buf(res.pixels()) , m_buf(res.pixels())

View File

@ -43,9 +43,11 @@ namespace Slic3r {
namespace { namespace {
struct PNGBuffer { std::vector<uint8_t> buf; std::string fname; };
struct ArchiveData { struct ArchiveData {
boost::property_tree::ptree profile, config; boost::property_tree::ptree profile, config;
std::vector<sla::EncodedRaster> images; std::vector<PNGBuffer> images;
}; };
static const constexpr char *CONFIG_FNAME = "config.ini"; 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; 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, MZ_Archive & zip,
const std::string & name) 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, if (!mz_zip_reader_extract_file_to_mem(&zip.arch, entry.m_filename,
buf.data(), buf.size(), 0)) buf.data(), buf.size(), 0))
throw std::runtime_error(zip.get_errorstr()); throw std::runtime_error(zip.get_errorstr());
return sla::EncodedRaster(std::move(buf), return {std::move(buf), (name.empty() ? entry.m_filename : name)};
name.empty() ? entry.m_filename : name);
} }
ArchiveData extract_sla_archive(const std::string &zipfname, 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") { if (boost::filesystem::path(name).extension().string() == ".png") {
auto it = std::lower_bound( auto it = std::lower_bound(
arch.images.begin(), arch.images.end(), sla::EncodedRaster({}, name), arch.images.begin(), arch.images.end(), PNGBuffer{{}, name},
[](const sla::EncodedRaster &r1, const sla::EncodedRaster &r2) { [](const PNGBuffer &r1, const PNGBuffer &r2) {
return std::less<std::string>()(r1.extension(), r2.extension()); return std::less<std::string>()(r1.fname, r2.fname);
}); });
arch.images.insert(it, read_png(entry, zip, name)); arch.images.insert(it, read_png(entry, zip, name));
@ -258,8 +259,8 @@ std::vector<ExPolygons> extract_slices_from_sla_archive(
} }
} }
auto &buf = arch.images[i]; PNGBuffer &png = arch.images[i];
wxMemoryInputStream stream{buf.data(), buf.size()}; wxMemoryInputStream stream{png.buf.data(), png.buf.size()};
wxImage img{stream}; wxImage img{stream};
auto rings = marchsq::execute(img, 128, rstp.win); auto rings = marchsq::execute(img, 128, rstp.win);