Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_sequential_limits

This commit is contained in:
enricoturri1966 2021-05-18 10:37:39 +02:00
commit 221c054e4f
27 changed files with 1856 additions and 1602 deletions

View file

@ -5,6 +5,8 @@
#include <condition_variable>
#include <mutex>
#include <boost/thread.hpp>
#include <wx/event.h>
#include "libslic3r/PrintBase.hpp"

View file

@ -254,7 +254,7 @@ void Control::SetMaxValue(const int max_value)
void Control::SetSliderValues(const std::vector<double>& values)
{
m_values = values;
m_ruler.count = std::count(m_values.begin(), m_values.end(), m_values.front());
m_ruler.init(m_values);
}
void Control::draw_scroll_line(wxDC& dc, const int lower_pos, const int higher_pos)
@ -1023,8 +1023,23 @@ void Control::draw_colored_band(wxDC& dc)
}
}
void Control::Ruler::init(const std::vector<double>& values)
{
max_values.clear();
max_values.reserve(std::count(values.begin(), values.end(), values.front()));
auto it = std::find(values.begin() + 1, values.end(), values.front());
while (it != values.end()) {
max_values.push_back(*(it - 1));
it = std::find(it + 1, values.end(), values.front());
}
max_values.push_back(*(it - 1));
}
void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, double scroll_step)
{
if (values.empty())
return;
int DPI = GUI::get_dpi_for_window(win);
int pixels_per_sm = lround((double)(DPI) * 5.0/25.4);
@ -1035,7 +1050,7 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
int pow = -2;
int step = 0;
auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count);
auto end_it = std::find(values.begin() + 1, values.end(), values.front());
while (pow < 3) {
for (int istep : {1, 2, 5}) {
@ -1099,7 +1114,7 @@ void Control::draw_ruler(wxDC& dc)
double short_tick = std::nan("");
int tick = 0;
double value = 0.0;
int sequence = 0;
size_t sequence = 0;
int prev_y_pos = -1;
wxCoord label_height = dc.GetMultiLineTextExtent("0").y - 2;
@ -1107,7 +1122,7 @@ void Control::draw_ruler(wxDC& dc)
while (tick <= m_max_value) {
value += m_ruler.long_step;
if (value > m_values.back() && sequence < m_ruler.count) {
if (value > m_ruler.max_values[sequence] && sequence < m_ruler.count()) {
value = m_ruler.long_step;
for (; tick < values_size; tick++)
if (m_values[tick] < value)
@ -1140,7 +1155,7 @@ void Control::draw_ruler(wxDC& dc)
draw_short_ticks(dc, short_tick, tick);
if (value == m_values.back() && sequence < m_ruler.count) {
if (value == m_ruler.max_values[sequence] && sequence < m_ruler.count()) {
value = 0.0;
sequence++;
tick++;

View file

@ -424,10 +424,13 @@ private:
struct Ruler {
double long_step;
double short_step;
int count { 1 }; // > 1 for sequential print
std::vector<double> max_values;// max value for each object/instance in sequence print
// > 1 for sequential print
void init(const std::vector<double>& values);
void update(wxWindow* win, const std::vector<double>& values, double scroll_step);
bool is_ok() { return long_step > 0 && short_step > 0; }
size_t count() { return max_values.size(); }
} m_ruler;
};

View file

@ -2,6 +2,7 @@
#include "libslic3r/Tesselate.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/TriangleMeshSlicer.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "slic3r/GUI/Camera.hpp"
@ -83,16 +84,17 @@ void MeshClipper::recalculate_triangles()
// Now do the cutting
std::vector<ExPolygons> list_of_expolys;
m_tms->set_up_direction(up.cast<float>());
m_tms->slice(std::vector<float>{height_mesh}, SlicingMode::Regular, 0.f, &list_of_expolys, [](){});
m_tms->slice(std::vector<float>{height_mesh}, MeshSlicingParamsExtended{}, &list_of_expolys);
if (m_negative_mesh && !m_negative_mesh->empty()) {
TriangleMeshSlicer negative_tms{m_negative_mesh};
negative_tms.set_up_direction(up.cast<float>());
std::vector<ExPolygons> neg_polys;
negative_tms.slice(std::vector<float>{height_mesh}, SlicingMode::Regular, 0.f, &neg_polys, [](){});
negative_tms.slice(std::vector<float>{height_mesh}, MeshSlicingParamsExtended{}, &neg_polys);
list_of_expolys.front() = diff_ex(list_of_expolys.front(), neg_polys.front());
}
m_triangles2d = triangulate_expolygons_2f(list_of_expolys[0], m_trafo.get_matrix().matrix().determinant() < 0.);
// Rotate the cut into world coords:

View file

@ -3,6 +3,7 @@
#include "libslic3r/Point.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/TriangleMeshSlicer.hpp"
#include "libslic3r/SLA/IndexedMesh.hpp"
#include "admesh/stl.h"
@ -12,9 +13,6 @@
namespace Slic3r {
class TriangleMesh;
class TriangleMeshSlicer;
namespace GUI {
struct Camera;