From b5ff4bbb5213b7d87840715d8979ac51ddb74cbc Mon Sep 17 00:00:00 2001 From: Sam Segers Date: Tue, 16 Jul 2019 23:12:07 +0200 Subject: [PATCH 1/4] Only set SLIC3R_FHS_RESOURCES when SLIC3R_FHS is set This makes it possible to run slic3r in a temporary direction with make DESTDIR="run" install --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49717b68d..8259c13f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -392,8 +392,10 @@ endif() # Resources install target, configure fhs.hpp on UNIX if (WIN32) install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources") -else () +elseif (SLIC3R_FHS) set(SLIC3R_FHS_RESOURCES "${CMAKE_INSTALL_FULL_DATAROOTDIR}/PrusaSlicer") install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${SLIC3R_FHS_RESOURCES}") +else () + install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources") endif () configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp) From 206dbb81c7b54a32bf2a06c3812c070072b33e85 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 2 Sep 2019 11:47:11 +0200 Subject: [PATCH 2/4] Fix of "Extra overhanging perimeters are added in 2.1.0-beta3" #2857 Two bugs were fixed: 1) An entry in the GLVolume index was not always created when it should have been. 2) Removing empty volumes from the list of GLVolumes did not update the GLVolume index. This is an old issue, but it likely surfaced now with the introduction of splitting the large GLVolumes into multiple shorter ones. --- src/slic3r/GUI/GLCanvas3D.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 7bfae3084..71bacd815 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2152,9 +2152,36 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const if (!m_volumes.empty()) { - // removes empty volumes - m_volumes.volumes.erase(std::remove_if(m_volumes.volumes.begin(), m_volumes.volumes.end(), - [](const GLVolume* volume) { return volume->print_zs.empty(); }), m_volumes.volumes.end()); + // Remove empty volumes from both m_volumes, update m_gcode_preview_volume_index. + { + size_t idx_volume_src = 0; + size_t idx_volume_dst = 0; + size_t idx_volume_index_src = 0; + size_t idx_volume_index_dst = 0; + size_t idx_volume_of_this_type_last = (idx_volume_index_src + 1 == m_gcode_preview_volume_index.first_volumes.size()) ? m_volumes.volumes.size() : m_gcode_preview_volume_index.first_volumes[idx_volume_index_src + 1].id; + size_t idx_volume_of_this_type_first_new = 0; + for (;;) { + if (idx_volume_src == idx_volume_of_this_type_last) { + if (idx_volume_of_this_type_first_new < idx_volume_dst) { + // There are some volumes of this type left, therefore their entry in the index has to be maintained. + if (idx_volume_index_dst < idx_volume_index_src) + m_gcode_preview_volume_index.first_volumes[idx_volume_index_dst] = m_gcode_preview_volume_index.first_volumes[idx_volume_index_src]; + m_gcode_preview_volume_index.first_volumes[idx_volume_index_dst].id = idx_volume_of_this_type_first_new; + ++ idx_volume_index_dst; + } + if (idx_volume_of_this_type_last == m_volumes.volumes.size()) + break; + ++ idx_volume_index_src; + idx_volume_of_this_type_last = (idx_volume_index_src + 1 == m_gcode_preview_volume_index.first_volumes.size()) ? m_volumes.volumes.size() : m_gcode_preview_volume_index.first_volumes[idx_volume_index_src + 1].id; + idx_volume_of_this_type_first_new = idx_volume_dst; + } + if (! m_volumes.volumes[idx_volume_src]->print_zs.empty()) + m_volumes.volumes[idx_volume_dst ++] = m_volumes.volumes[idx_volume_src]; + ++ idx_volume_src; + } + m_volumes.volumes.erase(m_volumes.volumes.begin() + idx_volume_dst, m_volumes.volumes.end()); + m_gcode_preview_volume_index.first_volumes.erase(m_gcode_preview_volume_index.first_volumes.begin() + idx_volume_index_dst, m_gcode_preview_volume_index.first_volumes.end()); + } _load_fff_shells(); } @@ -5097,7 +5124,7 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat unsigned int role = (unsigned int)(&filters - &roles_filters.front()); for (std::pair &filter : filters) if (filter.second->indexed_vertex_array.vertices_and_normals_interleaved.size() > MAX_VERTEX_BUFFER_SIZE) { - if (m_gcode_preview_volume_index.first_volumes.back().id != role) + if (m_gcode_preview_volume_index.first_volumes.back().type != GCodePreviewVolumeIndex::Extrusion || m_gcode_preview_volume_index.first_volumes.back().flag != role) m_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, role, (unsigned int)m_volumes.volumes.size()); GLVolume& vol = *filter.second; filter.second = m_volumes.new_toolpath_volume(vol.color); From 0b03f0eb66aa4721772fff1a68e3d3ce62f4eb0e Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 2 Sep 2019 11:55:14 +0200 Subject: [PATCH 3/4] 2nd attempt to fix non compatible (newer) .3mf and .amf import error handling on Linux and OsX --- src/libslic3r/Format/3mf.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index d4f72ffb3..f3561d60b 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -9,6 +9,7 @@ #include "3mf.hpp" #include +#include #include #include @@ -102,6 +103,13 @@ const char* INVALID_OBJECT_TYPES[] = "other" }; +class version_error : public std::runtime_error +{ +public: + version_error(const std::string& what_arg) : std::runtime_error(what_arg) {} + version_error(const char* what_arg) : std::runtime_error(what_arg) {} +}; + const char* get_attribute_value_charptr(const char** attributes, unsigned int attributes_size, const char* attribute_key) { if ((attributes == nullptr) || (attributes_size == 0) || (attributes_size % 2 != 0) || (attribute_key == nullptr)) @@ -731,6 +739,11 @@ namespace Slic3r { return n; }, &data, 0); } + catch (const version_error& e) + { + // rethrow the exception + throw std::runtime_error(e.what()); + } catch (std::exception& e) { add_error(e.what()); @@ -1440,7 +1453,7 @@ namespace Slic3r { if (m_check_version && (m_version > VERSION_3MF)) { std::string msg = _(L("The selected 3mf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatibile.")); - throw std::runtime_error(msg.c_str()); + throw version_error(msg.c_str()); } } From 729bd529dc9f09fed9a45d261b93a692f7cf5554 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 2 Sep 2019 13:02:28 +0200 Subject: [PATCH 4/4] Fixed typo --- src/libslic3r/Format/3mf.cpp | 2 +- src/libslic3r/Format/AMF.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index f3561d60b..0f89e6193 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1452,7 +1452,7 @@ namespace Slic3r { if (m_check_version && (m_version > VERSION_3MF)) { - std::string msg = _(L("The selected 3mf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatibile.")); + std::string msg = _(L("The selected 3mf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatible.")); throw version_error(msg.c_str()); } } diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index f43724cb6..92c958d8a 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -827,7 +827,7 @@ bool extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_fi if (check_version && (ctx.m_version > VERSION_AMF)) { - std::string msg = _(L("The selected amf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatibile.")); + std::string msg = _(L("The selected amf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatible.")); throw std::runtime_error(msg.c_str()); }