Top-surface coloring optimizations
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@
|
||||
#include "ExtrusionEntityCollection.hpp"
|
||||
#include "BoundingBox.hpp"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
namespace Slic3r {
|
||||
|
||||
class ExPolygon;
|
||||
@@ -18,6 +19,9 @@ class LayerRegion;
|
||||
using LayerRegionPtrs = std::vector<LayerRegion*>;
|
||||
class PrintRegion;
|
||||
class PrintObject;
|
||||
class TopSurfaceImageContoningStackPlanCache;
|
||||
|
||||
std::shared_ptr<TopSurfaceImageContoningStackPlanCache> make_top_surface_image_contoning_stack_plan_cache();
|
||||
|
||||
namespace FillAdaptive {
|
||||
struct Octree;
|
||||
@@ -197,7 +201,8 @@ public:
|
||||
void make_fills(FillAdaptive::Octree* adaptive_fill_octree,
|
||||
FillAdaptive::Octree* support_fill_octree,
|
||||
FillLightning::Generator* lightning_generator = nullptr,
|
||||
std::function<void()> throw_if_canceled = {});
|
||||
std::function<void()> throw_if_canceled = {},
|
||||
TopSurfaceImageContoningStackPlanCache *contoning_stack_plan_cache = nullptr);
|
||||
Polylines generate_sparse_infill_polylines_for_anchoring(FillAdaptive::Octree *adaptive_fill_octree,
|
||||
FillAdaptive::Octree *support_fill_octree,
|
||||
FillLightning::Generator* lightning_generator) const;
|
||||
|
||||
@@ -834,25 +834,30 @@ void PrintObject::infill()
|
||||
|
||||
if (this->set_started(posInfill)) {
|
||||
const size_t total_layers = m_layers.size();
|
||||
const auto objects = m_print->objects();
|
||||
const auto object_it = std::find(objects.begin(), objects.end(), this);
|
||||
const size_t object_index = object_it == objects.end() ? 0 : size_t(object_it - objects.begin());
|
||||
std::atomic<size_t> completed_layers { 0 };
|
||||
auto set_infill_progress = [this, total_layers](size_t completed) {
|
||||
auto set_infill_progress = [this, total_layers, object_index](size_t completed) {
|
||||
const std::string message_prefix = Slic3r::format("%1% %2%", L("Generating infill toolpath"), object_index + 1);
|
||||
if (total_layers == 0)
|
||||
m_print->set_status(35, L("Generating infill toolpath"));
|
||||
m_print->set_status(35, message_prefix);
|
||||
else
|
||||
m_print->set_status(35, Slic3r::format(L("Generating infill toolpath (%1%/%2%)"), completed, total_layers));
|
||||
m_print->set_status(35, Slic3r::format("%1% (%2%/%3%)", message_prefix, completed, total_layers));
|
||||
};
|
||||
set_infill_progress(0);
|
||||
const auto& adaptive_fill_octree = this->m_adaptive_fill_octrees.first;
|
||||
const auto& support_fill_octree = this->m_adaptive_fill_octrees.second;
|
||||
const std::function<void()> throw_if_canceled = [this]() { m_print->throw_if_canceled(); };
|
||||
auto contoning_stack_plan_cache = make_top_surface_image_contoning_stack_plan_cache();
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start";
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<size_t>(0, m_layers.size()),
|
||||
[this, &adaptive_fill_octree = adaptive_fill_octree, &support_fill_octree = support_fill_octree, &throw_if_canceled, &completed_layers, &set_infill_progress](const tbb::blocked_range<size_t>& range) {
|
||||
[this, &adaptive_fill_octree = adaptive_fill_octree, &support_fill_octree = support_fill_octree, &throw_if_canceled, &completed_layers, &set_infill_progress, contoning_stack_plan_cache](const tbb::blocked_range<size_t>& range) {
|
||||
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) {
|
||||
m_print->throw_if_canceled();
|
||||
m_layers[layer_idx]->make_fills(adaptive_fill_octree.get(), support_fill_octree.get(), this->m_lightning_generator.get(), throw_if_canceled);
|
||||
m_layers[layer_idx]->make_fills(adaptive_fill_octree.get(), support_fill_octree.get(), this->m_lightning_generator.get(), throw_if_canceled, contoning_stack_plan_cache.get());
|
||||
const size_t completed = completed_layers.fetch_add(1, std::memory_order_relaxed) + 1;
|
||||
set_infill_progress(completed);
|
||||
}
|
||||
|
||||
@@ -1061,6 +1061,7 @@ bool TextureMappingZone::operator==(const TextureMappingZone &rhs) const
|
||||
top_surface_contoning_varied_infill_angles_enabled == rhs.top_surface_contoning_varied_infill_angles_enabled &&
|
||||
top_surface_contoning_blue_noise_error_diffusion_enabled == rhs.top_surface_contoning_blue_noise_error_diffusion_enabled &&
|
||||
top_surface_contoning_supersampled_cells_enabled == rhs.top_surface_contoning_supersampled_cells_enabled &&
|
||||
top_surface_contoning_surface_anchored_stacks_enabled == rhs.top_surface_contoning_surface_anchored_stacks_enabled &&
|
||||
compact_offset_mode == rhs.compact_offset_mode &&
|
||||
use_legacy_fixed_color_mode == rhs.use_legacy_fixed_color_mode &&
|
||||
high_speed_image_texture_sampling == rhs.high_speed_image_texture_sampling &&
|
||||
@@ -1454,6 +1455,8 @@ std::string TextureMappingManager::serialize_entries()
|
||||
zone.top_surface_contoning_blue_noise_error_diffusion_enabled;
|
||||
texture["top_surface_contoning_supersampled_cells_enabled"] =
|
||||
zone.top_surface_contoning_supersampled_cells_enabled;
|
||||
texture["top_surface_contoning_surface_anchored_stacks_enabled"] =
|
||||
zone.top_surface_contoning_surface_anchored_stacks_enabled;
|
||||
texture["compact_offset_mode"] = zone.compact_offset_mode;
|
||||
texture["use_legacy_fixed_color_mode"] = zone.use_legacy_fixed_color_mode;
|
||||
texture["high_speed_image_texture_sampling"] = true;
|
||||
@@ -1732,6 +1735,9 @@ void TextureMappingManager::load_entries(const std::string &serialized,
|
||||
zone.top_surface_contoning_supersampled_cells_enabled =
|
||||
texture.value("top_surface_contoning_supersampled_cells_enabled",
|
||||
TextureMappingZone::DefaultTopSurfaceContoningSupersampledCellsEnabled);
|
||||
zone.top_surface_contoning_surface_anchored_stacks_enabled =
|
||||
texture.value("top_surface_contoning_surface_anchored_stacks_enabled",
|
||||
TextureMappingZone::DefaultTopSurfaceContoningSurfaceAnchoredStacksEnabled);
|
||||
zone.compact_offset_mode = texture.value("compact_offset_mode", TextureMappingZone::DefaultCompactOffsetMode);
|
||||
zone.use_legacy_fixed_color_mode =
|
||||
texture.value("use_legacy_fixed_color_mode", TextureMappingZone::DefaultUseLegacyFixedColorMode);
|
||||
|
||||
@@ -183,6 +183,7 @@ struct TextureMappingZone
|
||||
static constexpr bool DefaultTopSurfaceContoningVariedInfillAnglesEnabled = false;
|
||||
static constexpr bool DefaultTopSurfaceContoningBlueNoiseErrorDiffusionEnabled = false;
|
||||
static constexpr bool DefaultTopSurfaceContoningSupersampledCellsEnabled = false;
|
||||
static constexpr bool DefaultTopSurfaceContoningSurfaceAnchoredStacksEnabled = false;
|
||||
static constexpr bool DefaultCompactOffsetMode = true;
|
||||
static constexpr bool DefaultUseLegacyFixedColorMode = false;
|
||||
static constexpr bool DefaultHighSpeedImageTextureSampling = true;
|
||||
@@ -290,6 +291,7 @@ struct TextureMappingZone
|
||||
bool top_surface_contoning_varied_infill_angles_enabled = DefaultTopSurfaceContoningVariedInfillAnglesEnabled;
|
||||
bool top_surface_contoning_blue_noise_error_diffusion_enabled = DefaultTopSurfaceContoningBlueNoiseErrorDiffusionEnabled;
|
||||
bool top_surface_contoning_supersampled_cells_enabled = DefaultTopSurfaceContoningSupersampledCellsEnabled;
|
||||
bool top_surface_contoning_surface_anchored_stacks_enabled = DefaultTopSurfaceContoningSurfaceAnchoredStacksEnabled;
|
||||
bool compact_offset_mode = DefaultCompactOffsetMode;
|
||||
bool use_legacy_fixed_color_mode = DefaultUseLegacyFixedColorMode;
|
||||
bool high_speed_image_texture_sampling = DefaultHighSpeedImageTextureSampling;
|
||||
@@ -413,6 +415,7 @@ struct TextureMappingZone
|
||||
top_surface_contoning_varied_infill_angles_enabled = DefaultTopSurfaceContoningVariedInfillAnglesEnabled;
|
||||
top_surface_contoning_blue_noise_error_diffusion_enabled = DefaultTopSurfaceContoningBlueNoiseErrorDiffusionEnabled;
|
||||
top_surface_contoning_supersampled_cells_enabled = DefaultTopSurfaceContoningSupersampledCellsEnabled;
|
||||
top_surface_contoning_surface_anchored_stacks_enabled = DefaultTopSurfaceContoningSurfaceAnchoredStacksEnabled;
|
||||
compact_offset_mode = DefaultCompactOffsetMode;
|
||||
use_legacy_fixed_color_mode = DefaultUseLegacyFixedColorMode;
|
||||
high_speed_image_texture_sampling = DefaultHighSpeedImageTextureSampling;
|
||||
|
||||
@@ -572,6 +572,20 @@ bool BackgroundSlicingProcess::stop()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BackgroundSlicingProcess::cancel()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ", enter"<<std::endl;
|
||||
std::unique_lock<std::mutex> lck(m_mutex);
|
||||
if (m_state == STATE_INITIAL || m_state == STATE_IDLE)
|
||||
return false;
|
||||
if (m_state == STATE_STARTED || m_state == STATE_RUNNING) {
|
||||
cancel_ui_task(m_ui_task);
|
||||
m_print->cancel();
|
||||
return true;
|
||||
}
|
||||
return m_state == STATE_FINISHED || m_state == STATE_CANCELED;
|
||||
}
|
||||
|
||||
bool BackgroundSlicingProcess::reset()
|
||||
{
|
||||
bool stopped = this->stop();
|
||||
|
||||
@@ -131,6 +131,7 @@ public:
|
||||
// Cancel the background processing. Returns false if the background processing was not running.
|
||||
// A stopped background processing may be restarted with start().
|
||||
bool stop();
|
||||
bool cancel();
|
||||
// Cancel the background processing and reset the print. Returns false if the background processing was not running.
|
||||
// Useful when the Model or configuration is being changed drastically.
|
||||
bool reset();
|
||||
|
||||
@@ -1912,6 +1912,7 @@ public:
|
||||
bool top_surface_contoning_varied_infill_angles_enabled,
|
||||
bool top_surface_contoning_blue_noise_error_diffusion_enabled,
|
||||
bool top_surface_contoning_supersampled_cells_enabled,
|
||||
bool top_surface_contoning_surface_anchored_stacks_enabled,
|
||||
const TextureMappingManager &texture_mapping_zones,
|
||||
const TextureMappingGlobalSettings &global_settings,
|
||||
const TextureMappingPrimeTowerImage &prime_tower_image,
|
||||
@@ -2634,6 +2635,15 @@ public:
|
||||
0,
|
||||
wxEXPAND | wxTOP | wxBOTTOM,
|
||||
gap / 2);
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox =
|
||||
new wxCheckBox(m_top_surface_contoning_checkboxes_panel, wxID_ANY, _L("Surface-anchored stacks"));
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox->SetValue(top_surface_contoning_surface_anchored_stacks_enabled);
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox->SetMinSize(
|
||||
wxSize(-1, std::max(m_top_surface_contoning_surface_anchored_stacks_checkbox->GetBestSize().GetHeight(), FromDIP(24))));
|
||||
contoning_checkboxes_root->Add(m_top_surface_contoning_surface_anchored_stacks_checkbox,
|
||||
0,
|
||||
wxEXPAND | wxTOP | wxBOTTOM,
|
||||
gap / 2);
|
||||
top_surface_box->Add(m_top_surface_contoning_checkboxes_panel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, gap);
|
||||
m_top_surface_contoning_only_color_surface_infill_checkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &) {
|
||||
update_top_surface_image_options_visibility(true);
|
||||
@@ -3046,6 +3056,12 @@ public:
|
||||
return m_top_surface_contoning_supersampled_cells_checkbox != nullptr &&
|
||||
m_top_surface_contoning_supersampled_cells_checkbox->GetValue();
|
||||
}
|
||||
bool top_surface_contoning_surface_anchored_stacks_enabled() const
|
||||
{
|
||||
return m_top_surface_contoning_surface_anchored_stacks_checkbox == nullptr ?
|
||||
TextureMappingZone::DefaultTopSurfaceContoningSurfaceAnchoredStacksEnabled :
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox->GetValue();
|
||||
}
|
||||
bool minimum_visibility_offset_enabled() const
|
||||
{
|
||||
return m_minimum_visibility_offset_checkbox && m_minimum_visibility_offset_checkbox->GetValue();
|
||||
@@ -3533,6 +3549,10 @@ private:
|
||||
m_top_surface_contoning_supersampled_cells_checkbox->Show(contoning);
|
||||
m_top_surface_contoning_supersampled_cells_checkbox->Enable(contoning);
|
||||
}
|
||||
if (m_top_surface_contoning_surface_anchored_stacks_checkbox != nullptr) {
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox->Show(contoning);
|
||||
m_top_surface_contoning_surface_anchored_stacks_checkbox->Enable(contoning);
|
||||
}
|
||||
if (m_top_surface_image_fixed_coloring_filaments_checkbox != nullptr) {
|
||||
m_top_surface_image_fixed_coloring_filaments_checkbox->Show(!contoning_selected);
|
||||
m_top_surface_image_fixed_coloring_filaments_checkbox->Enable(enabled && !contoning_selected);
|
||||
@@ -3603,6 +3623,7 @@ private:
|
||||
wxCheckBox *m_top_surface_contoning_varied_infill_angles_checkbox {nullptr};
|
||||
wxCheckBox *m_top_surface_contoning_blue_noise_error_diffusion_checkbox {nullptr};
|
||||
wxCheckBox *m_top_surface_contoning_supersampled_cells_checkbox {nullptr};
|
||||
wxCheckBox *m_top_surface_contoning_surface_anchored_stacks_checkbox {nullptr};
|
||||
wxCheckBox *m_use_legacy_fixed_color_mode_checkbox {nullptr};
|
||||
wxCheckBox *m_minimum_visibility_offset_checkbox {nullptr};
|
||||
wxSpinCtrl *m_minimum_visibility_offset_spin {nullptr};
|
||||
@@ -8611,6 +8632,7 @@ void Sidebar::update_texture_mapping_panel(bool sync_manager)
|
||||
updated.top_surface_contoning_varied_infill_angles_enabled,
|
||||
updated.top_surface_contoning_blue_noise_error_diffusion_enabled,
|
||||
updated.top_surface_contoning_supersampled_cells_enabled,
|
||||
updated.top_surface_contoning_surface_anchored_stacks_enabled,
|
||||
bundle->texture_mapping_zones,
|
||||
bundle->texture_mapping_global_settings,
|
||||
wxGetApp().model().texture_mapping_prime_tower_image,
|
||||
@@ -8678,6 +8700,8 @@ void Sidebar::update_texture_mapping_panel(bool sync_manager)
|
||||
dlg.top_surface_contoning_blue_noise_error_diffusion_enabled();
|
||||
updated.top_surface_contoning_supersampled_cells_enabled =
|
||||
dlg.top_surface_contoning_supersampled_cells_enabled();
|
||||
updated.top_surface_contoning_surface_anchored_stacks_enabled =
|
||||
dlg.top_surface_contoning_surface_anchored_stacks_enabled();
|
||||
if (updated.top_surface_image_printing_enabled &&
|
||||
updated.top_surface_image_printing_method == int(TextureMappingZone::TopSurfaceImageContoning)) {
|
||||
updated.modulation_mode = int(TextureMappingZone::ModulationPerimeterPathV2);
|
||||
@@ -15944,8 +15968,7 @@ void Plater::priv::init_notification_manager()
|
||||
auto cancel_callback = [this]() {
|
||||
if (this->background_process.idle())
|
||||
return false;
|
||||
this->background_process.stop();
|
||||
return true;
|
||||
return this->background_process.cancel();
|
||||
};
|
||||
notification_manager->init_slicing_progress_notification(cancel_callback);
|
||||
notification_manager->set_fff(printer_technology == ptFFF);
|
||||
|
||||
@@ -70,6 +70,7 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
|
||||
set_percentage(-1);
|
||||
m_has_print_info = false;
|
||||
set_export_possible(false);
|
||||
m_cancel_requested = false;
|
||||
m_sp_state = state;
|
||||
return true;
|
||||
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_BEGAN:
|
||||
@@ -77,6 +78,7 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
|
||||
set_percentage(-1);
|
||||
m_has_print_info = false;
|
||||
set_export_possible(false);
|
||||
m_cancel_requested = false;
|
||||
m_sp_state = state;
|
||||
m_current_fade_opacity = 1;
|
||||
return true;
|
||||
@@ -91,6 +93,7 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
|
||||
set_percentage(-1);
|
||||
m_has_print_info = false;
|
||||
set_export_possible(false);
|
||||
m_cancel_requested = false;
|
||||
m_sp_state = state;
|
||||
return true;
|
||||
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_COMPLETED:
|
||||
@@ -100,6 +103,7 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
|
||||
m_has_print_info = false;
|
||||
// m_export_possible is important only for SP_PROGRESS state, thus we can reset it here
|
||||
set_export_possible(false);
|
||||
m_cancel_requested = false;
|
||||
m_sp_state = state;
|
||||
return true;
|
||||
default:
|
||||
@@ -117,7 +121,8 @@ void NotificationManager::SlicingProgressNotification::set_status_text(const std
|
||||
break;
|
||||
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_PROGRESS:
|
||||
{
|
||||
NotificationData data{ NotificationType::SlicingProgress, NotificationLevel::ProgressBarNotificationLevel, 0, text + "." };
|
||||
NotificationData data{ NotificationType::SlicingProgress, NotificationLevel::ProgressBarNotificationLevel, 0,
|
||||
m_cancel_requested ? _u8L("Cancelling...") : text + "." };
|
||||
update(data);
|
||||
m_state = EState::NotFading;
|
||||
}
|
||||
@@ -163,6 +168,9 @@ void NotificationManager::SlicingProgressNotification::on_cancel_button()
|
||||
if (m_cancel_callback){
|
||||
if (!m_cancel_callback()) {
|
||||
set_progress_state(SlicingProgressState::SP_NO_SLICING);
|
||||
} else {
|
||||
m_cancel_requested = true;
|
||||
set_status_text(_u8L("Cancelling..."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,4 +499,4 @@ void NotificationManager::SlicingProgressNotification::render_close_button(const
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
}}
|
||||
|
||||
@@ -71,6 +71,7 @@ protected:
|
||||
// if returns false, process was already canceled
|
||||
std::function<bool()> m_cancel_callback;
|
||||
SlicingProgressState m_sp_state{ SlicingProgressState::SP_PROGRESS };
|
||||
bool m_cancel_requested{ false };
|
||||
bool m_sidebar_collapsed{ false };
|
||||
// if true, it is possible show export hyperlink in state SP_PROGRESS
|
||||
bool m_export_possible{ false };
|
||||
@@ -84,4 +85,4 @@ protected:
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user