diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index de43bfaec..1793f5e93 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1738,13 +1738,9 @@ void GCode::process_layer( // This extrusion is part of certain Region, which tells us which extruder should be used for it: int correct_extruder_id = Print::get_extruder(*fill, region); - //FIXME what is this? - entity_type=="infills" ? - std::max<int>(0, (is_solid_infill(fill->entities.front()->role()) ? region.config().solid_infill_extruder : region.config().infill_extruder) - 1) : - std::max<int>(region.config().perimeter_extruder.value - 1, 0); // Let's recover vector of extruder overrides: - const ExtruderPerCopy* entity_overrides = const_cast<LayerTools&>(layer_tools).wiping_extrusions().get_extruder_overrides(fill, correct_extruder_id, (int)layer_to_print.object()->copies().size()); + const ExtruderPerCopy* entity_overrides = const_cast<LayerTools&>(layer_tools).wiping_extrusions().get_extruder_overrides(fill, correct_extruder_id, layer_to_print.object()->copies().size()); // Now we must add this extrusion into the by_extruder map, once for each extruder that will print it: for (unsigned int extruder : layer_tools.extruders) @@ -3027,7 +3023,7 @@ const std::vector<GCode::ObjectByExtruder::Island::Region>& GCode::ObjectByExtru // This function takes the eec and appends its entities to either perimeters or infills of this Region (depending on the first parameter) // It also saves pointer to ExtruderPerCopy struct (for each entity), that holds information about which extruders should be used for which copy. -void GCode::ObjectByExtruder::Island::Region::append(const std::string& type, const ExtrusionEntityCollection* eec, const ExtruderPerCopy* copies_extruder, unsigned int object_copies_num) +void GCode::ObjectByExtruder::Island::Region::append(const std::string& type, const ExtrusionEntityCollection* eec, const ExtruderPerCopy* copies_extruder, size_t object_copies_num) { // We are going to manipulate either perimeters or infills, exactly in the same way. Let's create pointers to the proper structure to not repeat ourselves: ExtrusionEntityCollection* perimeters_or_infills = &infills; diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 83d61c483..72813810b 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -246,7 +246,7 @@ protected: std::vector<const ExtruderPerCopy*> perimeters_overrides; // Appends perimeter/infill entities and writes don't indices of those that are not to be extruder as part of perimeter/infill wiping - void append(const std::string& type, const ExtrusionEntityCollection* eec, const ExtruderPerCopy* copy_extruders, unsigned int object_copies_num); + void append(const std::string& type, const ExtrusionEntityCollection* eec, const ExtruderPerCopy* copy_extruders, size_t object_copies_num); }; std::vector<Region> by_region; // all extrusions for this island, grouped by regions diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 9280aa33a..677d6b868 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -458,14 +458,14 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int continue; } - const auto& object = object_list[i]; + const PrintObject* object = object_list[i]; // Finds this layer: auto this_layer_it = std::find_if(object->layers().begin(), object->layers().end(), [<](const Layer* lay) { return std::abs(lt.print_z - lay->print_z)<EPSILON; }); if (this_layer_it == object->layers().end()) continue; const Layer* this_layer = *this_layer_it; - unsigned int num_of_copies = object->copies().size(); + size_t num_of_copies = object->copies().size(); for (unsigned int copy = 0; copy < num_of_copies; ++copy) { // iterate through copies first, so that we mark neighbouring infills to minimize travel moves @@ -494,7 +494,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int if ((!is_entity_overridden(fill, copy) && fill->total_volume() > min_infill_volume)) { // this infill will be used to wipe this extruder set_extruder_override(fill, copy, new_extruder, num_of_copies); - volume_to_wipe -= fill->total_volume(); + volume_to_wipe -= float(fill->total_volume()); } } } @@ -512,7 +512,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int if ((!is_entity_overridden(fill, copy) && fill->total_volume() > min_infill_volume)) { set_extruder_override(fill, copy, new_extruder, num_of_copies); - volume_to_wipe -= fill->total_volume(); + volume_to_wipe -= float(fill->total_volume()); } } } @@ -540,9 +540,9 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print) if (this_layer_it == object->layers().end()) continue; const Layer* this_layer = *this_layer_it; - unsigned int num_of_copies = object->copies().size(); + size_t num_of_copies = object->copies().size(); - for (unsigned int copy = 0; copy < num_of_copies; ++copy) { // iterate through copies first, so that we mark neighbouring infills to minimize travel moves + for (size_t copy = 0; copy < num_of_copies; ++copy) { // iterate through copies first, so that we mark neighbouring infills to minimize travel moves for (size_t region_id = 0; region_id < object->region_volumes.size(); ++ region_id) { const auto& region = *object->print()->regions()[region_id]; @@ -598,7 +598,7 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print) // so -1 was used as "print as usual". // The resulting vector has to keep track of which extrusions are the ones that were overridden and which were not. In the extruder is used as overridden, // its number is saved as it is (zero-based index). Usual extrusions are saved as -number-1 (unfortunately there is no negative zero). -const std::vector<int>* WipingExtrusions::get_extruder_overrides(const ExtrusionEntity* entity, int correct_extruder_id, int num_of_copies) +const std::vector<int>* WipingExtrusions::get_extruder_overrides(const ExtrusionEntity* entity, int correct_extruder_id, size_t num_of_copies) { auto entity_map_it = entity_map.find(entity); if (entity_map_it == entity_map.end()) diff --git a/src/libslic3r/GCode/ToolOrdering.hpp b/src/libslic3r/GCode/ToolOrdering.hpp index d4006120d..0d4b83ecb 100644 --- a/src/libslic3r/GCode/ToolOrdering.hpp +++ b/src/libslic3r/GCode/ToolOrdering.hpp @@ -24,7 +24,7 @@ public: } // This is called from GCode::process_layer - see implementation for further comments: - const std::vector<int>* get_extruder_overrides(const ExtrusionEntity* entity, int correct_extruder_id, int num_of_copies); + const std::vector<int>* get_extruder_overrides(const ExtrusionEntity* entity, int correct_extruder_id, size_t num_of_copies); // This function goes through all infill entities, decides which ones will be used for wiping and // marks them by the extruder id. Returns volume that remains to be wiped on the wipe tower: @@ -44,7 +44,7 @@ private: void set_extruder_override(const ExtrusionEntity* entity, unsigned int copy_id, int extruder, unsigned int num_of_copies); // Returns true in case that entity is not printed with its usual extruder for a given copy: - bool is_entity_overridden(const ExtrusionEntity* entity, int copy_id) const { + bool is_entity_overridden(const ExtrusionEntity* entity, size_t copy_id) const { return (entity_map.find(entity) == entity_map.end() ? false : entity_map.at(entity).at(copy_id) != -1); } diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 9745f23df..9e2ec1251 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -184,7 +184,7 @@ public: if (f != 0.f && f != m_current_feedrate) { if (limit_volumetric_flow) { - float e_speed = e / (((len == 0) ? std::abs(e) : len) / f * 60.f); + float e_speed = e / (((len == 0.f) ? std::abs(e) : len) / f * 60.f); f /= std::max(1.f, e_speed / m_filpar[m_current_tool].max_e_speed); } m_gcode += set_format_F(f); @@ -194,7 +194,7 @@ public: m_current_pos.y() = y; // Update the elapsed time with a rough estimate. - m_elapsed_time += ((len == 0) ? std::abs(e) : len) / m_current_feedrate * 60.f; + m_elapsed_time += ((len == 0.f) ? std::abs(e) : len) / m_current_feedrate * 60.f; m_gcode += "\n"; return *this; } @@ -387,14 +387,14 @@ public: } - WipeTowerWriter& set_fan(unsigned int speed) + WipeTowerWriter& set_fan(unsigned speed) { if (speed == m_last_fan_speed) return *this; if (speed == 0) m_gcode += "M107\n"; else - m_gcode += "M106 S" + std::to_string((size_t)(255.0 * speed / 100.0)) + "\n"; + m_gcode += "M106 S" + std::to_string(unsigned(255.0 * speed / 100.0)) + "\n"; m_last_fan_speed = speed; return *this; } @@ -417,7 +417,7 @@ private: float m_y_shift = 0.f; float m_wipe_tower_width = 0.f; float m_wipe_tower_depth = 0.f; - float m_last_fan_speed = 0.f; + unsigned m_last_fan_speed = 0.f; int current_temp = -1; const float m_default_analyzer_line_width; float m_used_filament_length = 0.f; @@ -466,12 +466,12 @@ private: WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) : m_semm(config.single_extruder_multi_material.value), m_wipe_tower_pos(config.wipe_tower_x, config.wipe_tower_y), - m_wipe_tower_width(config.wipe_tower_width), - m_wipe_tower_rotation_angle(config.wipe_tower_rotation_angle), + m_wipe_tower_width(float(config.wipe_tower_width)), + m_wipe_tower_rotation_angle(float(config.wipe_tower_rotation_angle)), m_y_shift(0.f), m_z_pos(0.f), m_is_first_layer(false), - m_bridging(config.wipe_tower_bridging), + m_bridging(float(config.wipe_tower_bridging)), m_gcode_flavor(config.gcode_flavor), m_current_tool(initial_tool), wipe_volumes(wiping_matrix) @@ -479,16 +479,16 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl // If this is a single extruder MM printer, we will use all the SE-specific config values. // Otherwise, the defaults will be used to turn off the SE stuff. if (m_semm) { - m_cooling_tube_retraction = config.cooling_tube_retraction; - m_cooling_tube_length = config.cooling_tube_length; - m_parking_pos_retraction = config.parking_pos_retraction; - m_extra_loading_move = config.extra_loading_move; - m_set_extruder_trimpot = config.high_current_on_filament_swap; + m_cooling_tube_retraction = float(config.cooling_tube_retraction); + m_cooling_tube_length = float(config.cooling_tube_length); + m_parking_pos_retraction = float(config.parking_pos_retraction); + m_extra_loading_move = float(config.extra_loading_move); + m_set_extruder_trimpot = config.high_current_on_filament_swap; } // Calculate where the priming lines should be - very naive test not detecting parallelograms or custom shapes const std::vector<Vec2d>& bed_points = config.bed_shape.values; m_bed_shape = (bed_points.size() == 4 ? RectangularBed : CircularBed); - m_bed_width = BoundingBoxf(bed_points).size().x(); + m_bed_width = float(BoundingBoxf(bed_points).size().x()); } @@ -505,21 +505,21 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config) // If this is a single extruder MM printer, we will use all the SE-specific config values. // Otherwise, the defaults will be used to turn off the SE stuff. if (m_semm) { - m_filpar[idx].loading_speed = config.filament_loading_speed.get_at(idx); - m_filpar[idx].loading_speed_start = config.filament_loading_speed_start.get_at(idx); - m_filpar[idx].unloading_speed = config.filament_unloading_speed.get_at(idx); - m_filpar[idx].unloading_speed_start = config.filament_unloading_speed_start.get_at(idx); - m_filpar[idx].delay = config.filament_toolchange_delay.get_at(idx); + m_filpar[idx].loading_speed = float(config.filament_loading_speed.get_at(idx)); + m_filpar[idx].loading_speed_start = float(config.filament_loading_speed_start.get_at(idx)); + m_filpar[idx].unloading_speed = float(config.filament_unloading_speed.get_at(idx)); + m_filpar[idx].unloading_speed_start = float(config.filament_unloading_speed_start.get_at(idx)); + m_filpar[idx].delay = float(config.filament_toolchange_delay.get_at(idx)); m_filpar[idx].cooling_moves = config.filament_cooling_moves.get_at(idx); - m_filpar[idx].cooling_initial_speed = config.filament_cooling_initial_speed.get_at(idx); - m_filpar[idx].cooling_final_speed = config.filament_cooling_final_speed.get_at(idx); + m_filpar[idx].cooling_initial_speed = float(config.filament_cooling_initial_speed.get_at(idx)); + m_filpar[idx].cooling_final_speed = float(config.filament_cooling_final_speed.get_at(idx)); } m_filpar[idx].filament_area = float((M_PI/4.f) * pow(config.filament_diameter.get_at(idx), 2)); // all extruders are assumed to have the same filament diameter at this point - float nozzle_diameter = config.nozzle_diameter.get_at(idx); + float nozzle_diameter = float(config.nozzle_diameter.get_at(idx)); m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM - float max_vol_speed = config.filament_max_volumetric_speed.get_at(idx); + float max_vol_speed = float(config.filament_max_volumetric_speed.get_at(idx)); if (max_vol_speed!= 0.f) m_filpar[idx].max_e_speed = (max_vol_speed / filament_area()); @@ -548,7 +548,7 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime( const std::vector<unsigned int> &tools, // If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower. // If false, the last priming are will be large enough to wipe the last extruder sufficiently. - bool last_wipe_inside_wipe_tower) + bool /*last_wipe_inside_wipe_tower*/) { this->set_layer(first_layer_height, first_layer_height, tools.size(), true, false); this->m_current_tool = tools.front(); @@ -683,7 +683,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(unsigned int tool, bool last_ box_coordinates cleaning_box( Vec2f(m_perimeter_width / 2.f, m_perimeter_width / 2.f), m_wipe_tower_width - m_perimeter_width, - (tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width + (tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5f*m_perimeter_width : m_wipe_tower_depth-m_perimeter_width)); WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar); @@ -789,7 +789,7 @@ WipeTower::ToolChangeResult WipeTower::toolchange_Brim(bool sideOnly, float y_of // Extrude 4 rounds of a brim around the future wipe tower. box_coordinates box(wipeTower_box); for (size_t i = 0; i < 4; ++ i) { - box.expand(m_perimeter_width - m_layer_height*(1.f-M_PI_4)); // the brim shall have 'normal' spacing with no extra void space + box.expand(m_perimeter_width - m_layer_height*float(1.-M_PI_4)); // the brim shall have 'normal' spacing with no extra void space writer.travel (box.ld, 7000) .extrude(box.lu, 2100).extrude(box.ru) .extrude(box.rd ).extrude(box.ld); @@ -898,8 +898,8 @@ void WipeTower::toolchange_Unload( const float x = volume_to_length(m_filpar[m_current_tool].ramming_speed[i] * 0.25f, line_width, m_layer_height); const float e = m_filpar[m_current_tool].ramming_speed[i] * 0.25f / filament_area(); // transform volume per sec to E move; const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround - const float actual_time = dist/x * 0.25; - writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), dist / (actual_time / 60.)); + const float actual_time = dist/x * 0.25f; + writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0.f, 0.f, e * (dist / x), dist / (actual_time / 60.f)); remaining -= dist; if (remaining < WT_EPSILON) { // we reached a turning point @@ -1078,21 +1078,21 @@ void WipeTower::toolchange_Wipe( float traversed_x = writer.x(); if (m_left_to_right) - writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); else - writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); + writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); - if (writer.y()+EPSILON > cleaning_box.lu.y()-0.5f*m_perimeter_width) + if (writer.y()+float(EPSILON) > cleaning_box.lu.y()-0.5f*m_perimeter_width) break; // in case next line would not fit traversed_x -= writer.x(); - x_to_wipe -= fabs(traversed_x); + x_to_wipe -= std::abs(traversed_x); if (x_to_wipe < WT_EPSILON) { - writer.travel(m_left_to_right ? xl + 1.5*m_perimeter_width : xr - 1.5*m_perimeter_width, writer.y(), 7200); + writer.travel(m_left_to_right ? xl + 1.5f*m_perimeter_width : xr - 1.5f*m_perimeter_width, writer.y(), 7200); break; } // stepping to the next line: - writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * 1.5*m_perimeter_width, writer.y() + dy); + writer.extrude(writer.x() + (i % 4 == 0 ? -1.f : (i % 4 == 1 ? 1.f : 0.f)) * 1.5f*m_perimeter_width, writer.y() + dy); m_left_to_right = !m_left_to_right; } @@ -1175,7 +1175,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer() writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f)) .extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), 2900 * speed_factor); - const int n = 1+(right-left)/(m_bridging); + const int n = 1+int((right-left)/m_bridging); const float dx = (right-left)/n; for (int i=1;i<=n;++i) { float x=left+dx*i; @@ -1254,7 +1254,7 @@ void WipeTower::plan_tower() for (auto& layer : m_plan) layer.depth = 0.f; - for (int layer_index = m_plan.size() - 1; layer_index >= 0; --layer_index) + for (int layer_index = int(m_plan.size()) - 1; layer_index >= 0; --layer_index) { float this_layer_depth = std::max(m_plan[layer_index].depth, m_plan[layer_index].toolchanges_depth()); m_plan[layer_index].depth = this_layer_depth;