ENH: optimize the efficiency of auto lift
Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I9c1679cc80ae23ff066df6e2fe98b5530a9d2288
This commit is contained in:
parent
1b0b14c0f2
commit
1d0476fa44
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Bambulab",
|
"name": "Bambulab",
|
||||||
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
|
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
|
||||||
"version": "01.06.00.03",
|
"version": "01.06.00.04",
|
||||||
"force_update": "0",
|
"force_update": "0",
|
||||||
"description": "the initial version of BBL configurations",
|
"description": "the initial version of BBL configurations",
|
||||||
"machine_model_list": [
|
"machine_model_list": [
|
||||||
|
|
|
@ -149,7 +149,7 @@
|
||||||
"30"
|
"30"
|
||||||
],
|
],
|
||||||
"z_hop_types": [
|
"z_hop_types": [
|
||||||
"Spiral Lift"
|
"Auto Lift"
|
||||||
],
|
],
|
||||||
"nozzle_type": "hardened_steel",
|
"nozzle_type": "hardened_steel",
|
||||||
"silent_mode": "0",
|
"silent_mode": "0",
|
||||||
|
|
|
@ -4006,27 +4006,47 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
|
||||||
std::pair<float, float> z_range;
|
std::pair<float, float> z_range;
|
||||||
z_range.second = m_layer ? m_layer->print_z : 0.f;
|
z_range.second = m_layer ? m_layer->print_z : 0.f;
|
||||||
z_range.first = std::max(0.f, z_range.second - protect_z_scaled);
|
z_range.first = std::max(0.f, z_range.second - protect_z_scaled);
|
||||||
for (auto object : m_curr_print->objects()) {
|
std::vector<LayerPtrs> layers_of_objects;
|
||||||
BoundingBox obj_bbox = object->bounding_box();
|
std::vector<BoundingBox> boundingBox_for_objects;
|
||||||
|
std::vector<size_t> 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);
|
BoundingBox travel_bbox = get_extents(travel);
|
||||||
obj_bbox.offset(scale_(EPSILON));
|
obj_bbox.offset(scale_(EPSILON));
|
||||||
|
|
||||||
if (!obj_bbox.overlap(travel_bbox))
|
if (!obj_bbox.overlap(travel_bbox))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (auto layer : object->layers()) {
|
Polygon object_box;
|
||||||
if (layer->print_z < z_range.first)
|
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;
|
continue;
|
||||||
|
|
||||||
if (layer->print_z > z_range.second + EPSILON)
|
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();
|
||||||
break;
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
for (ExPolygon& overhang : layer->loverhangs) {
|
|
||||||
if (overhang.contains(travel))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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++)
|
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));
|
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 travel_len_thresh = max_z_hop / tan(GCodeWriter::slope_threshold);
|
||||||
|
|
||||||
float accum_len = 0.f;
|
float accum_len = 0.f;
|
||||||
Polyline clipped_travel;
|
Polyline clipped_travel;
|
||||||
for (auto line : travel.lines()) {
|
|
||||||
if (accum_len + line.length() > travel_len_thresh + EPSILON) {
|
clipped_travel.append(Polyline(travel.points[0], travel.points[1]));
|
||||||
Point end_pnt = line.a + line.normal() * (travel_len_thresh - accum_len);
|
if (clipped_travel.length() > travel_len_thresh)
|
||||||
clipped_travel.append(Polyline(line.a, end_pnt));
|
clipped_travel.points.back() = clipped_travel.points.front()+(clipped_travel.points.back() - clipped_travel.points.front()) * (travel_len_thresh / clipped_travel.length());
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clipped_travel.append(Polyline(line.a, line.b));
|
|
||||||
accum_len += line.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//BBS: force to retract when leave from external perimeter for a long travel
|
//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.
|
//Better way is judging whether the travel move direction is same with last extrusion move.
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
ExPolygons loverhangs;
|
ExPolygons loverhangs;
|
||||||
|
BoundingBox loverhangs_bbox;
|
||||||
size_t region_count() const { return m_regions.size(); }
|
size_t region_count() const { return m_regions.size(); }
|
||||||
const LayerRegion* get_region(int idx) const { return m_regions[idx]; }
|
const LayerRegion* get_region(int idx) const { return m_regions[idx]; }
|
||||||
LayerRegion* get_region(int idx) { return m_regions[idx]; }
|
LayerRegion* get_region(int idx) { return m_regions[idx]; }
|
||||||
|
|
|
@ -399,6 +399,20 @@ bool Print::has_brim() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
|
std::vector<size_t> Print::layers_sorted_for_object(float start, float end, std::vector<LayerPtrs> &layers_of_objects, std::vector<BoundingBox> &boundingBox_for_objects)
|
||||||
|
{
|
||||||
|
std::vector<size_t> 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<std::pair<Polygon, float>>* height_polygons)
|
StringObjectException Print::sequential_print_clearance_valid(const Print &print, Polygons *polygons, std::vector<std::pair<Polygon, float>>* height_polygons)
|
||||||
{
|
{
|
||||||
StringObjectException single_object_exception;
|
StringObjectException single_object_exception;
|
||||||
|
|
|
@ -410,7 +410,7 @@ public:
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
BoundingBox get_first_layer_bbox(float& area, float& layer_height, std::string& name);
|
BoundingBox get_first_layer_bbox(float& area, float& layer_height, std::string& name);
|
||||||
|
void get_certain_layers(float start, float end, std::vector<LayerPtrs> &out, std::vector<BoundingBox> &boundingbox_objects);
|
||||||
PrintObject* get_shared_object() const { return m_shared_object; }
|
PrintObject* get_shared_object() const { return m_shared_object; }
|
||||||
void set_shared_object(PrintObject *object);
|
void set_shared_object(PrintObject *object);
|
||||||
void clear_shared_object();
|
void clear_shared_object();
|
||||||
|
@ -734,7 +734,7 @@ public:
|
||||||
// For Perl bindings.
|
// For Perl bindings.
|
||||||
PrintObjectPtrs& objects_mutable() { return m_objects; }
|
PrintObjectPtrs& objects_mutable() { return m_objects; }
|
||||||
PrintRegionPtrs& print_regions_mutable() { return m_print_regions; }
|
PrintRegionPtrs& print_regions_mutable() { return m_print_regions; }
|
||||||
|
std::vector<size_t> layers_sorted_for_object(float start, float end, std::vector<LayerPtrs> &layers_of_objects, std::vector<BoundingBox> &boundingBox_for_objects);
|
||||||
const ExtrusionEntityCollection& skirt() const { return m_skirt; }
|
const ExtrusionEntityCollection& skirt() const { return m_skirt; }
|
||||||
// Convex hull of the 1st layer extrusions, for bed leveling and placing the initial purge line.
|
// 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.
|
// It encompasses the object extrusions, support extrusions, skirt, brim, wipe tower.
|
||||||
|
|
|
@ -441,9 +441,9 @@ void PrintObject::detect_overhangs_for_lift()
|
||||||
|
|
||||||
ExPolygons overhangs = diff_ex(layer.lslices, offset_ex(lower_layer.lslices, scale_(min_overlap)));
|
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 = 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);
|
this->set_done(posDetectOverhangsForLift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2006,7 +2006,21 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c
|
||||||
|
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
//BBS:
|
||||||
|
void PrintObject::get_certain_layers(float start, float end, std::vector<LayerPtrs> &out, std::vector<BoundingBox> &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,
|
// 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.
|
// 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.
|
// Here the internal surfaces and perimeters have to be supported by the sparse infill.
|
||||||
|
|
Loading…
Reference in New Issue