Merge branch 'master' into lm_sla_supports_auto
This commit is contained in:
commit
779b6c5e0b
3 changed files with 43 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
#include "PostProcessor.hpp"
|
#include "PostProcessor.hpp"
|
||||||
|
|
||||||
#if 1
|
#ifdef WIN32
|
||||||
//#ifdef WIN32
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -15,6 +14,10 @@ void run_post_process_scripts(const std::string &path, const PrintConfig &config
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <boost/process/system.hpp>
|
#include <boost/process/system.hpp>
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <sys/stat.h> //for getting filesystem UID/GID
|
||||||
|
#include <unistd.h> //for getting current UID/GID
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -22,19 +25,29 @@ void run_post_process_scripts(const std::string &path, const PrintConfig &config
|
||||||
{
|
{
|
||||||
if (config.post_process.values.empty())
|
if (config.post_process.values.empty())
|
||||||
return;
|
return;
|
||||||
config.setenv_();
|
//config.setenv_();
|
||||||
|
auto gcode_file = boost::filesystem::path(path);
|
||||||
|
if (!boost::filesystem::exists(gcode_file))
|
||||||
|
throw std::runtime_error(std::string("Post-processor can't find exported gcode file"));
|
||||||
|
|
||||||
for (std::string script: config.post_process.values) {
|
for (std::string script: config.post_process.values) {
|
||||||
// Ignore empty post processing script lines.
|
// Ignore empty post processing script lines.
|
||||||
boost::trim(script);
|
boost::trim(script);
|
||||||
if (script.empty())
|
if (script.empty())
|
||||||
continue;
|
continue;
|
||||||
BOOST_LOG_TRIVIAL(info) << "Executing script " << script << " on file " << path;
|
BOOST_LOG_TRIVIAL(info) << "Executing script " << script << " on file " << path;
|
||||||
if (! boost::filesystem::exists(boost::filesystem::path(path)))
|
if (! boost::filesystem::exists(boost::filesystem::path(script)))
|
||||||
throw std::runtime_exception(std::string("The configured post-processing script does not exist: ") + path);
|
throw std::runtime_error(std::string("The configured post-processing script does not exist: ") + script);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
file_status fs = boost::filesystem::status(path);
|
struct stat info;
|
||||||
//FIXME test if executible by the effective UID / GID.
|
if (stat(script.c_str(), &info))
|
||||||
// throw std::runtime_exception(std::string("The configured post-processing script is not executable: check permissions. ") + path));
|
throw std::runtime_error(std::string("Cannot read information for post-processing script: ") + script);
|
||||||
|
boost::filesystem::perms script_perms = boost::filesystem::status(script).permissions();
|
||||||
|
//if UID matches, check UID perm. else if GID matches, check GID perm. Otherwise check other perm.
|
||||||
|
if (!(script_perms & ((info.st_uid == geteuid()) ? boost::filesystem::perms::owner_exe
|
||||||
|
: ((info.st_gid == getegid()) ? boost::filesystem::perms::group_exe
|
||||||
|
: boost::filesystem::perms::others_exe))))
|
||||||
|
throw std::runtime_error(std::string("The configured post-processing script is not executable: check permissions. ") + script);
|
||||||
#endif
|
#endif
|
||||||
int result = 0;
|
int result = 0;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -45,10 +58,10 @@ void run_post_process_scripts(const std::string &path, const PrintConfig &config
|
||||||
::GetModuleFileNameW(nullptr, wpath_exe, _MAX_PATH);
|
::GetModuleFileNameW(nullptr, wpath_exe, _MAX_PATH);
|
||||||
boost::filesystem::path path_exe(wpath_exe);
|
boost::filesystem::path path_exe(wpath_exe);
|
||||||
// Replace it with the current perl interpreter.
|
// Replace it with the current perl interpreter.
|
||||||
result = boost::process::system((path_exe.parent_path() / "perl5.24.0.exe").string(), script, output_file);
|
result = boost::process::system((path_exe.parent_path() / "perl5.24.0.exe").string(), script, gcode_file);
|
||||||
} else
|
} else
|
||||||
#else
|
#else
|
||||||
result = boost::process::system(script, output_file);
|
result = boost::process::system(script, gcode_file);
|
||||||
#endif
|
#endif
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
BOOST_LOG_TRIVIAL(error) << "Script " << script << " on file " << path << " failed. Negative error code returned.";
|
BOOST_LOG_TRIVIAL(error) << "Script " << script << " on file " << path << " failed. Negative error code returned.";
|
||||||
|
|
|
@ -1080,8 +1080,10 @@ GLCanvas3D::Selection::VolumeCache::TransformCache::TransformCache()
|
||||||
: position(Vec3d::Zero())
|
: position(Vec3d::Zero())
|
||||||
, rotation(Vec3d::Zero())
|
, rotation(Vec3d::Zero())
|
||||||
, scaling_factor(Vec3d::Ones())
|
, scaling_factor(Vec3d::Ones())
|
||||||
|
, mirror(Vec3d::Ones())
|
||||||
, rotation_matrix(Transform3d::Identity())
|
, rotation_matrix(Transform3d::Identity())
|
||||||
, scale_matrix(Transform3d::Identity())
|
, scale_matrix(Transform3d::Identity())
|
||||||
|
, mirror_matrix(Transform3d::Identity())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,9 +1091,11 @@ GLCanvas3D::Selection::VolumeCache::TransformCache::TransformCache(const Geometr
|
||||||
: position(transform.get_offset())
|
: position(transform.get_offset())
|
||||||
, rotation(transform.get_rotation())
|
, rotation(transform.get_rotation())
|
||||||
, scaling_factor(transform.get_scaling_factor())
|
, scaling_factor(transform.get_scaling_factor())
|
||||||
|
, mirror(transform.get_mirror())
|
||||||
{
|
{
|
||||||
rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
||||||
scale_matrix = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scaling_factor);
|
scale_matrix = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scaling_factor);
|
||||||
|
mirror_matrix = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), Vec3d::Ones(), mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::Selection::VolumeCache::VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform)
|
GLCanvas3D::Selection::VolumeCache::VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform)
|
||||||
|
@ -1481,7 +1485,7 @@ void GLCanvas3D::Selection::translate(const Vec3d& displacement)
|
||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
if ((m_mode == Volume) || (*m_volumes)[i]->is_wipe_tower)
|
if ((m_mode == Volume) || (*m_volumes)[i]->is_wipe_tower)
|
||||||
{
|
{
|
||||||
Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix()).inverse() * displacement;
|
Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement;
|
||||||
(*m_volumes)[i]->set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement);
|
(*m_volumes)[i]->set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement);
|
||||||
}
|
}
|
||||||
else if (m_mode == Instance)
|
else if (m_mode == Instance)
|
||||||
|
@ -5338,6 +5342,15 @@ void GLCanvas3D::do_mirror()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes sinking/flying instances
|
||||||
|
for (const std::pair<int, int>& i : done)
|
||||||
|
{
|
||||||
|
ModelObject* m = m_model->objects[i.first];
|
||||||
|
Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second));
|
||||||
|
m_selection.translate(i.first, i.second, shift);
|
||||||
|
m->translate_instance(i.second, shift);
|
||||||
|
}
|
||||||
|
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,8 +398,10 @@ public:
|
||||||
Vec3d position;
|
Vec3d position;
|
||||||
Vec3d rotation;
|
Vec3d rotation;
|
||||||
Vec3d scaling_factor;
|
Vec3d scaling_factor;
|
||||||
|
Vec3d mirror;
|
||||||
Transform3d rotation_matrix;
|
Transform3d rotation_matrix;
|
||||||
Transform3d scale_matrix;
|
Transform3d scale_matrix;
|
||||||
|
Transform3d mirror_matrix;
|
||||||
|
|
||||||
TransformCache();
|
TransformCache();
|
||||||
explicit TransformCache(const Geometry::Transformation& transform);
|
explicit TransformCache(const Geometry::Transformation& transform);
|
||||||
|
@ -428,14 +430,18 @@ public:
|
||||||
const Vec3d& get_volume_position() const { return m_volume.position; }
|
const Vec3d& get_volume_position() const { return m_volume.position; }
|
||||||
const Vec3d& get_volume_rotation() const { return m_volume.rotation; }
|
const Vec3d& get_volume_rotation() const { return m_volume.rotation; }
|
||||||
const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; }
|
const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; }
|
||||||
|
const Vec3d& get_volume_mirror() const { return m_volume.mirror; }
|
||||||
const Transform3d& get_volume_rotation_matrix() const { return m_volume.rotation_matrix; }
|
const Transform3d& get_volume_rotation_matrix() const { return m_volume.rotation_matrix; }
|
||||||
const Transform3d& get_volume_scale_matrix() const { return m_volume.scale_matrix; }
|
const Transform3d& get_volume_scale_matrix() const { return m_volume.scale_matrix; }
|
||||||
|
const Transform3d& get_volume_mirror_matrix() const { return m_volume.mirror_matrix; }
|
||||||
|
|
||||||
const Vec3d& get_instance_position() const { return m_instance.position; }
|
const Vec3d& get_instance_position() const { return m_instance.position; }
|
||||||
const Vec3d& get_instance_rotation() const { return m_instance.rotation; }
|
const Vec3d& get_instance_rotation() const { return m_instance.rotation; }
|
||||||
const Vec3d& get_instance_scaling_factor() const { return m_instance.scaling_factor; }
|
const Vec3d& get_instance_scaling_factor() const { return m_instance.scaling_factor; }
|
||||||
|
const Vec3d& get_instance_mirror() const { return m_instance.mirror; }
|
||||||
const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; }
|
const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; }
|
||||||
const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; }
|
const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; }
|
||||||
|
const Transform3d& get_instance_mirror_matrix() const { return m_instance.mirror_matrix; }
|
||||||
#else
|
#else
|
||||||
const Vec3d& get_position() const { return m_position; }
|
const Vec3d& get_position() const { return m_position; }
|
||||||
const Vec3d& get_rotation() const { return m_rotation; }
|
const Vec3d& get_rotation() const { return m_rotation; }
|
||||||
|
|
Loading…
Reference in a new issue