diff --git a/resources/profiles/BBL.json b/resources/profiles/BBL.json index 0b303db46..b6f749a98 100644 --- a/resources/profiles/BBL.json +++ b/resources/profiles/BBL.json @@ -1,7 +1,7 @@ { "name": "Bambulab", "url": "http://www.bambulab.com/Parameters/vendor/BBL.json", - "version": "01.06.00.03", + "version": "01.06.00.04", "force_update": "0", "description": "the initial version of BBL configurations", "machine_model_list": [ diff --git a/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json b/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json index 29c69edb2..b7e3bdbe3 100644 --- a/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json +++ b/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json @@ -149,7 +149,7 @@ "30" ], "z_hop_types": [ - "Spiral Lift" + "Auto Lift" ], "nozzle_type": "hardened_steel", "silent_mode": "0", diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f8f581c94..7b6deb7ab 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4006,27 +4006,47 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp std::pair z_range; z_range.second = m_layer ? m_layer->print_z : 0.f; z_range.first = std::max(0.f, z_range.second - protect_z_scaled); - for (auto object : m_curr_print->objects()) { - BoundingBox obj_bbox = object->bounding_box(); + std::vector layers_of_objects; + std::vector boundingBox_for_objects; + std::vector idx_of_object_sorted = m_curr_print->layers_sorted_for_object(z_range.first, z_range.second, layers_of_objects, boundingBox_for_objects); + + for (size_t i = 0; i < idx_of_object_sorted.size();i++) { + size_t idx = idx_of_object_sorted[i]; + + BoundingBox obj_bbox = boundingBox_for_objects[idx]; BoundingBox travel_bbox = get_extents(travel); obj_bbox.offset(scale_(EPSILON)); + if (!obj_bbox.overlap(travel_bbox)) continue; - for (auto layer : object->layers()) { - if (layer->print_z < z_range.first) - continue; + Polygon object_box; + Polygons temp; + object_box.points.push_back(Point(obj_bbox.min(0), obj_bbox.min(1))); + object_box.points.push_back(Point(obj_bbox.max(0), obj_bbox.min(1))); + object_box.points.push_back(Point(obj_bbox.max(0), obj_bbox.max(1))); + object_box.points.push_back(Point(obj_bbox.min(0), obj_bbox.max(1))); + temp.push_back(object_box); + if (intersection_pl(travel, temp).empty()) + continue; - if (layer->print_z > z_range.second + EPSILON) - break; + std::sort(layers_of_objects[idx].begin(), layers_of_objects[idx].end(), [](auto left, auto right) { return left->loverhangs_bbox.area() > right->loverhangs_bbox.area(); + }); - for (ExPolygon& overhang : layer->loverhangs) { - if (overhang.contains(travel)) - return true; + for (const auto &layer : layers_of_objects[idx]) { + for (const ExPolygon &overhang : layer->loverhangs) { + BoundingBox bbox1 = get_extents(overhang); + travel_bbox.inflated(1); + if (!bbox1.overlap(travel_bbox)) + continue; + + if (intersection_pl(travel, overhang).empty()) + continue; + + return true; } } } - return false; }; @@ -4034,19 +4054,13 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp for (int i = 0; i < m_config.z_hop.size(); i++) max_z_hop = std::max(max_z_hop, (float)m_config.z_hop.get_at(i)); float travel_len_thresh = max_z_hop / tan(GCodeWriter::slope_threshold); + float accum_len = 0.f; Polyline clipped_travel; - for (auto line : travel.lines()) { - if (accum_len + line.length() > travel_len_thresh + EPSILON) { - Point end_pnt = line.a + line.normal() * (travel_len_thresh - accum_len); - clipped_travel.append(Polyline(line.a, end_pnt)); - break; - } - else { - clipped_travel.append(Polyline(line.a, line.b)); - accum_len += line.length(); - } - } + + clipped_travel.append(Polyline(travel.points[0], travel.points[1])); + if (clipped_travel.length() > travel_len_thresh) + clipped_travel.points.back() = clipped_travel.points.front()+(clipped_travel.points.back() - clipped_travel.points.front()) * (travel_len_thresh / clipped_travel.length()); //BBS: force to retract when leave from external perimeter for a long travel //Better way is judging whether the travel move direction is same with last extrusion move. diff --git a/src/libslic3r/Layer.hpp b/src/libslic3r/Layer.hpp index 47b0b7817..968aeae9e 100644 --- a/src/libslic3r/Layer.hpp +++ b/src/libslic3r/Layer.hpp @@ -149,7 +149,7 @@ public: // BBS ExPolygons loverhangs; - + BoundingBox loverhangs_bbox; size_t region_count() const { return m_regions.size(); } const LayerRegion* get_region(int idx) const { return m_regions[idx]; } LayerRegion* get_region(int idx) { return m_regions[idx]; } diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index a5b99f67a..635802ba3 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -399,6 +399,20 @@ bool Print::has_brim() const } //BBS +std::vector Print::layers_sorted_for_object(float start, float end, std::vector &layers_of_objects, std::vector &boundingBox_for_objects) +{ + std::vector idx_of_object_sorted; + size_t idx = 0; + for (const auto &object : m_objects) { + idx_of_object_sorted.push_back(idx++); + object->get_certain_layers(start, end, layers_of_objects, boundingBox_for_objects); + } + std::sort(idx_of_object_sorted.begin(), idx_of_object_sorted.end(), + [boundingBox_for_objects](auto left, auto right) { return boundingBox_for_objects[left].area() > boundingBox_for_objects[right].area(); }); + + return idx_of_object_sorted; +}; + StringObjectException Print::sequential_print_clearance_valid(const Print &print, Polygons *polygons, std::vector>* height_polygons) { StringObjectException single_object_exception; diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index dc60566f2..2c74d2585 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -410,7 +410,7 @@ public: //BBS BoundingBox get_first_layer_bbox(float& area, float& layer_height, std::string& name); - + void get_certain_layers(float start, float end, std::vector &out, std::vector &boundingbox_objects); PrintObject* get_shared_object() const { return m_shared_object; } void set_shared_object(PrintObject *object); void clear_shared_object(); @@ -734,7 +734,7 @@ public: // For Perl bindings. PrintObjectPtrs& objects_mutable() { return m_objects; } PrintRegionPtrs& print_regions_mutable() { return m_print_regions; } - + std::vector layers_sorted_for_object(float start, float end, std::vector &layers_of_objects, std::vector &boundingBox_for_objects); const ExtrusionEntityCollection& skirt() const { return m_skirt; } // Convex hull of the 1st layer extrusions, for bed leveling and placing the initial purge line. // It encompasses the object extrusions, support extrusions, skirt, brim, wipe tower. diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index de41a291f..920ada240 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -441,9 +441,9 @@ void PrintObject::detect_overhangs_for_lift() ExPolygons overhangs = diff_ex(layer.lslices, offset_ex(lower_layer.lslices, scale_(min_overlap))); layer.loverhangs = std::move(offset2_ex(overhangs, -0.1f * scale_(m_config.line_width), 0.1f * scale_(m_config.line_width))); + layer.loverhangs_bbox = get_extents(layer.loverhangs); } }); - this->set_done(posDetectOverhangsForLift); } } @@ -2006,7 +2006,21 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c return updated; } +//BBS: +void PrintObject::get_certain_layers(float start, float end, std::vector &out, std::vector &boundingbox_objects) +{ + BoundingBox temp; + LayerPtrs out_temp; + for (const auto &layer : layers()) { + if (layer->print_z < start) continue; + if (layer->print_z > end + EPSILON) break; + temp.merge(layer->loverhangs_bbox); + out_temp.emplace_back(layer); + } + boundingbox_objects.emplace_back(std::move(temp)); + out.emplace_back(std::move(out_temp)); +}; // Only active if config->infill_only_where_needed. This step trims the sparse infill, // so it acts as an internal support. It maintains all other infill types intact. // Here the internal surfaces and perimeters have to be supported by the sparse infill.