From 4e2ef09a506409697cc5f1f9340e2bf04343ede7 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 20 May 2019 11:19:43 +0200 Subject: [PATCH] Fixing build on Win and OSX --- src/libslic3r/SLA/SLARaster.cpp | 15 +++++++-- src/libslic3r/SLA/SLARaster.hpp | 23 ++++++++------ src/libslic3r/SLA/SLARasterWriter.cpp | 4 +-- src/libslic3r/SLA/SLARasterWriter.hpp | 46 +++++++++++++++++++++------ src/libslic3r/SLAPrint.cpp | 2 +- 5 files changed, 65 insertions(+), 25 deletions(-) diff --git a/src/libslic3r/SLA/SLARaster.cpp b/src/libslic3r/SLA/SLARaster.cpp index f1b1c8c42..20891c3d4 100644 --- a/src/libslic3r/SLA/SLARaster.cpp +++ b/src/libslic3r/SLA/SLARaster.cpp @@ -1,6 +1,8 @@ #ifndef SLARASTER_CPP #define SLARASTER_CPP +#include + #include "SLARaster.hpp" #include "libslic3r/ExPolygon.hpp" #include @@ -179,10 +181,17 @@ private: const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255); const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0); -Raster::Raster() = default; +template<> Raster::Raster() { reset(); }; Raster::~Raster() = default; -Raster::Raster(Raster &&m) = default; -Raster& Raster::operator=(Raster&&) = default; + +// Raster::Raster(Raster &&m) = default; +// Raster& Raster::operator=(Raster&&) = default; + +// FIXME: remove after migrating to higher version of windows compiler +Raster::Raster(Raster &&m): m_impl(std::move(m.m_impl)) {} +Raster& Raster::operator=(Raster &&m) { + m_impl = std::move(m.m_impl); return *this; +} void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd, Format fmt, double gamma) diff --git a/src/libslic3r/SLA/SLARaster.hpp b/src/libslic3r/SLA/SLARaster.hpp index 5051498c5..d3bd52d92 100644 --- a/src/libslic3r/SLA/SLARaster.hpp +++ b/src/libslic3r/SLA/SLARaster.hpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include namespace ClipperLib { struct Polygon; } @@ -27,22 +29,20 @@ public: const uint8_t * data() { return m_buffer.data(); } RawBytes(const RawBytes&) = delete; - RawBytes(RawBytes&&) = default; RawBytes& operator=(const RawBytes&) = delete; - RawBytes& operator=(RawBytes&&) = default; // ///////////////////////////////////////////////////////////////////////// // FIXME: the following is needed for MSVC2013 compatibility // ///////////////////////////////////////////////////////////////////////// -// RawBytes(const RawBytes&) = delete; -// RawBytes(RawBytes&& mv) : m_buffer(std::move(mv.m_buffer)) {} + // RawBytes(RawBytes&&) = default; + // RawBytes& operator=(RawBytes&&) = default; -// RawBytes& operator=(const RawBytes&) = delete; -// RawBytes& operator=(RawBytes&& mv) { -// m_buffer = std::move(mv.m_buffer); -// return *this; -// } + RawBytes(RawBytes&& mv) : m_buffer(std::move(mv.m_buffer)) {} + RawBytes& operator=(RawBytes&& mv) { + m_buffer = std::move(mv.m_buffer); + return *this; + } // ///////////////////////////////////////////////////////////////////////// }; @@ -92,7 +92,6 @@ public: reset(std::forward(args)...); } - Raster(); Raster(const Raster& cpy) = delete; Raster& operator=(const Raster& cpy) = delete; Raster(Raster&& m); @@ -141,6 +140,10 @@ public: RawBytes save(); }; +// This prevents the duplicate default constructor warning on MSVC2013 +template<> Raster::Raster(); + + } // sla } // Slic3r diff --git a/src/libslic3r/SLA/SLARasterWriter.cpp b/src/libslic3r/SLA/SLARasterWriter.cpp index b2fe0c72c..f7c3925ac 100644 --- a/src/libslic3r/SLA/SLARasterWriter.cpp +++ b/src/libslic3r/SLA/SLARasterWriter.cpp @@ -44,11 +44,11 @@ void SLARasterWriter::flpXY(ClipperLib::Polygon &poly) void SLARasterWriter::flpXY(ExPolygon &poly) { - for(auto& p : poly.contour.points) p = {p.y(), p.x()}; + for(auto& p : poly.contour.points) p = Point(p.y(), p.x()); std::reverse(poly.contour.points.begin(), poly.contour.points.end()); for(auto& h : poly.holes) { - for(auto& p : h.points) p = {p.y(), p.x()}; + for(auto& p : h.points) p = Point(p.y(), p.x()); std::reverse(h.points.begin(), h.points.end()); } } diff --git a/src/libslic3r/SLA/SLARasterWriter.hpp b/src/libslic3r/SLA/SLARasterWriter.hpp index 9fc23840e..7133d2dde 100644 --- a/src/libslic3r/SLA/SLARasterWriter.hpp +++ b/src/libslic3r/SLA/SLARasterWriter.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "libslic3r/PrintConfig.hpp" @@ -49,8 +50,18 @@ private: Layer(const Layer&) = delete; // The image is big, do not copy by accident Layer& operator=(const Layer&) = delete; - Layer(Layer&& m) = default; - Layer& operator=(Layer&&) = default; + // ///////////////////////////////////////////////////////////////////// + // FIXME: the following is needed for MSVC2013 compatibility + // ///////////////////////////////////////////////////////////////////// + + // Layer(Layer&& m) = default; + // Layer& operator=(Layer&&) = default; + Layer(Layer &&m): + raster(std::move(m.raster)), rawbytes(std::move(m.rawbytes)) {} + Layer& operator=(Layer &&m) { + raster = std::move(m.raster); rawbytes = std::move(m.rawbytes); + return *this; + } }; // We will save the compressed PNG data into RawBytes type buffers in @@ -83,13 +94,30 @@ public: SLARasterWriter(const SLARasterWriter& ) = delete; SLARasterWriter& operator=(const SLARasterWriter&) = delete; - SLARasterWriter(SLARasterWriter&& m) = default; - SLARasterWriter& operator=(SLARasterWriter&&) = default; -// SLARasterWriter(SLARasterWriter&& m) = default; -// SLARasterWriter(SLARasterWriter&& m): -// m_layers_rst(std::move(m.m_layers_rst)), -// m_res(m.m_res), -// m_pxdim(m.m_pxdim) {} + + // ///////////////////////////////////////////////////////////////////////// + // FIXME: the following is needed for MSVC2013 compatibility + // ///////////////////////////////////////////////////////////////////////// + + // SLARasterWriter(SLARasterWriter&& m) = default; + // SLARasterWriter& operator=(SLARasterWriter&&) = default; + SLARasterWriter(SLARasterWriter&& m): + m_layers_rst(std::move(m.m_layers_rst)), + m_res(m.m_res), + m_pxdim(m.m_pxdim), + m_exp_time_s(m.m_exp_time_s), + m_exp_time_first_s(m.m_exp_time_first_s), + m_layer_height(m.m_layer_height), + m_o(m.m_o), + m_mirror(std::move(m.m_mirror)), + m_gamma(m.m_gamma), + m_used_material(m.m_used_material), + m_cnt_fade_layers(m.m_cnt_fade_layers), + m_cnt_slow_layers(m.m_cnt_slow_layers), + m_cnt_fast_layers(m.m_cnt_fast_layers) + {} + + // ///////////////////////////////////////////////////////////////////////// inline void layers(unsigned cnt) { if(cnt > 0) m_layers_rst.resize(cnt); } inline unsigned layers() const { return unsigned(m_layers_rst.size()); } diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 13df2fa79..d07eba2b8 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -742,7 +742,7 @@ void SLAPrint::process() // We apply the printer correction offset here. if(clpr_offs != 0) po.m_model_slices[id] = - offset_ex(po.m_model_slices[id], clpr_offs); + offset_ex(po.m_model_slices[id], float(clpr_offs)); mit->set_model_slice_idx(po, id); ++mit; }