diff --git a/src/libslic3r/GCode/ConflictChecker.cpp b/src/libslic3r/GCode/ConflictChecker.cpp index 7f8ba2d0c..064bb3620 100644 --- a/src/libslic3r/GCode/ConflictChecker.cpp +++ b/src/libslic3r/GCode/ConflictChecker.cpp @@ -163,13 +163,8 @@ ExtrusionPaths getExtrusionPathsFromLayer(LayerRegionPtrs layerRegionPtrs) { ExtrusionPaths paths; for (auto regionPtr : layerRegionPtrs) { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD getExtrusionPathsFromEntity(®ionPtr->perimeters(), paths); if (!regionPtr->perimeters().empty()) { getExtrusionPathsFromEntity(®ionPtr->fills(), paths); } -#else - getExtrusionPathsFromEntity(®ionPtr->perimeters, paths); - if (regionPtr->perimeters.empty() == false) { getExtrusionPathsFromEntity(®ionPtr->fills, paths); } -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } return paths; } @@ -218,13 +213,8 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP if (objs.size() <= 1) { return {}; } LinesBucketQueue conflictQueue; if (wtdptr.has_value()) { // wipe tower at 0 by default -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD auto wtpaths = (*wtdptr)->getFakeExtrusionPathsFromWipeTower(); conflictQueue.emplace_back_bucket(std::move(wtpaths), *wtdptr, { (*wtdptr)->plate_origin.x(), (*wtdptr)->plate_origin.y() }); -#else - auto wtpaths = wtdptr.value()->getFakeExtrusionPathsFromWipeTower(); - conflictQueue.emplace_back_bucket(std::move(wtpaths), wtdptr.value(), {wtdptr.value()->plate_origin.x(),wtdptr.value()->plate_origin.y()}); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } for (PrintObject *obj : objs) { auto layers = getAllLayersExtrusionPathsFromObject(obj); @@ -249,11 +239,7 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP auto interRes = find_inter_of_lines(layersLines[i]); if (interRes.has_value()) { find = true; -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD conflict.emplace_back(*interRes, heights[i]); -#else - conflict.emplace_back(interRes.value(),heights[i]); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD break; } } @@ -264,11 +250,7 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP const void *ptr2 = conflictQueue.idToObjsPtr(conflict[0].first._obj2); double conflictHeight = conflict[0].second; if (wtdptr.has_value()) { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD const FakeWipeTower* wtdp = *wtdptr; -#else - const FakeWipeTower *wtdp = wtdptr.value(); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD if (ptr1 == wtdp || ptr2 == wtdp) { if (ptr2 == wtdp) { std::swap(ptr1, ptr2); } const PrintObject *obj2 = reinterpret_cast(ptr2); diff --git a/src/libslic3r/GCode/ConflictChecker.hpp b/src/libslic3r/GCode/ConflictChecker.hpp index 00c975c37..39191f059 100644 --- a/src/libslic3r/GCode/ConflictChecker.hpp +++ b/src/libslic3r/GCode/ConflictChecker.hpp @@ -18,15 +18,9 @@ struct LineWithID { Line _line; int _id; -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD ExtrusionRole _role; LineWithID(const Line& line, int id, const ExtrusionRole& role) : _line(line), _id(id), _role(role) {} -#else - int _role; - - LineWithID(const Line& line, int id, int role) : _line(line), _id(id), _role(role) {} -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD }; using LineWithIDs = std::vector; @@ -58,20 +52,10 @@ public: { LineWithIDs lines; for (const ExtrusionPath &path : _piles[_curPileIdx]) { -#if !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - // - // INTEGRATION WHAT TO DO ??? - // we do not define path.is_force_no_extrusion() - // - if (path.is_force_no_extrusion() == false) { -#endif // !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - Polyline check_polyline = path.polyline; - check_polyline.translate(_offset); - Lines tmpLines = check_polyline.lines(); - for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); } -#if !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - } -#endif // !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD + Polyline check_polyline = path.polyline; + check_polyline.translate(_offset); + Lines tmpLines = check_polyline.lines(); + for (const Line &line : tmpLines) { lines.emplace_back(line, _id, path.role()); } } return lines; } diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index b00b8e218..df24f2b11 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -967,39 +967,16 @@ void Print::process() } #if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION -#if !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - // - // INTEGRATION WHAT TO DO ??? - // we do not define m_no_check - // - if (!m_no_check) { - using Clock = std::chrono::high_resolution_clock; - auto startTime = Clock::now(); -#endif // !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - std::optional wipe_tower_opt = {}; - if (this->has_wipe_tower()) { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x, m_config.wipe_tower_y }); -#else - m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x.get_at(m_plate_index), m_config.wipe_tower_y.get_at(m_plate_index) }); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - wipe_tower_opt = std::make_optional(&m_fake_wipe_tower); - } - auto conflictRes = ConflictChecker::find_inter_of_lines_in_diff_objs(m_objects, wipe_tower_opt); -#if !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - auto endTime = Clock::now(); - volatile double seconds = std::chrono::duration_cast(endTime - startTime).count() / (double)1000; - BOOST_LOG_TRIVIAL(info) << "gcode path conflicts check takes " << seconds << " secs."; -#endif // !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - - m_conflict_result = conflictRes; - if (conflictRes.has_value()) -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%") % conflictRes->_objName1 % conflictRes->_objName2; -#else - BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%") % conflictRes.value()._objName1 % conflictRes.value()._objName2; + std::optional wipe_tower_opt = {}; + if (this->has_wipe_tower()) { + m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x, m_config.wipe_tower_y }); + wipe_tower_opt = std::make_optional(&m_fake_wipe_tower); } -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD + auto conflictRes = ConflictChecker::find_inter_of_lines_in_diff_objs(m_objects, wipe_tower_opt); + + m_conflict_result = conflictRes; + if (conflictRes.has_value()) + 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(); diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 12058734b..6ecc7abf3 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -430,11 +430,7 @@ struct FakeWipeTower float brim_width; Vec2d plate_origin; -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD void set_fake_extrusion_data(const Vec2f& p, float w, float h, float lh, float d, float bd, const Vec2d& o) -#else - void set_fake_extrusion_data(Vec2f p, float w, float h, float lh, float d, float bd, Vec2d o) -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD { pos = p; width = w; @@ -445,11 +441,7 @@ struct FakeWipeTower plate_origin = o; } -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD void set_pos(const Vec2f& p) { pos = p; } -#else - void set_pos(Vec2f p) { pos = p; } -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD std::vector getFakeExtrusionPathsFromWipeTower() const { @@ -463,27 +455,9 @@ struct FakeWipeTower std::vector paths; for (float hh = 0.f; hh < h; hh += lh) { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD ExtrusionPath path(ExtrusionRole::WipeTower, 0.0, 0.0, lh); -#else - ExtrusionPath path(ExtrusionRole::erWipeTower, 0.0, 0.0, lh); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD path.polyline = { minCorner, {maxCorner.x(), minCorner.y()}, maxCorner, {minCorner.x(), maxCorner.y()}, minCorner }; paths.push_back({ path }); - -#if !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - // - // INTEGRATION WHAT TO DO ??? - // we do not define erBrim - // - if (hh == 0.f) { // add brim - ExtrusionPath fakeBrim(ExtrusionRole::erBrim, 0.0, 0.0, lh); - Point wtbminCorner = { minCorner - Point{bd, bd} }; - Point wtbmaxCorner = { maxCorner + Point{bd, bd} }; - fakeBrim.polyline = { wtbminCorner, {wtbmaxCorner.x(), wtbminCorner.y()}, wtbmaxCorner, {wtbminCorner.x(), wtbmaxCorner.y()}, wtbminCorner }; - paths.back().push_back(fakeBrim); - } -#endif // !ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } return paths; } diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 36b51fe2d..c54498a98 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -79,10 +79,5 @@ #define ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION (1 && ENABLE_2_6_0_BETA1) -// Modifications to original BambuStudio code: -// * compliance with PS code -// * removed code which has no clear counterpart in PS -#define ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD (1 && ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION) - #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5261113e0..aec674459 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -802,11 +802,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr #if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION m_conflict_result = gcode_result.conflict_result; -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD if (m_conflict_result.has_value()) { m_conflict_result->layer = m_layers.get_l_at(m_conflict_result->_height); } -#else - if (m_conflict_result) { m_conflict_result.value().layer = m_layers.get_l_at(m_conflict_result.value()._height); } -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD #endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 14db2f8df..048449a4c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7448,11 +7448,7 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning) if (warning == EWarning::ToolpathOutside) show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); else if (warning == EWarning::GCodeConflict) -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.get_conflict_result().has_value(); -#else - show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.m_conflict_result.has_value(); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } #else if (current_printer_technology() != ptSLA) @@ -7485,25 +7481,14 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) break; #if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION case EWarning::GCodeConflict: { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD - const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result(); - if (!conflict_result.has_value()) { break; } - std::string objName1 = conflict_result->_objName1; - std::string objName2 = conflict_result->_objName2; - double height = conflict_result->_height; - int layer = conflict_result->layer; - text = (boost::format(_u8L("Conflicts of gcode paths have been found at layer %d, z = %.2lf mm. Please separate the conflicted objects farther (%s <-> %s).")) % layer % - height % objName1 % objName2).str(); -#else - if (!m_gcode_viewer.m_conflict_result) { break; } - std::string objName1 = m_gcode_viewer.m_conflict_result.value()._objName1; - std::string objName2 = m_gcode_viewer.m_conflict_result.value()._objName2; - double height = m_gcode_viewer.m_conflict_result.value()._height; - int layer = m_gcode_viewer.m_conflict_result.value().layer; + const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result(); + if (!conflict_result.has_value()) { break; } + std::string objName1 = conflict_result->_objName1; + std::string objName2 = conflict_result->_objName2; + double height = conflict_result->_height; + int layer = conflict_result->layer; text = (boost::format(_u8L("Conflicts of gcode paths have been found at layer %d, z = %.2lf mm. Please separate the conflicted objects farther (%s <-> %s).")) % layer % - height % objName1 % objName2) - .str(); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD + height % objName1 % objName2).str(); error = ErrorType::SLICING_ERROR; break; } @@ -7512,57 +7497,35 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) auto& notification_manager = *wxGetApp().plater()->get_notification_manager(); #if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD const ConflictResultOpt& conflict_result = m_gcode_viewer.get_conflict_result(); if (warning == EWarning::GCodeConflict) { if (conflict_result.has_value()) { const PrintObject* obj2 = reinterpret_cast(conflict_result->_obj2); -#else - if (warning == EWarning::GCodeConflict && m_gcode_viewer.m_conflict_result) { - const PrintObject* obj2 = reinterpret_cast(m_gcode_viewer.m_conflict_result.value()._obj2); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD auto mo = obj2->model_object(); ObjectID id = mo->id(); -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD auto action_fn = [this, id](wxEvtHandler*) { -#else - auto action_fn = [id](wxEvtHandler*) { -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD auto& objects = wxGetApp().model().objects; auto iter = id.id ? std::find_if(objects.begin(), objects.end(), [id](auto o) { return o->id() == id; }) : objects.end(); if (iter != objects.end()) { -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD const unsigned int obj_idx = std::distance(objects.begin(), iter); wxGetApp().CallAfter([this, obj_idx]() { wxGetApp().plater()->select_view_3D("3D"); wxGetApp().plater()->canvas3D()->get_selection().add_object(obj_idx, true); wxGetApp().obj_list()->update_selections(); }); -#else - wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor); - wxGetApp().obj_list()->select_items({ { *iter, nullptr } }); -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } return false; }; auto hypertext = _u8L("Jump to"); hypertext += std::string(" [") + mo->name + "]"; -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD notification_manager.push_notification(NotificationType::SlicingError, NotificationManager::NotificationLevel::ErrorNotificationLevel, _u8L("ERROR:") + "\n" + text, hypertext, action_fn); -#else - notification_manager.push_notification(NotificationType::PlaterError, NotificationManager::NotificationLevel::ErrorNotificationLevel, - _u8L("ERROR:") + "\n" + text, hypertext, action_fn); - return; -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD } -#if ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD else notification_manager.close_slicing_error_notification(text); return; } -#endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION_MOD #endif // ENABLE_BAMBUSTUDIO_TOOLPATHS_CONFLICTS_DETECTION switch (error)