WIP TreeSupports: Fixed some compiler warnings and errors.

This commit is contained in:
Vojtech Bubnik 2022-08-23 12:04:18 +02:00
parent b9e7cd2d7b
commit bfbfdaedb9
2 changed files with 9 additions and 5 deletions

View File

@ -575,12 +575,14 @@ private:
switch (type) { switch (type) {
case AvoidanceType::Fast: return m_avoidance_cache_to_model; case AvoidanceType::Fast: return m_avoidance_cache_to_model;
case AvoidanceType::Slow: return m_avoidance_cache_to_model_slow; case AvoidanceType::Slow: return m_avoidance_cache_to_model_slow;
case AvoidanceType::Count: assert(false);
case AvoidanceType::FastSafe: return m_avoidance_cache_holefree_to_model; case AvoidanceType::FastSafe: return m_avoidance_cache_holefree_to_model;
} }
} else { } else {
switch (type) { switch (type) {
case AvoidanceType::Fast: return m_avoidance_cache; case AvoidanceType::Fast: return m_avoidance_cache;
case AvoidanceType::Slow: return m_avoidance_cache_slow; case AvoidanceType::Slow: return m_avoidance_cache_slow;
case AvoidanceType::Count: assert(false);
case AvoidanceType::FastSafe: return m_avoidance_cache_holefree; case AvoidanceType::FastSafe: return m_avoidance_cache_holefree;
} }
} }

View File

@ -186,7 +186,9 @@ static std::vector<std::pair<TreeSupport::TreeSupportSettings, std::vector<size_
// as different settings in the same group may only occur in the tip, which uses the original settings objects from the meshes. // as different settings in the same group may only occur in the tip, which uses the original settings objects from the meshes.
for (size_t object_id = 0; object_id < print_object_ids.size(); ++ object_id) { for (size_t object_id = 0; object_id < print_object_ids.size(); ++ object_id) {
const PrintObject &print_object = *print.get_object(object_id); const PrintObject &print_object = *print.get_object(object_id);
#ifndef _NDEBUG
const PrintObjectConfig &object_config = print_object.config(); const PrintObjectConfig &object_config = print_object.config();
#endif // _NDEBUG
// Support must be enabled and set to Tree style. // Support must be enabled and set to Tree style.
assert(object_config.support_material); assert(object_config.support_material);
assert(object_config.support_material_style == smsTree); assert(object_config.support_material_style == smsTree);
@ -243,11 +245,11 @@ static bool inline g_showed_performance_warning = false;
void TreeSupport::showError(std::string message, bool critical) void TreeSupport::showError(std::string message, bool critical)
{ // todo Remove! ONLY FOR PUBLIC BETA!! { // todo Remove! ONLY FOR PUBLIC BETA!!
std::string bugtype = std::string(critical ? " This is a critical bug. It may cause missing or malformed branches.\n" : "This bug should only decrease performance.\n"); #if defined(_WIN32) && defined(TREE_SUPPORT_SHOW_ERRORS)
bool show = (critical && !g_showed_critical_error) || (!critical && !g_showed_performance_warning); auto bugtype = std::string(critical ? " This is a critical bug. It may cause missing or malformed branches.\n" : "This bug should only decrease performance.\n");
bool show = (critical && !g_showed_critical_error) || (!critical && !g_showed_performance_warning);
(critical ? g_showed_critical_error : g_showed_performance_warning) = true; (critical ? g_showed_critical_error : g_showed_performance_warning) = true;
#if defined(_WIN32) && defined(TREE_SUPPORT_SHOW_ERRORS)
if (show) if (show)
MessageBoxA(nullptr, std::string("TreeSupport_2 MOD detected an error while generating the tree support.\nPlease report this back to me with profile and model.\nRevision 5.0\n" + message + "\n" + bugtype).c_str(), MessageBoxA(nullptr, std::string("TreeSupport_2 MOD detected an error while generating the tree support.\nPlease report this back to me with profile and model.\nRevision 5.0\n" + message + "\n" + bugtype).c_str(),
"Bug detected!", MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND | MB_ICONWARNING); "Bug detected!", MB_OK | MB_SYSTEMMODAL | MB_SETFOREGROUND | MB_ICONWARNING);
@ -312,7 +314,7 @@ static bool layer_has_overhangs(const Layer &layer)
* \param storage[in] Background storage to access meshes. * \param storage[in] Background storage to access meshes.
* \param currently_processing_meshes[in] Indexes of all meshes that are processed in this iteration * \param currently_processing_meshes[in] Indexes of all meshes that are processed in this iteration
*/ */
static [[nodiscard]] LayerIndex precalculate(const Print &print, const std::vector<Polygons> &overhangs, const TreeSupport::TreeSupportSettings &config, const std::vector<size_t> &object_ids, TreeModelVolumes &volumes) [[nodiscard]] static LayerIndex precalculate(const Print &print, const std::vector<Polygons> &overhangs, const TreeSupport::TreeSupportSettings &config, const std::vector<size_t> &object_ids, TreeModelVolumes &volumes)
{ {
// calculate top most layer that is relevant for support // calculate top most layer that is relevant for support
LayerIndex max_layer = 0; LayerIndex max_layer = 0;
@ -2450,7 +2452,7 @@ void TreeSupport::generateBranchAreas(
else { else {
// try a fuzzy inside as sometimes the point should be on the border, but is not because of rounding errors... // try a fuzzy inside as sometimes the point should be on the border, but is not because of rounding errors...
Point from = elem->result_on_layer; Point from = elem->result_on_layer;
Polygons &to = to_polygons(std::move(part)); Polygons to = to_polygons(std::move(part));
moveInside(to, from, 0); moveInside(to, from, 0);
if ((elem->result_on_layer - from).cast<double>().norm() < scaled<double>(0.025)) if ((elem->result_on_layer - from).cast<double>().norm() < scaled<double>(0.025))
polygons_with_correct_center = union_(polygons_with_correct_center, to); polygons_with_correct_center = union_(polygons_with_correct_center, to);