Tech ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION set as default

This commit is contained in:
enricoturri1966 2023-04-27 08:49:56 +02:00 committed by Lukas Matena
parent 417c85b83b
commit 6944c30f87
10 changed files with 6 additions and 68 deletions

View File

@ -1,8 +1,6 @@
#include "libslic3r.h" #include "libslic3r.h"
#include "ConflictChecker.hpp" #include "ConflictChecker.hpp"
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#include <tbb/parallel_for.h> #include <tbb/parallel_for.h>
#include <tbb/concurrent_vector.h> #include <tbb/concurrent_vector.h>
@ -280,4 +278,3 @@ ConflictComputeOpt ConflictChecker::line_intersect(const LineWithID &l1, const L
} // namespace Slic3r } // namespace Slic3r
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION

View File

@ -1,8 +1,6 @@
#ifndef slic3r_ConflictChecker_hpp_ #ifndef slic3r_ConflictChecker_hpp_
#define slic3r_ConflictChecker_hpp_ #define slic3r_ConflictChecker_hpp_
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#include "../Utils.hpp" #include "../Utils.hpp"
#include "../Model.hpp" #include "../Model.hpp"
#include "../Print.hpp" #include "../Print.hpp"
@ -122,6 +120,4 @@ struct ConflictChecker
} // namespace Slic3r } // namespace Slic3r
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#endif #endif

View File

@ -82,7 +82,6 @@ namespace Slic3r {
} }
}; };
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
struct ConflictResult struct ConflictResult
{ {
std::string _objName1; std::string _objName1;
@ -98,7 +97,6 @@ namespace Slic3r {
}; };
using ConflictResultOpt = std::optional<ConflictResult>; using ConflictResultOpt = std::optional<ConflictResult>;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
struct GCodeProcessorResult struct GCodeProcessorResult
{ {
@ -155,9 +153,7 @@ namespace Slic3r {
std::vector<CustomGCode::Item> custom_gcode_per_print_z; std::vector<CustomGCode::Item> custom_gcode_per_print_z;
std::vector<std::pair<float, std::pair<size_t, size_t>>> spiral_vase_layers; std::vector<std::pair<float, std::pair<size_t, size_t>>> spiral_vase_layers;
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
ConflictResultOpt conflict_result; ConflictResultOpt conflict_result;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
int64_t time{ 0 }; int64_t time{ 0 };

View File

@ -11,9 +11,7 @@
#include "Thread.hpp" #include "Thread.hpp"
#include "GCode.hpp" #include "GCode.hpp"
#include "GCode/WipeTower.hpp" #include "GCode/WipeTower.hpp"
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#include "GCode/ConflictChecker.hpp" #include "GCode/ConflictChecker.hpp"
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
#include "Utils.hpp" #include "Utils.hpp"
#include "BuildVolume.hpp" #include "BuildVolume.hpp"
#include "format.hpp" #include "format.hpp"
@ -966,7 +964,6 @@ void Print::process()
this->set_done(psSkirtBrim); this->set_done(psSkirtBrim);
} }
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
std::optional<const FakeWipeTower*> wipe_tower_opt = {}; std::optional<const FakeWipeTower*> wipe_tower_opt = {};
if (this->has_wipe_tower()) { if (this->has_wipe_tower()) {
m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x, m_config.wipe_tower_y }); m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x, m_config.wipe_tower_y });
@ -977,7 +974,6 @@ void Print::process()
m_conflict_result = conflictRes; m_conflict_result = conflictRes;
if (conflictRes.has_value()) if (conflictRes.has_value())
BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%") % conflictRes->_objName1 % conflictRes->_objName2; BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%") % conflictRes->_objName1 % conflictRes->_objName2;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
BOOST_LOG_TRIVIAL(info) << "Slicing process finished." << log_memory_info(); BOOST_LOG_TRIVIAL(info) << "Slicing process finished." << log_memory_info();
} }
@ -1005,9 +1001,7 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
std::unique_ptr<GCode> gcode(new GCode); std::unique_ptr<GCode> gcode(new GCode);
gcode->do_export(this, path.c_str(), result, thumbnail_cb); gcode->do_export(this, path.c_str(), result, thumbnail_cb);
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
result->conflict_result = m_conflict_result; result->conflict_result = m_conflict_result;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
return path.c_str(); return path.c_str();
} }

View File

@ -418,7 +418,6 @@ private:
FillLightning::GeneratorPtr m_lightning_generator; FillLightning::GeneratorPtr m_lightning_generator;
}; };
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
struct FakeWipeTower struct FakeWipeTower
{ {
// generate fake extrusion // generate fake extrusion
@ -462,7 +461,6 @@ struct FakeWipeTower
return paths; return paths;
} }
}; };
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
struct WipeTowerData struct WipeTowerData
{ {
@ -715,10 +713,8 @@ private:
// Allow PrintObject to access m_mutex and m_cancel_callback. // Allow PrintObject to access m_mutex and m_cancel_callback.
friend class PrintObject; friend class PrintObject;
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
ConflictResultOpt m_conflict_result; ConflictResultOpt m_conflict_result;
FakeWipeTower m_fake_wipe_tower; FakeWipeTower m_fake_wipe_tower;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
}; };
} /* slic3r_Print_hpp_ */ } /* slic3r_Print_hpp_ */

View File

@ -62,22 +62,4 @@
#define ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR (1 && ENABLE_2_6_0_ALPHA1) #define ENABLE_ALTERNATIVE_FILE_WILDCARDS_GENERATOR (1 && ENABLE_2_6_0_ALPHA1)
//====================
// 2.6.0.beta1 techs
//====================
#define ENABLE_2_6_0_BETA1 1
// Toolpaths conflicts detection
// Succesfully enhanced and integrated into PrusaSlicer from BambuStudio:
// https://github.com/bambulab/BambuStudio/commit/d43c7d5c9293508241ee88cee860ea7ea51c2080
// https://github.com/bambulab/BambuStudio/commit/d72b4c1bfe3f0c275241250a0b1797944147b3b7
// https://github.com/bambulab/BambuStudio/commit/87eb0f366560b895cb7219a2eb6820027aaf69d3
// https://github.com/bambulab/BambuStudio/commit/b5b7264e99ea0872d39455bf61af56209cb4cd39
// Co-authored-by: manch1n <miaoxin.chen@bambulab.com>
// Co-authored-by: miaoxin <miaoxin.chen@bambulab.com>
// Co-authored-by: lane.wei <lane.wei@bambulab.com>
#define ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION (1 && ENABLE_2_6_0_BETA1)
#endif // _prusaslicer_technologies_h_ #endif // _prusaslicer_technologies_h_

View File

@ -800,10 +800,8 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_time_estimate_mode = PrintEstimatedStatistics::ETimeMode::Normal; m_time_estimate_mode = PrintEstimatedStatistics::ETimeMode::Normal;
} }
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
m_conflict_result = gcode_result.conflict_result; m_conflict_result = gcode_result.conflict_result;
if (m_conflict_result.has_value()) { m_conflict_result->layer = m_layers.get_l_at(m_conflict_result->_height); } if (m_conflict_result.has_value()) { m_conflict_result->layer = m_layers.get_l_at(m_conflict_result->_height); }
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
} }
void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors) void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)

View File

@ -526,12 +526,10 @@ class GCodeViewer
std::vector<Range>& get_ranges() { return m_ranges; } std::vector<Range>& get_ranges() { return m_ranges; }
double get_z_at(unsigned int id) const { return (id < m_zs.size()) ? m_zs[id] : 0.0; } double get_z_at(unsigned int id) const { return (id < m_zs.size()) ? m_zs[id] : 0.0; }
Range get_range_at(unsigned int id) const { return (id < m_ranges.size()) ? m_ranges[id] : Range(); } Range get_range_at(unsigned int id) const { return (id < m_ranges.size()) ? m_ranges[id] : Range(); }
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
int get_l_at(double z) const { int get_l_at(double z) const {
auto iter = std::upper_bound(m_zs.begin(), m_zs.end(), z); auto iter = std::upper_bound(m_zs.begin(), m_zs.end(), z);
return std::distance(m_zs.begin(), iter); return std::distance(m_zs.begin(), iter);
} }
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
bool operator != (const Layers& other) const { bool operator != (const Layers& other) const {
if (m_zs != other.m_zs) if (m_zs != other.m_zs)
@ -790,9 +788,7 @@ private:
bool m_contained_in_bed{ true }; bool m_contained_in_bed{ true };
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
ConflictResultOpt m_conflict_result; ConflictResultOpt m_conflict_result;
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
public: public:
GCodeViewer(); GCodeViewer();
@ -851,9 +847,7 @@ public:
void invalidate_legend() { m_legend_resizer.reset(); } void invalidate_legend() { m_legend_resizer.reset(); }
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
const ConflictResultOpt& get_conflict_result() const { return m_conflict_result; } const ConflictResultOpt& get_conflict_result() const { return m_conflict_result; }
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
private: private:
void load_toolpaths(const GCodeProcessorResult& gcode_result); void load_toolpaths(const GCodeProcessorResult& gcode_result);

View File

@ -2692,9 +2692,7 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
if (wxGetApp().is_editor()) { if (wxGetApp().is_editor()) {
m_gcode_viewer.update_shells_color_by_extruder(m_config); m_gcode_viewer.update_shells_color_by_extruder(m_config);
_set_warning_notification_if_needed(EWarning::ToolpathOutside); _set_warning_notification_if_needed(EWarning::ToolpathOutside);
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
_set_warning_notification_if_needed(EWarning::GCodeConflict); _set_warning_notification_if_needed(EWarning::GCodeConflict);
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
} }
m_gcode_viewer.refresh(gcode_result, str_tool_colors); m_gcode_viewer.refresh(gcode_result, str_tool_colors);
@ -7443,17 +7441,12 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
} }
else { else {
if (wxGetApp().is_editor()) { if (wxGetApp().is_editor()) {
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION if (current_printer_technology() != ptSLA) {
if (current_printer_technology() != ptSLA) { if (warning == EWarning::ToolpathOutside)
if (warning == EWarning::ToolpathOutside) show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); else if (warning == EWarning::GCodeConflict)
else if (warning == EWarning::GCodeConflict) show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.get_conflict_result().has_value();
show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.get_conflict_result().has_value(); }
}
#else
if (current_printer_technology() != ptSLA)
show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
} }
} }
@ -7479,7 +7472,6 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
"Resolve the current problem to continue slicing."); "Resolve the current problem to continue slicing.");
error = ErrorType::PLATER_ERROR; error = ErrorType::PLATER_ERROR;
break; break;
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
case EWarning::GCodeConflict: { case EWarning::GCodeConflict: {
const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result(); const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result();
if (!conflict_result.has_value()) { break; } if (!conflict_result.has_value()) { break; }
@ -7492,11 +7484,9 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
error = ErrorType::SLICING_ERROR; error = ErrorType::SLICING_ERROR;
break; break;
} }
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
} }
auto& notification_manager = *wxGetApp().plater()->get_notification_manager(); auto& notification_manager = *wxGetApp().plater()->get_notification_manager();
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result(); const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result();
if (warning == EWarning::GCodeConflict) { if (warning == EWarning::GCodeConflict) {
if (conflict_result.has_value()) { if (conflict_result.has_value()) {
@ -7526,7 +7516,6 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
return; return;
} }
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
switch (error) switch (error)
{ {

View File

@ -362,12 +362,8 @@ class GLCanvas3D
ToolpathOutside, ToolpathOutside,
SlaSupportsOutside, SlaSupportsOutside,
SomethingNotShown, SomethingNotShown,
#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
ObjectClashed, ObjectClashed,
GCodeConflict GCodeConflict
#else
ObjectClashed
#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION
}; };
class RenderStats class RenderStats