mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-07-08 10:24:29 +03:00
Improved constness of the Print / PrintObject / Layer ...
Split the wipe tower and time statistics data into separate objects. Initial work in synchronizing the Model with the Print.
This commit is contained in:
@@ -99,19 +99,19 @@ static BoundingBoxf extrusionentity_extents(const ExtrusionEntity *extrusion_ent
|
||||
|
||||
BoundingBoxf get_print_extrusions_extents(const Print &print)
|
||||
{
|
||||
BoundingBoxf bbox(extrusionentity_extents(print.brim));
|
||||
bbox.merge(extrusionentity_extents(print.skirt));
|
||||
BoundingBoxf bbox(extrusionentity_extents(print.brim()));
|
||||
bbox.merge(extrusionentity_extents(print.skirt()));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
BoundingBoxf get_print_object_extrusions_extents(const PrintObject &print_object, const coordf_t max_print_z)
|
||||
{
|
||||
BoundingBoxf bbox;
|
||||
for (const Layer *layer : print_object.layers) {
|
||||
for (const Layer *layer : print_object.layers()) {
|
||||
if (layer->print_z > max_print_z)
|
||||
break;
|
||||
BoundingBoxf bbox_this;
|
||||
for (const LayerRegion *layerm : layer->regions) {
|
||||
for (const LayerRegion *layerm : layer->regions()) {
|
||||
bbox_this.merge(extrusionentity_extents(layerm->perimeters));
|
||||
for (const ExtrusionEntity *ee : layerm->fills.entities)
|
||||
// fill represents infill extrusions of a single island.
|
||||
@@ -135,7 +135,7 @@ BoundingBoxf get_print_object_extrusions_extents(const PrintObject &print_object
|
||||
BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_t max_print_z)
|
||||
{
|
||||
BoundingBoxf bbox;
|
||||
for (const std::vector<WipeTower::ToolChangeResult> &tool_changes : print.m_wipe_tower_tool_changes) {
|
||||
for (const std::vector<WipeTower::ToolChangeResult> &tool_changes : print.wipe_tower_data().tool_changes) {
|
||||
if (! tool_changes.empty() && tool_changes.front().print_z > max_print_z)
|
||||
break;
|
||||
for (const WipeTower::ToolChangeResult &tcr : tool_changes) {
|
||||
@@ -161,8 +161,8 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_
|
||||
BoundingBoxf get_wipe_tower_priming_extrusions_extents(const Print &print)
|
||||
{
|
||||
BoundingBoxf bbox;
|
||||
if (print.m_wipe_tower_priming) {
|
||||
const WipeTower::ToolChangeResult &tcr = *print.m_wipe_tower_priming.get();
|
||||
if (print.wipe_tower_data().priming != nullptr) {
|
||||
const WipeTower::ToolChangeResult &tcr = *print.wipe_tower_data().priming;
|
||||
for (size_t i = 1; i < tcr.extrusions.size(); ++ i) {
|
||||
const WipeTower::Extrusion &e = tcr.extrusions[i];
|
||||
if (e.width > 0) {
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
namespace Slic3r {
|
||||
|
||||
// For the use case when each object is printed separately
|
||||
// (print.config.complete_objects is true).
|
||||
// (print.config().complete_objects is true).
|
||||
ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extruder, bool prime_multi_material)
|
||||
{
|
||||
if (object.layers.empty())
|
||||
if (object.layers().empty())
|
||||
return;
|
||||
|
||||
// Initialize the print layers for just a single object.
|
||||
{
|
||||
std::vector<coordf_t> zs;
|
||||
zs.reserve(zs.size() + object.layers.size() + object.support_layers.size());
|
||||
for (auto layer : object.layers)
|
||||
zs.reserve(zs.size() + object.layers().size() + object.support_layers().size());
|
||||
for (auto layer : object.layers())
|
||||
zs.emplace_back(layer->print_z);
|
||||
for (auto layer : object.support_layers)
|
||||
for (auto layer : object.support_layers())
|
||||
zs.emplace_back(layer->print_z);
|
||||
this->initialize_layers(zs);
|
||||
}
|
||||
@@ -39,39 +39,39 @@ ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extrude
|
||||
// Reorder the extruders to minimize tool switches.
|
||||
this->reorder_extruders(first_extruder);
|
||||
|
||||
this->fill_wipe_tower_partitions(object.print()->config, object.layers.front()->print_z - object.layers.front()->height);
|
||||
this->fill_wipe_tower_partitions(object.print()->config(), object.layers().front()->print_z - object.layers().front()->height);
|
||||
|
||||
this->collect_extruder_statistics(prime_multi_material);
|
||||
}
|
||||
|
||||
// For the use case when all objects are printed at once.
|
||||
// (print.config.complete_objects is false).
|
||||
// (print.config().complete_objects is false).
|
||||
ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool prime_multi_material)
|
||||
{
|
||||
// Initialize the print layers for all objects and all layers.
|
||||
coordf_t object_bottom_z = 0.;
|
||||
{
|
||||
std::vector<coordf_t> zs;
|
||||
for (auto object : print.objects) {
|
||||
zs.reserve(zs.size() + object->layers.size() + object->support_layers.size());
|
||||
for (auto layer : object->layers)
|
||||
for (auto object : print.objects()) {
|
||||
zs.reserve(zs.size() + object->layers().size() + object->support_layers().size());
|
||||
for (auto layer : object->layers())
|
||||
zs.emplace_back(layer->print_z);
|
||||
for (auto layer : object->support_layers)
|
||||
for (auto layer : object->support_layers())
|
||||
zs.emplace_back(layer->print_z);
|
||||
if (! object->layers.empty())
|
||||
object_bottom_z = object->layers.front()->print_z - object->layers.front()->height;
|
||||
if (! object->layers().empty())
|
||||
object_bottom_z = object->layers().front()->print_z - object->layers().front()->height;
|
||||
}
|
||||
this->initialize_layers(zs);
|
||||
}
|
||||
|
||||
// Collect extruders reuqired to print the layers.
|
||||
for (auto object : print.objects)
|
||||
for (auto object : print.objects())
|
||||
this->collect_extruders(*object);
|
||||
|
||||
// Reorder the extruders to minimize tool switches.
|
||||
this->reorder_extruders(first_extruder);
|
||||
|
||||
this->fill_wipe_tower_partitions(print.config, object_bottom_z);
|
||||
this->fill_wipe_tower_partitions(print.config(), object_bottom_z);
|
||||
|
||||
this->collect_extruder_statistics(prime_multi_material);
|
||||
}
|
||||
@@ -111,13 +111,13 @@ void ToolOrdering::initialize_layers(std::vector<coordf_t> &zs)
|
||||
void ToolOrdering::collect_extruders(const PrintObject &object)
|
||||
{
|
||||
// Collect the support extruders.
|
||||
for (auto support_layer : object.support_layers) {
|
||||
for (auto support_layer : object.support_layers()) {
|
||||
LayerTools &layer_tools = this->tools_for_layer(support_layer->print_z);
|
||||
ExtrusionRole role = support_layer->support_fills.role();
|
||||
bool has_support = role == erMixed || role == erSupportMaterial;
|
||||
bool has_interface = role == erMixed || role == erSupportMaterialInterface;
|
||||
unsigned int extruder_support = object.config.support_material_extruder.value;
|
||||
unsigned int extruder_interface = object.config.support_material_interface_extruder.value;
|
||||
unsigned int extruder_support = object.config().support_material_extruder.value;
|
||||
unsigned int extruder_interface = object.config().support_material_interface_extruder.value;
|
||||
if (has_support)
|
||||
layer_tools.extruders.push_back(extruder_support);
|
||||
if (has_interface)
|
||||
@@ -126,16 +126,16 @@ void ToolOrdering::collect_extruders(const PrintObject &object)
|
||||
layer_tools.has_support = true;
|
||||
}
|
||||
// Collect the object extruders.
|
||||
for (auto layer : object.layers) {
|
||||
for (auto layer : object.layers()) {
|
||||
LayerTools &layer_tools = this->tools_for_layer(layer->print_z);
|
||||
// What extruders are required to print this object layer?
|
||||
for (size_t region_id = 0; region_id < object.print()->regions.size(); ++ region_id) {
|
||||
const LayerRegion *layerm = (region_id < layer->regions.size()) ? layer->regions[region_id] : nullptr;
|
||||
for (size_t region_id = 0; region_id < object.print()->regions().size(); ++ region_id) {
|
||||
const LayerRegion *layerm = (region_id < layer->regions().size()) ? layer->regions()[region_id] : nullptr;
|
||||
if (layerm == nullptr)
|
||||
continue;
|
||||
const PrintRegion ®ion = *object.print()->regions[region_id];
|
||||
const PrintRegion ®ion = *object.print()->regions()[region_id];
|
||||
if (! layerm->perimeters.entities.empty()) {
|
||||
layer_tools.extruders.push_back(region.config.perimeter_extruder.value);
|
||||
layer_tools.extruders.push_back(region.config().perimeter_extruder.value);
|
||||
layer_tools.has_object = true;
|
||||
}
|
||||
bool has_infill = false;
|
||||
@@ -150,9 +150,9 @@ void ToolOrdering::collect_extruders(const PrintObject &object)
|
||||
has_infill = true;
|
||||
}
|
||||
if (has_solid_infill)
|
||||
layer_tools.extruders.push_back(region.config.solid_infill_extruder);
|
||||
layer_tools.extruders.push_back(region.config().solid_infill_extruder);
|
||||
if (has_infill)
|
||||
layer_tools.extruders.push_back(region.config.infill_extruder);
|
||||
layer_tools.extruders.push_back(region.config().infill_extruder);
|
||||
if (has_solid_infill || has_infill)
|
||||
layer_tools.has_object = true;
|
||||
}
|
||||
|
||||
@@ -396,8 +396,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
||||
}
|
||||
|
||||
this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false);
|
||||
this->m_num_layer_changes = 0;
|
||||
this->m_current_tool = tools.front();
|
||||
m_num_layer_changes = 0;
|
||||
m_current_tool = tools.front();
|
||||
|
||||
// The Prusa i3 MK2 has a working space of [0, -2.2] to [250, 210].
|
||||
// Due to the XYZ calibration, this working space may shrink slightly from all directions,
|
||||
@@ -439,9 +439,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
||||
if (last_wipe_inside_wipe_tower) {
|
||||
// Shrink the last wipe area to the area of the other purge areas,
|
||||
// remember the last initial wipe width to be purged into the 1st layer of the wipe tower.
|
||||
this->m_initial_extra_wipe = std::max(0.f, wipe_area - (y_end + 0.5f * 0.85f * m_perimeter_width - cleaning_box.ld.y));
|
||||
cleaning_box.lu.y -= this->m_initial_extra_wipe;
|
||||
cleaning_box.ru.y -= this->m_initial_extra_wipe;
|
||||
m_initial_extra_wipe = std::max(0.f, wipe_area - (y_end + 0.5f * 0.85f * m_perimeter_width - cleaning_box.ld.y));
|
||||
cleaning_box.lu.y -= m_initial_extra_wipe;
|
||||
cleaning_box.ru.y -= m_initial_extra_wipe;
|
||||
}
|
||||
toolchange_Wipe(writer, cleaning_box, false);
|
||||
} else {
|
||||
@@ -471,8 +471,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
||||
m_idx_tool_change_in_layer = (unsigned int)(-1);
|
||||
|
||||
ToolChangeResult result;
|
||||
result.print_z = this->m_z_pos;
|
||||
result.layer_height = this->m_layer_height;
|
||||
result.print_z = m_z_pos;
|
||||
result.layer_height = m_layer_height;
|
||||
result.gcode = writer.gcode();
|
||||
result.elapsed_time = writer.elapsed_time();
|
||||
result.extrusions = writer.extrusions();
|
||||
@@ -612,8 +612,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
|
||||
}
|
||||
|
||||
ToolChangeResult result;
|
||||
result.print_z = this->m_z_pos;
|
||||
result.layer_height = this->m_layer_height;
|
||||
result.print_z = m_z_pos;
|
||||
result.layer_height = m_layer_height;
|
||||
result.gcode = writer.gcode();
|
||||
result.elapsed_time = writer.elapsed_time();
|
||||
result.extrusions = writer.extrusions();
|
||||
@@ -718,8 +718,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b
|
||||
}
|
||||
|
||||
ToolChangeResult result;
|
||||
result.print_z = this->m_z_pos;
|
||||
result.layer_height = this->m_layer_height;
|
||||
result.print_z = m_z_pos;
|
||||
result.layer_height = m_layer_height;
|
||||
result.gcode = writer.gcode();
|
||||
result.elapsed_time = writer.elapsed_time();
|
||||
result.extrusions = writer.extrusions();
|
||||
@@ -1040,8 +1040,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer(Purpose purpose)
|
||||
}
|
||||
|
||||
ToolChangeResult result;
|
||||
result.print_z = this->m_z_pos;
|
||||
result.layer_height = this->m_layer_height;
|
||||
result.print_z = m_z_pos;
|
||||
result.layer_height = m_layer_height;
|
||||
result.gcode = writer.gcode();
|
||||
result.elapsed_time = writer.elapsed_time();
|
||||
result.extrusions = writer.extrusions();
|
||||
|
||||
Reference in New Issue
Block a user