mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-21 04:23:15 +08:00
FIX: brim generation with extruder overridding in by layer slicing
in brim generation, object's first layer extruders are obtained from regions. If the extruders are changed at certain layers in by layer slicing mode, the extruders from layer regions are not right. this patch fix that issue by updating the extruder overridding in a new member "object_first_layer_wall_extruders" in "print_object" class during constructing "Tool_ordering" class. then using the new member directly when generating brim. besides, support contour, which should be no_brim_area, is obtained from "support_infills" instead of "lslices" of "support_layers" JIRA-ID: https://jira.bambooolab.com/browse/STUDIO-4332 Change-Id: I271d0ea0d8c01c412d4fb9ade5296c6a6471aed6 (cherry picked from commit 9919ce9d1b9105b859273eee4fe9481c4dff6189)
This commit is contained in:
parent
0eb9ac856b
commit
5160c8c4f6
@ -939,44 +939,12 @@ static ExPolygons outer_inner_brim_area(const Print& print,
|
||||
support_material_extruder = printExtruders.front() + 1;
|
||||
}
|
||||
if (support_material_extruder == extruderNo && brimToWrite.at(object->id()).sup) {
|
||||
if (!object->support_layers().empty() && object->support_layers().front()->support_type==stInnerNormal) {
|
||||
if (!object->support_layers().empty()) {
|
||||
for (const Polygon& support_contour : object->support_layers().front()->support_fills.polygons_covered_by_spacing()) {
|
||||
// Brim will not be generated for supports
|
||||
/*
|
||||
if (brim_type == BrimType::btOuterOnly || brim_type == BrimType::btOuterAndInner || brim_type == BrimType::btAutoBrim) {
|
||||
append(brim_area_support, diff_ex(offset_ex(support_contour, brim_width + brim_offset, jtRound, SCALED_RESOLUTION), offset_ex(support_contour, brim_offset)));
|
||||
}
|
||||
if (brim_type != BrimType::btNoBrim)
|
||||
append(no_brim_area_support, offset_ex(support_contour, 0));
|
||||
*/
|
||||
no_brim_area_support.emplace_back(support_contour);
|
||||
}
|
||||
}
|
||||
// BBS
|
||||
if (!object->support_layers().empty() && object->support_layers().front()->support_type == stInnerTree) {
|
||||
for (const ExPolygon &ex_poly : object->support_layers().front()->lslices) {
|
||||
// BBS: additional brim width will be added if adhension area is too small without brim
|
||||
float brim_width_mod = ex_poly.area() / ex_poly.contour.length() < scaled_half_min_adh_length
|
||||
&& brim_width < scaled_flow_width ? brim_width + scaled_additional_brim_width : brim_width;
|
||||
brim_width_mod = floor(brim_width_mod / scaled_flow_width / 2) * scaled_flow_width * 2;
|
||||
// Brim will not be generated for supports
|
||||
/*
|
||||
if (brim_type == BrimType::btOuterOnly || brim_type == BrimType::btOuterAndInner || brim_type == BrimType::btAutoBrim) {
|
||||
append(brim_area_support, diff_ex(offset_ex(ex_poly.contour, brim_width_mod + brim_offset, jtRound, SCALED_RESOLUTION), offset_ex(ex_poly.contour, brim_offset)));
|
||||
}
|
||||
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btOuterAndInner)
|
||||
append(brim_area_support, diff_ex(offset_ex(ex_poly.holes, -brim_offset), offset_ex(ex_poly.holes, -brim_width - brim_offset)));
|
||||
*/
|
||||
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btNoBrim)
|
||||
append(no_brim_area_support, diff_ex(offset(ex_poly.contour, no_brim_offset), ex_poly.holes));
|
||||
if (brim_type == BrimType::btNoBrim)
|
||||
append(no_brim_area_support, offset_ex(ex_poly.holes, -no_brim_offset));
|
||||
append(holes_support, ex_poly.holes);
|
||||
if (brim_type != BrimType::btNoBrim)
|
||||
append(no_brim_area_support, offset_ex(ex_poly.contour, 0));
|
||||
no_brim_area_support.emplace_back(ex_poly.contour);
|
||||
}
|
||||
}
|
||||
|
||||
brimToWrite.at(object->id()).sup = false;
|
||||
for (const PrintInstance& instance : object->instances()) {
|
||||
if (!brim_area_support.empty())
|
||||
|
@ -382,6 +382,11 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
||||
it_per_layer_extruder_override = per_layer_extruder_switches.begin();
|
||||
unsigned int extruder_override = 0;
|
||||
|
||||
// BBS: collect first layer extruders of an object's wall, which will be used by brim generator
|
||||
int layerCount = 0;
|
||||
std::vector<int> firstLayerExtruders;
|
||||
firstLayerExtruders.clear();
|
||||
|
||||
// Collect the object extruders.
|
||||
for (auto layer : object.layers()) {
|
||||
LayerTools &layer_tools = this->tools_for_layer(layer->print_z);
|
||||
@ -407,8 +412,12 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
||||
something_nonoverriddable = true;
|
||||
}
|
||||
|
||||
if (something_nonoverriddable)
|
||||
if (something_nonoverriddable){
|
||||
layer_tools.extruders.emplace_back((extruder_override == 0) ? region.config().wall_filament.value : extruder_override);
|
||||
if (layerCount == 0) {
|
||||
firstLayerExtruders.emplace_back((extruder_override == 0) ? region.config().wall_filament.value : extruder_override);
|
||||
}
|
||||
}
|
||||
|
||||
layer_tools.has_object = true;
|
||||
}
|
||||
@ -443,8 +452,12 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
||||
if (has_solid_infill || has_infill)
|
||||
layer_tools.has_object = true;
|
||||
}
|
||||
layerCount++;
|
||||
}
|
||||
|
||||
sort_remove_duplicates(firstLayerExtruders);
|
||||
const_cast<PrintObject&>(object).object_first_layer_wall_extruders = firstLayerExtruders;
|
||||
|
||||
for (auto& layer : m_layer_tools) {
|
||||
// Sort and remove duplicates
|
||||
sort_remove_duplicates(layer.extruders);
|
||||
|
@ -1450,16 +1450,21 @@ std::map<ObjectID, unsigned int> getObjectExtruderMap(const Print& print) {
|
||||
std::map<ObjectID, unsigned int> objectExtruderMap;
|
||||
for (const PrintObject* object : print.objects()) {
|
||||
// BBS
|
||||
unsigned int objectFirstLayerFirstExtruder = print.config().filament_diameter.size();
|
||||
auto firstLayerRegions = object->layers().front()->regions();
|
||||
if (!firstLayerRegions.empty()) {
|
||||
for (const LayerRegion* regionPtr : firstLayerRegions) {
|
||||
if (regionPtr -> has_extrusions())
|
||||
objectFirstLayerFirstExtruder = std::min(objectFirstLayerFirstExtruder,
|
||||
regionPtr->region().extruder(frExternalPerimeter));
|
||||
if (object->object_first_layer_wall_extruders.empty()){
|
||||
unsigned int objectFirstLayerFirstExtruder = print.config().filament_diameter.size();
|
||||
auto firstLayerRegions = object->layers().front()->regions();
|
||||
if (!firstLayerRegions.empty()) {
|
||||
for (const LayerRegion* regionPtr : firstLayerRegions) {
|
||||
if (regionPtr->has_extrusions())
|
||||
objectFirstLayerFirstExtruder = std::min(objectFirstLayerFirstExtruder,
|
||||
regionPtr->region().extruder(frExternalPerimeter));
|
||||
}
|
||||
}
|
||||
objectExtruderMap.insert(std::make_pair(object->id(), objectFirstLayerFirstExtruder));
|
||||
}
|
||||
else {
|
||||
objectExtruderMap.insert(std::make_pair(object->id(), object->object_first_layer_wall_extruders.front()));
|
||||
}
|
||||
objectExtruderMap.insert(std::make_pair(object->id(), objectFirstLayerFirstExtruder));
|
||||
}
|
||||
return objectExtruderMap;
|
||||
}
|
||||
|
@ -434,6 +434,9 @@ public:
|
||||
// BBS: Boundingbox of the first layer
|
||||
BoundingBox firstLayerObjectBrimBoundingBox;
|
||||
|
||||
// BBS: returns 1-based indices of extruders used to print the first layer wall of objects
|
||||
std::vector<int> object_first_layer_wall_extruders;
|
||||
|
||||
// OrcaSlicer
|
||||
size_t get_klipper_object_id() const { return m_klipper_object_id; }
|
||||
void set_klipper_object_id(size_t id) { m_klipper_object_id = id; }
|
||||
@ -517,6 +520,7 @@ private:
|
||||
bool m_typed_slices = false;
|
||||
std::vector < VolumeSlices > firstLayerObjSliceByVolume;
|
||||
std::vector<groupedVolumeSlices> firstLayerObjSliceByGroups;
|
||||
|
||||
// BBS: per object skirt
|
||||
ExtrusionEntityCollection m_skirt;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user