diff --git a/src/libslic3r/AnyPtr.hpp b/src/libslic3r/AnyPtr.hpp index c40d10093e..823fac0808 100644 --- a/src/libslic3r/AnyPtr.hpp +++ b/src/libslic3r/AnyPtr.hpp @@ -38,16 +38,16 @@ class AnyPtr { } public: - template>> + template>> AnyPtr(TT *p = nullptr) : ptr{p} {} - template>> + template>> AnyPtr(std::unique_ptr p) : ptr{std::unique_ptr(std::move(p))} {} - template>> + template>> AnyPtr(std::shared_ptr p) : ptr{std::shared_ptr(std::move(p))} {} - template>> + template>> AnyPtr(std::weak_ptr p) : ptr{std::weak_ptr(std::move(p))} {} @@ -59,16 +59,16 @@ public: AnyPtr &operator=(AnyPtr &&other) noexcept { ptr = std::move(other.ptr); return *this; } AnyPtr &operator=(const AnyPtr &other) = delete; - template>> + template>> AnyPtr &operator=(TT *p) { ptr = p; return *this; } - template>> + template>> AnyPtr &operator=(std::unique_ptr p) { ptr = std::move(p); return *this; } - template>> + template>> AnyPtr &operator=(std::shared_ptr p) { ptr = p; return *this; } - template>> + template>> AnyPtr &operator=(std::weak_ptr p) { ptr = std::move(p); return *this; } const T &operator*() const { return *get_ptr(*this); } diff --git a/src/libslic3r/CSGMesh/PerformCSGMeshBooleans.hpp b/src/libslic3r/CSGMesh/PerformCSGMeshBooleans.hpp index aabe9a2de3..555e9abbe0 100644 --- a/src/libslic3r/CSGMesh/PerformCSGMeshBooleans.hpp +++ b/src/libslic3r/CSGMesh/PerformCSGMeshBooleans.hpp @@ -26,7 +26,6 @@ MeshBoolean::cgal::CGALMeshPtr get_cgalmesh(const CSGPartT &csgpart) MeshBoolean::cgal::CGALMeshPtr ret; indexed_triangle_set m = *its; - auto tr = get_transform(csgpart); its_transform(m, get_transform(csgpart), true); try { diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index d60e077af0..6655b6764e 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -53,22 +53,7 @@ void Layer::make_slices() this->lslices = slices; } - // prepare lslices ordered by print order - this->lslice_indices_sorted_by_print_order.clear(); - this->lslice_indices_sorted_by_print_order.reserve(lslices.size()); - // prepare ordering points - Points ordering_points; - ordering_points.reserve( this->lslices.size()); - for (const ExPolygon &ex : this->lslices) - ordering_points.push_back(ex.contour.first_point()); - - // sort slices - std::vector order = chain_points(ordering_points); - - // populate slices vector - for (size_t i : order) { - this->lslice_indices_sorted_by_print_order.emplace_back(i); - } + this->lslice_indices_sorted_by_print_order = chain_expolygons(this->lslices); } // used by Layer::build_up_down_graph() diff --git a/src/libslic3r/Layer.hpp b/src/libslic3r/Layer.hpp index 11193828cc..e9c8ecbac5 100644 --- a/src/libslic3r/Layer.hpp +++ b/src/libslic3r/Layer.hpp @@ -318,7 +318,7 @@ public: Layer *upper_layer; Layer *lower_layer; - bool slicing_errors; +// bool slicing_errors; coordf_t slice_z; // Z used for slicing in unscaled coordinates coordf_t print_z; // Z used for printing in unscaled coordinates coordf_t height; // layer height in unscaled coordinates @@ -387,7 +387,8 @@ protected: friend std::string fix_slicing_errors(LayerPtrs&, const std::function&); Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) : - upper_layer(nullptr), lower_layer(nullptr), slicing_errors(false), + upper_layer(nullptr), lower_layer(nullptr), + //slicing_errors(false), slice_z(slice_z), print_z(print_z), height(height), m_id(id), m_object(object) {} virtual ~Layer(); diff --git a/src/libslic3r/PrintObjectSlice.cpp b/src/libslic3r/PrintObjectSlice.cpp index 9dd74bfd70..4cc5adff0d 100644 --- a/src/libslic3r/PrintObjectSlice.cpp +++ b/src/libslic3r/PrintObjectSlice.cpp @@ -1,9 +1,10 @@ +#include "ClipperUtils.hpp" #include "ElephantFootCompensation.hpp" #include "I18N.hpp" #include "Layer.hpp" #include "MultiMaterialSegmentation.hpp" #include "Print.hpp" -#include "ClipperUtils.hpp" +#include "ShortestPath.hpp" #include @@ -398,6 +399,10 @@ static std::vector> slices_to_regions( return slices_by_region; } +// Layer::slicing_errors is no more set since 1.41.1 or possibly earlier, thus this code +// was not really functional for a long day and nobody missed it. +// Could we reuse this fixing code one day? +/* std::string fix_slicing_errors(LayerPtrs &layers, const std::function &throw_if_canceled) { // Collect layers with slicing errors. @@ -480,6 +485,7 @@ std::string fix_slicing_errors(LayerPtrs &layers, const std::function &t "The model has overlapping or self-intersecting facets. I tried to repair it, " "however you might want to check the results or repair the input file and retry.\n"; } +*/ // Called by make_perimeters() // 1) Decides Z positions of the layers, @@ -502,12 +508,18 @@ void PrintObject::slice() m_layers = new_layers(this, generate_object_layers(m_slicing_params, layer_height_profile)); this->slice_volumes(); m_print->throw_if_canceled(); +#if 0 + // Layer::slicing_errors is no more set since 1.41.1 or possibly earlier, thus this code + // was not really functional for a long day and nobody missed it. + // Could we reuse this fixing code one day? + // Fix the model. //FIXME is this the right place to do? It is done repeateadly at the UI and now here at the backend. std::string warning = fix_slicing_errors(m_layers, [this](){ m_print->throw_if_canceled(); }); m_print->throw_if_canceled(); if (! warning.empty()) BOOST_LOG_TRIVIAL(info) << warning; +#endif // Update bounding boxes, back up raw slices of complex models. tbb::parallel_for( tbb::blocked_range(0, m_layers.size()), @@ -799,8 +811,12 @@ void PrintObject::slice_volumes() if (elephant_foot_compensation_scaled > 0.f && ! m_layers.empty()) { // The Elephant foot has been compensated, therefore the 1st layer's lslices are shrank with the Elephant foot compensation value. // Store the uncompensated value there. - assert(m_layers.front()->id() == 0); - m_layers.front()->lslices = std::move(lslices_1st_layer); + //FIXME is this operation needed? MMU painting and brim now have to do work arounds to work with compensated layer, not with the uncompensated layer. + // There may be subtle issues removing this block such as support raft sticking too well with the first object layer. + Layer &layer = *m_layers.front(); + assert(layer.id() == 0); + layer.lslices = std::move(lslices_1st_layer); + layer.lslice_indices_sorted_by_print_order = chain_expolygons(layer.lslices); } } diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp index 72bfe1f306..da1a44ec75 100644 --- a/src/libslic3r/ShortestPath.cpp +++ b/src/libslic3r/ShortestPath.cpp @@ -1076,6 +1076,15 @@ std::vector chain_points(const Points &points, Point *start_near) return out; } +std::vector chain_expolygons(const ExPolygons &expolygons, Point *start_near) +{ + Points ordering_points; + ordering_points.reserve(expolygons.size()); + for (const ExPolygon &ex : expolygons) + ordering_points.push_back(ex.contour.first_point()); + return chain_points(ordering_points); +} + #ifndef NDEBUG // #define DEBUG_SVG_OUTPUT #endif /* NDEBUG */ diff --git a/src/libslic3r/ShortestPath.hpp b/src/libslic3r/ShortestPath.hpp index 14912ee857..c84349217e 100644 --- a/src/libslic3r/ShortestPath.hpp +++ b/src/libslic3r/ShortestPath.hpp @@ -12,7 +12,11 @@ namespace ClipperLib { class PolyNode; } namespace Slic3r { +class ExPolygon; +using ExPolygons = std::vector; + std::vector chain_points(const Points &points, Point *start_near = nullptr); +std::vector chain_expolygons(const ExPolygons &expolygons, Point *start_near = nullptr); std::vector> chain_extrusion_entities(std::vector &entities, const Point *start_near = nullptr); void reorder_extrusion_entities(std::vector &entities, const std::vector> &chain); diff --git a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp index b277aa206c..0980326d31 100644 --- a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp +++ b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp @@ -118,8 +118,6 @@ void RotoptimizeJob::finalize(bool canceled, std::exception_ptr &eptr) // Correct the z offset of the object which was corrupted be // the rotation o->ensure_on_bed(); - -// m_plater->find_new_position(o->instances); } if (!canceled) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4fc59db625..d4e0b8fbd0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3116,38 +3116,6 @@ void Plater::priv::mirror(Axis axis) view3D->mirror_selection(axis); } -void Plater::find_new_position(const ModelInstancePtrs &instances) -{ - arrangement::ArrangePolygons movable, fixed; - arrangement::ArrangeParams arr_params = get_arrange_params(this); - - for (const ModelObject *mo : p->model.objects) - for (ModelInstance *inst : mo->instances) { - auto it = std::find(instances.begin(), instances.end(), inst); - auto arrpoly = get_arrange_poly(inst, this); - - if (it == instances.end()) - fixed.emplace_back(std::move(arrpoly)); - else { - arrpoly.setter = [it](const arrangement::ArrangePolygon &p) { - if (p.is_arranged() && p.bed_idx == 0) { - Vec2d t = p.translation.cast(); - (*it)->apply_arrange_result(t, p.rotation); - } - }; - movable.emplace_back(std::move(arrpoly)); - } - } - - if (auto wt = get_wipe_tower_arrangepoly(*this)) - fixed.emplace_back(*wt); - - arrangement::arrange(movable, fixed, this->build_volume().polygon(), arr_params); - - for (auto & m : movable) - m.apply(); -} - void Plater::priv::split_object() { int obj_idx = get_selected_object_idx(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 1997293d84..1ecbeb1906 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -330,7 +330,6 @@ public: GLCanvas3D* get_current_canvas3D(); void arrange(); - void find_new_position(const ModelInstancePtrs &instances); void set_current_canvas_as_dirty(); void unbind_canvas_event_handlers();