Merge branch 'master' into fs_emboss

This commit is contained in:
Filip Sykala - NTB T15p 2023-02-17 16:58:34 +01:00
commit 8269452927
10 changed files with 44 additions and 65 deletions

View File

@ -38,16 +38,16 @@ class AnyPtr {
}
public:
template<class TT = T, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT = T, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr(TT *p = nullptr) : ptr{p}
{}
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr(std::unique_ptr<TT> p) : ptr{std::unique_ptr<T>(std::move(p))}
{}
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr(std::shared_ptr<TT> p) : ptr{std::shared_ptr<T>(std::move(p))}
{}
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr(std::weak_ptr<TT> p) : ptr{std::weak_ptr<T>(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<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr &operator=(TT *p) { ptr = p; return *this; }
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr &operator=(std::unique_ptr<TT> p) { ptr = std::move(p); return *this; }
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr &operator=(std::shared_ptr<TT> p) { ptr = p; return *this; }
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT, T>>>
template<class TT, class = std::enable_if_t<std::is_convertible_v<TT*, T*>>>
AnyPtr &operator=(std::weak_ptr<TT> p) { ptr = std::move(p); return *this; }
const T &operator*() const { return *get_ptr(*this); }

View File

@ -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 {

View File

@ -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<Points::size_type> 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()

View File

@ -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<void()>&);
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();

View File

@ -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 <boost/log/trivial.hpp>
@ -398,6 +399,10 @@ static std::vector<std::vector<ExPolygons>> 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<void()> &throw_if_canceled)
{
// Collect layers with slicing errors.
@ -480,6 +485,7 @@ std::string fix_slicing_errors(LayerPtrs &layers, const std::function<void()> &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<size_t>(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);
}
}

View File

@ -1076,6 +1076,15 @@ std::vector<size_t> chain_points(const Points &points, Point *start_near)
return out;
}
std::vector<size_t> 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 */

View File

@ -12,7 +12,11 @@ namespace ClipperLib { class PolyNode; }
namespace Slic3r {
class ExPolygon;
using ExPolygons = std::vector<ExPolygon>;
std::vector<size_t> chain_points(const Points &points, Point *start_near = nullptr);
std::vector<size_t> chain_expolygons(const ExPolygons &expolygons, Point *start_near = nullptr);
std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr);
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const std::vector<std::pair<size_t, bool>> &chain);

View File

@ -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)

View File

@ -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<double>();
(*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();

View File

@ -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();