Added invalidation of the sliced object when gap-fill enabled/disabled if the object is painted using the multi-material painting gizmo.

Filtering of unprintable regions in multi-material segmentation depends on if gap-fill is enabled or not. So sliced object is invalidated when gap-fill was enabled/disabled by option "gap_fill_enabled" or by changing "gap_fill_speed" to force recomputation of the multi-material segmentation.
This commit is contained in:
Lukáš Hejl 2021-07-29 13:02:33 +02:00
parent b16aada962
commit 742a373c1f
4 changed files with 32 additions and 2 deletions

View File

@ -725,6 +725,11 @@ void ModelObject::clear_volumes()
this->invalidate_bounding_box(); this->invalidate_bounding_box();
} }
bool ModelObject::is_mm_painted() const
{
return std::any_of(this->volumes.cbegin(), this->volumes.cend(), [](const ModelVolume *mv) { return mv->is_mm_painted(); });
}
void ModelObject::sort_volumes(bool full_sort) void ModelObject::sort_volumes(bool full_sort)
{ {
// sort volumes inside the object to order "Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. " // sort volumes inside the object to order "Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. "

View File

@ -285,6 +285,8 @@ public:
void clear_volumes(); void clear_volumes();
void sort_volumes(bool full_sort); void sort_volumes(bool full_sort);
bool is_multiparts() const { return volumes.size() > 1; } bool is_multiparts() const { return volumes.size() > 1; }
// Checks if any of object volume is painted using the multi-material painting gizmo.
bool is_mm_painted() const;
ModelInstance* add_instance(); ModelInstance* add_instance();
ModelInstance* add_instance(const ModelInstance &instance); ModelInstance* add_instance(const ModelInstance &instance);
@ -715,6 +717,8 @@ public:
this->mmu_segmentation_facets.set_new_unique_id(); this->mmu_segmentation_facets.set_new_unique_id();
} }
bool is_mm_painted() const { return !this->mmu_segmentation_facets.empty(); }
protected: protected:
friend class Print; friend class Print;
friend class SLAPrint; friend class SLAPrint;

View File

@ -317,6 +317,8 @@ public:
bool has_support() const { return m_config.support_material || m_config.support_material_enforce_layers > 0; } bool has_support() const { return m_config.support_material || m_config.support_material_enforce_layers > 0; }
bool has_raft() const { return m_config.raft_layers > 0; } bool has_raft() const { return m_config.raft_layers > 0; }
bool has_support_material() const { return this->has_support() || this->has_raft(); } bool has_support_material() const { return this->has_support() || this->has_raft(); }
// Checks if the model object is painted using the multi-material painting gizmo.
bool is_mm_painted() const { return this->model_object()->is_mm_painted(); };
// returns 0-based indices of extruders used to print the object (without brim, support and other helper extrusions) // returns 0-based indices of extruders used to print the object (without brim, support and other helper extrusions)
std::vector<unsigned int> object_extruders() const; std::vector<unsigned int> object_extruders() const;

View File

@ -509,13 +509,32 @@ bool PrintObject::invalidate_state_by_config_options(
} else if ( } else if (
opt_key == "perimeters" opt_key == "perimeters"
|| opt_key == "extra_perimeters" || opt_key == "extra_perimeters"
|| opt_key == "gap_fill_enabled"
|| opt_key == "gap_fill_speed"
|| opt_key == "first_layer_extrusion_width" || opt_key == "first_layer_extrusion_width"
|| opt_key == "perimeter_extrusion_width" || opt_key == "perimeter_extrusion_width"
|| opt_key == "infill_overlap" || opt_key == "infill_overlap"
|| opt_key == "external_perimeters_first") { || opt_key == "external_perimeters_first") {
steps.emplace_back(posPerimeters); steps.emplace_back(posPerimeters);
} else if (
opt_key == "gap_fill_enabled"
|| opt_key == "gap_fill_speed") {
// Return true if gap-fill speed has changed from zero value to non-zero or from non-zero value to zero.
auto is_gap_fill_changed_state_due_to_speed = [&opt_key, &old_config, &new_config]() -> bool {
if (opt_key == "gap_fill_speed") {
const auto *old_gap_fill_speed = old_config.option<ConfigOptionFloat>(opt_key);
const auto *new_gap_fill_speed = new_config.option<ConfigOptionFloat>(opt_key);
assert(old_gap_fill_speed && new_gap_fill_speed);
return (old_gap_fill_speed->value > 0.f && new_gap_fill_speed->value == 0.f) ||
(old_gap_fill_speed->value == 0.f && new_gap_fill_speed->value > 0.f);
}
return false;
};
// Filtering of unprintable regions in multi-material segmentation depends on if gap-fill is enabled or not.
// So step posSlice is invalidated when gap-fill was enabled/disabled by option "gap_fill_enabled" or by
// changing "gap_fill_speed" to force recomputation of the multi-material segmentation.
if (this->is_mm_painted() && (opt_key == "gap_fill_enabled" || (opt_key == "gap_fill_speed" && is_gap_fill_changed_state_due_to_speed())))
steps.emplace_back(posSlice);
steps.emplace_back(posPerimeters);
} else if ( } else if (
opt_key == "layer_height" opt_key == "layer_height"
|| opt_key == "first_layer_height" || opt_key == "first_layer_height"