Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
YuSanka committed Sep 2, 2019
2 parents 9471254 + 292bff0 commit dba5dd3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,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)
17 changes: 15 additions & 2 deletions src/libslic3r/Format/3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "3mf.hpp"

#include <limits>
#include <stdexcept>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -1439,8 +1452,8 @@ 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());
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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Format/AMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
35 changes: 31 additions & 4 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<float, GLVolume*> &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);
Expand Down

0 comments on commit dba5dd3

Please sign in to comment.