Fixed comparison of layer height profiles when printing with wipe tower:
while the layer height profile vector may not contain all print z values, the only real case with two eqiuvalent layer height profiles is when one was created as a copy of another, so the vectors should in fact be equal.
This commit is contained in:
parent
677cb58000
commit
71ba15b6f0
1 changed files with 4 additions and 33 deletions
|
@ -434,6 +434,8 @@ static inline bool sequential_print_vertical_clearance_valid(const Print &print)
|
||||||
return it == print_instances_ordered.end() || (*it)->print_object->height() <= scale_(print.config().extruder_clearance_height.value);
|
return it == print_instances_ordered.end() || (*it)->print_object->height() <= scale_(print.config().extruder_clearance_height.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Precondition: Print::validate() requires the Print::apply() to be called its invocation.
|
// Precondition: Print::validate() requires the Print::apply() to be called its invocation.
|
||||||
std::string Print::validate(std::string* warning) const
|
std::string Print::validate(std::string* warning) const
|
||||||
{
|
{
|
||||||
|
@ -526,42 +528,11 @@ std::string Print::validate(std::string* warning) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_custom_layering) {
|
if (has_custom_layering) {
|
||||||
const std::vector<coordf_t> &layer_height_profile_tallest = layer_height_profiles[tallest_object_idx];
|
|
||||||
for (size_t idx_object = 0; idx_object < m_objects.size(); ++ idx_object) {
|
for (size_t idx_object = 0; idx_object < m_objects.size(); ++ idx_object) {
|
||||||
if (idx_object == tallest_object_idx)
|
if (idx_object == tallest_object_idx)
|
||||||
continue;
|
continue;
|
||||||
const std::vector<coordf_t> &layer_height_profile = layer_height_profiles[idx_object];
|
if (layer_height_profiles[idx_object] != layer_height_profiles[tallest_object_idx])
|
||||||
|
return L("The Wipe tower is only supported if all objects have the same variable layer height");
|
||||||
// The comparison of the profiles is not just about element-wise equality, some layers may not be
|
|
||||||
// explicitely included. Always remember z and height of last reference layer that in the vector
|
|
||||||
// and compare to that. In case some layers are in the vectors multiple times, only the last entry is
|
|
||||||
// taken into account and compared.
|
|
||||||
size_t i = 0; // index into tested profile
|
|
||||||
size_t j = 0; // index into reference profile
|
|
||||||
coordf_t ref_z = -1.;
|
|
||||||
coordf_t next_ref_z = layer_height_profile_tallest[0];
|
|
||||||
coordf_t ref_height = -1.;
|
|
||||||
while (i < layer_height_profile.size()) {
|
|
||||||
coordf_t this_z = layer_height_profile[i];
|
|
||||||
// find the last entry with this z
|
|
||||||
while (i+2 < layer_height_profile.size() && layer_height_profile[i+2] == this_z)
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
coordf_t this_height = layer_height_profile[i+1];
|
|
||||||
if (ref_height < -1. || next_ref_z < this_z + EPSILON) {
|
|
||||||
ref_z = next_ref_z;
|
|
||||||
do { // one layer can be in the vector several times
|
|
||||||
ref_height = layer_height_profile_tallest[j+1];
|
|
||||||
if (j+2 >= layer_height_profile_tallest.size())
|
|
||||||
break;
|
|
||||||
j += 2;
|
|
||||||
next_ref_z = layer_height_profile_tallest[j];
|
|
||||||
} while (ref_z == next_ref_z);
|
|
||||||
}
|
|
||||||
if (std::abs(this_height - ref_height) > EPSILON)
|
|
||||||
return L("The Wipe tower is only supported if all objects have the same variable layer height");
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue