Bugfix in extrusion quality estimator, Refactoring of alerts, rename of autogenerate button
This commit is contained in:
parent
a4de5c6553
commit
c31e3ec1a2
5 changed files with 143 additions and 134 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "Exception.hpp"
|
||||
#include "KDTreeIndirect.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "BoundingBox.hpp"
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
|
@ -425,123 +427,37 @@ void PrintObject::generate_support_spots()
|
|||
this->m_shared_regions->generated_support_points = {this->trafo_centered(), supp_points};
|
||||
m_print->throw_if_canceled();
|
||||
|
||||
auto check_problems = [&]() {
|
||||
std::unordered_map<SupportSpotsGenerator::SupportPointCause, SupportSpotsGenerator::SupportPoints> sp_by_cause{};
|
||||
for (const SupportSpotsGenerator::SupportPoint &sp : supp_points) {
|
||||
sp_by_cause[sp.cause].push_back(sp);
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::SeparationFromBed].empty()) {
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
L("Object part may break from the bed. Consider adding brim and/or supports."));
|
||||
}
|
||||
|
||||
std::reverse(partial_objects.begin(), partial_objects.end());
|
||||
std::sort(partial_objects.begin(), partial_objects.end(),
|
||||
[](const SupportSpotsGenerator::PartialObject &left, const SupportSpotsGenerator::PartialObject &right) {
|
||||
return left.volume > right.volume;
|
||||
});
|
||||
|
||||
float max_volume_part = partial_objects.front().volume;
|
||||
for (const SupportSpotsGenerator::PartialObject &p : partial_objects) {
|
||||
if (p.volume > max_volume_part / 1000.0f && !p.connected_to_bed) {
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
|
||||
L("Floating object parts detected. Please add supports."));
|
||||
return;
|
||||
auto alert_fn = [&](PrintStateBase::WarningLevel level, SupportSpotsGenerator::SupportPointCause cause) {
|
||||
switch (cause) {
|
||||
case SupportSpotsGenerator::SupportPointCause::LongBridge:
|
||||
this->active_step_add_warning(level, L("There are bridges longer than allowed distance. Consider adding supports. "));
|
||||
break;
|
||||
case SupportSpotsGenerator::SupportPointCause::FloatingBridgeAnchor:
|
||||
this->active_step_add_warning(level, L("Unsupported bridges will collapse. Supports are needed."));
|
||||
break;
|
||||
case SupportSpotsGenerator::SupportPointCause::FloatingExtrusion:
|
||||
if (level == PrintStateBase::WarningLevel::CRITICAL) {
|
||||
this->active_step_add_warning(level, L("Clusters of unsupported extrusions found. Supports are needed."));
|
||||
} else {
|
||||
this->active_step_add_warning(level, L("Some unspported extrusions found. Consider adding supports. "));
|
||||
}
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::WeakObjectPart].empty()) {
|
||||
break;
|
||||
case SupportSpotsGenerator::SupportPointCause::SeparationFromBed:
|
||||
this->active_step_add_warning(level, L("Object part may break from the bed. Consider adding brim and/or supports."));
|
||||
break;
|
||||
case SupportSpotsGenerator::SupportPointCause::UnstableFloatingPart:
|
||||
this->active_step_add_warning(level, L("Floating object parts detected. Supports are needed."));
|
||||
break;
|
||||
case SupportSpotsGenerator::SupportPointCause::WeakObjectPart:
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
|
||||
L("Thin parts of the object may break. Please add supports."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::FloatingBridgeAnchor].empty()) {
|
||||
Vec3f last_pos = Vec3f::Zero();
|
||||
size_t count = 0;
|
||||
for (const SupportSpotsGenerator::SupportPoint &sp :
|
||||
sp_by_cause[SupportSpotsGenerator::SupportPointCause::FloatingBridgeAnchor]) {
|
||||
if ((sp.position - last_pos).squaredNorm() < 9.0f) {
|
||||
count++;
|
||||
last_pos = sp.position;
|
||||
} else {
|
||||
last_pos = sp.position;
|
||||
count = 1;
|
||||
}
|
||||
if (count > 1) {
|
||||
this->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::CRITICAL,
|
||||
L("Bridges without supported endpoints will collapse. Please add supports. "));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::LongUnsupportedExtrusion].empty()) {
|
||||
Vec3f last_pos = Vec3f::Zero();
|
||||
size_t count = 0;
|
||||
for (const SupportSpotsGenerator::SupportPoint &sp :
|
||||
sp_by_cause[SupportSpotsGenerator::SupportPointCause::LongUnsupportedExtrusion]) {
|
||||
if ((sp.position - last_pos).squaredNorm() < 9.0f) {
|
||||
count++;
|
||||
last_pos = sp.position;
|
||||
} else {
|
||||
last_pos = sp.position;
|
||||
count = 1;
|
||||
}
|
||||
if (count > 1) {
|
||||
this->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::CRITICAL,
|
||||
L("Long unsupported extrusions will collapse. Please add supports. "));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::LongBridge].empty()) {
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
L("There are bridges longer than allowed distance. Consider adding supports. "));
|
||||
}
|
||||
|
||||
if (!sp_by_cause[SupportSpotsGenerator::SupportPointCause::FloatingExtrusion].empty()) {
|
||||
Vec3f last_pos = Vec3f::Zero();
|
||||
size_t count = 0;
|
||||
bool small_warning = false;
|
||||
for (const SupportSpotsGenerator::SupportPoint &sp :
|
||||
sp_by_cause[SupportSpotsGenerator::SupportPointCause::FloatingExtrusion]) {
|
||||
if ((sp.position - last_pos).squaredNorm() <
|
||||
params.bridge_distance + EPSILON) {
|
||||
count++;
|
||||
last_pos = sp.position;
|
||||
} else {
|
||||
if (count > 6) {
|
||||
this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL,
|
||||
L("Object has large part with loose extrusions. Please enable supports. "));
|
||||
small_warning = false;
|
||||
break;
|
||||
}
|
||||
if (count > 3) {
|
||||
small_warning = true;
|
||||
}
|
||||
|
||||
last_pos = sp.position;
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
if (small_warning) {
|
||||
this->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
L("Object has parts with loose extrusions and may look bad. Consider enabling supports. "));
|
||||
} else if (sp_by_cause[SupportSpotsGenerator::SupportPointCause::FloatingExtrusion].size() > max_volume_part / 100) {
|
||||
this->active_step_add_warning(
|
||||
PrintStateBase::WarningLevel::NON_CRITICAL,
|
||||
L("There are many loose surface extrusions on this object. Consider enabling supports. "));
|
||||
}
|
||||
L("Thin parts of the object may break. Supports are needed."));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
check_problems();
|
||||
if (!this->has_support()) {
|
||||
SupportSpotsGenerator::raise_alerts_for_issues(supp_points, partial_objects, alert_fn);
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(debug) << "Searching support spots - end";
|
||||
this->set_done(posSupportSpotsSearch);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue