Background processing: Fixed rotation & scaling of PrintObjects.

This commit is contained in:
bubnikv 2018-10-24 11:48:39 +02:00
parent 6c38cb2c32
commit 197458cf3a
4 changed files with 8 additions and 7 deletions

View file

@ -946,6 +946,7 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co
// Simple case, just generate new instances. // Simple case, just generate new instances.
for (const PrintInstances &print_instances : new_print_instances) { for (const PrintInstances &print_instances : new_print_instances) {
PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box()); PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box());
print_object->set_trafo(print_instances.trafo);
print_object->set_copies(print_instances.copies); print_object->set_copies(print_instances.copies);
print_object->config_apply(config); print_object->config_apply(config);
print_objects_new.emplace_back(print_object); print_objects_new.emplace_back(print_object);
@ -959,10 +960,11 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co
// Merge the old / new lists. // Merge the old / new lists.
auto it_old = old.begin(); auto it_old = old.begin();
for (const PrintInstances &new_instances : new_print_instances) { for (const PrintInstances &new_instances : new_print_instances) {
for (; transform3d_lower((*it_old)->trafo, new_instances.trafo); ++ it_old); for (; it_old != old.end() && transform3d_lower((*it_old)->trafo, new_instances.trafo); ++ it_old);
if (! transform3d_equal((*it_old)->trafo, new_instances.trafo)) { if (it_old == old.end() || ! transform3d_equal((*it_old)->trafo, new_instances.trafo)) {
// This is a new instance (or a set of instances with the same trafo). Just add it. // This is a new instance (or a set of instances with the same trafo). Just add it.
PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box()); PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box());
print_object->set_trafo(new_instances.trafo);
print_object->set_copies(new_instances.copies); print_object->set_copies(new_instances.copies);
print_object->config_apply(config); print_object->config_apply(config);
print_objects_new.emplace_back(print_object); print_objects_new.emplace_back(print_object);

View file

@ -203,7 +203,9 @@ public:
void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false) { this->m_config.apply_only(other, keys, ignore_nonexistent); } void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false) { this->m_config.apply_only(other, keys, ignore_nonexistent); }
const LayerPtrs& layers() const { return m_layers; } const LayerPtrs& layers() const { return m_layers; }
const SupportLayerPtrs& support_layers() const { return m_support_layers; } const SupportLayerPtrs& support_layers() const { return m_support_layers; }
const Transform3d& trafo() const { return m_trafo; } const Transform3d& trafo() const { return m_trafo; }
void set_trafo(const Transform3d& trafo) { m_trafo = trafo; }
const Points& copies() const { return m_copies; } const Points& copies() const { return m_copies; }
bool add_copy(const Vec2d &point); bool add_copy(const Vec2d &point);

View file

@ -1615,10 +1615,7 @@ std::vector<ExPolygons> PrintObject::_slice_volumes(const std::vector<float> &z,
for (const ModelVolume *v : volumes) for (const ModelVolume *v : volumes)
mesh.merge(v->mesh); mesh.merge(v->mesh);
if (mesh.stl.stats.number_of_facets > 0) { if (mesh.stl.stats.number_of_facets > 0) {
// transform mesh mesh.transform(m_trafo.cast<float>());
// we ignore the per-instance transformations currently and only
// consider the first one
this->model_object()->instances.front()->transform_mesh(&mesh, true);
// align mesh to Z = 0 (it should be already aligned actually) and apply XY shift // align mesh to Z = 0 (it should be already aligned actually) and apply XY shift
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), - float(this->model_object()->bounding_box().min(2))); mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), - float(this->model_object()->bounding_box().min(2)));
// perform actual slicing // perform actual slicing

View file

@ -2408,7 +2408,7 @@ void Plater::reslice()
// Don't reslice if export of G-code or sending to OctoPrint is running. // Don't reslice if export of G-code or sending to OctoPrint is running.
// if (! defined($self->{export_gcode_output_file}) && ! defined($self->{send_gcode_file})) { // if (! defined($self->{export_gcode_output_file}) && ! defined($self->{send_gcode_file})) {
// Stop the background processing threads, stop the async update timer. // Stop the background processing threads, stop the async update timer.
this->p->stop_background_process(); // this->p->stop_background_process();
// Rather perform one additional unnecessary update of the print object instead of skipping a pending async update. // Rather perform one additional unnecessary update of the print object instead of skipping a pending async update.
this->p->async_apply_config(); this->p->async_apply_config();
/* /*