Merge remote-tracking branch 'origin/master' into ys_printable_property

This commit is contained in:
YuSanka 2019-08-05 08:45:47 +02:00
commit 825446d145
22 changed files with 241 additions and 150 deletions

View file

@ -1,4 +1,5 @@
#include "libslic3r.h"
#include "I18N.hpp"
#include "GCode.hpp"
#include "ExtrusionEntity.hpp"
#include "EdgeGrid.hpp"
@ -36,6 +37,11 @@
namespace Slic3r {
//! macro used to mark string used at localization,
//! return same string
#define L(s) (s)
#define _(s) Slic3r::I18N::translate(s)
// Only add a newline in case the current G-code does not end with a newline.
static inline void check_add_eol(std::string &gcode)
{
@ -405,7 +411,8 @@ std::string WipeTowerIntegration::tool_change(GCode &gcodegen, int extruder_id,
assert(m_layer_idx >= 0 && size_t(m_layer_idx) <= m_tool_changes.size());
if (! m_brim_done || gcodegen.writer().need_toolchange(extruder_id) || finish_layer) {
if (m_layer_idx < (int)m_tool_changes.size()) {
assert(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size());
if (! (size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
throw std::runtime_error("Wipe tower generation failed, possibly due to empty first layer.");
gcode += append_tcr(gcodegen, m_tool_changes[m_layer_idx][m_tool_change_idx++], extruder_id);
}
m_brim_done = true;
@ -448,6 +455,17 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
-- idx_object_layer;
}
}
// Let's make sure that the last layer is not empty, so we don't build on top of it.
if (! layers_to_print.empty()
&& ((layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions())
|| (layer_to_print.support_layer && layer_to_print.support_layer->has_extrusions()))
&& (! layers_to_print.back().object_layer || ! layers_to_print.back().object_layer->has_extrusions())
&& (! layers_to_print.back().support_layer || ! layers_to_print.back().support_layer->has_extrusions()))
throw std::runtime_error(_(L("Empty layers detected, the output would not be printable.")) + "\n\n" +
_(L("Object name: ")) + object.model_object()->name + "\n" + _(L("Print z: ")) +
std::to_string(layers_to_print.back().print_z()));
layers_to_print.emplace_back(layer_to_print);
}
@ -1138,9 +1156,9 @@ void GCode::_do_export(Print &print, FILE *file)
print.m_print_statistics.clear();
print.m_print_statistics.estimated_normal_print_time = m_normal_time_estimator.get_time_dhms();
print.m_print_statistics.estimated_silent_print_time = m_silent_time_estimator_enabled ? m_silent_time_estimator.get_time_dhms() : "N/A";
print.m_print_statistics.estimated_normal_color_print_times = m_normal_time_estimator.get_color_times_dhms();
print.m_print_statistics.estimated_normal_color_print_times = m_normal_time_estimator.get_color_times_dhms(true);
if (m_silent_time_estimator_enabled)
print.m_print_statistics.estimated_silent_color_print_times = m_silent_time_estimator.get_color_times_dhms();
print.m_print_statistics.estimated_silent_color_print_times = m_silent_time_estimator.get_color_times_dhms(true);
std::vector<Extruder> extruders = m_writer.extruders();
if (! extruders.empty()) {

View file

@ -78,8 +78,13 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool
zs.emplace_back(layer->print_z);
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;
// Find first object layer that is not empty and save its print_z
for (const Layer* layer : object->layers())
if (layer->has_extrusions()) {
object_bottom_z = layer->print_z - layer->height;
break;
}
}
this->initialize_layers(zs);
}
@ -324,6 +329,7 @@ void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_
m_layer_tools[j].has_wipe_tower = true;
} else {
LayerTools &lt_extra = *m_layer_tools.insert(m_layer_tools.begin() + j, lt_new);
//LayerTools &lt_prev = m_layer_tools[j];
LayerTools &lt_next = m_layer_tools[j + 1];
assert(! m_layer_tools[j - 1].extruders.empty() && ! lt_next.extruders.empty());
// FIXME: Following assert tripped when running combine_infill.t. I decided to comment it out for now.

View file

@ -1242,6 +1242,8 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
for (auto& used : m_used_filament_length) // reset used filament stats
used = 0.f;
m_old_temperature = -1; // reset last temperature written in the gcode
std::vector<WipeTower::ToolChangeResult> layer_result;
for (auto layer : m_plan)
{

View file

@ -694,22 +694,39 @@ namespace Slic3r {
return m_color_times;
}
std::vector<std::string> GCodeTimeEstimator::get_color_times_dhms() const
std::vector<std::string> GCodeTimeEstimator::get_color_times_dhms(bool include_remaining) const
{
std::vector<std::string> ret;
float total_time = 0.0f;
for (float t : m_color_times)
{
ret.push_back(_get_time_dhms(t));
std::string time = _get_time_dhms(t);
if (include_remaining)
{
time += " (";
time += _get_time_dhms(m_time - total_time);
time += ")";
}
total_time += t;
ret.push_back(time);
}
return ret;
}
std::vector<std::string> GCodeTimeEstimator::get_color_times_minutes() const
std::vector<std::string> GCodeTimeEstimator::get_color_times_minutes(bool include_remaining) const
{
std::vector<std::string> ret;
float total_time = 0.0f;
for (float t : m_color_times)
{
ret.push_back(_get_time_minutes(t));
std::string time = _get_time_minutes(t);
if (include_remaining)
{
time += " (";
time += _get_time_minutes(m_time - total_time);
time += ")";
}
total_time += t;
}
return ret;
}

View file

@ -346,14 +346,16 @@ namespace Slic3r {
// Returns the estimated time, in minutes (integer)
std::string get_time_minutes() const;
// Returns the estimated time, in seconds, for each color
// Returns the estimated time, in seconds, for each color
std::vector<float> get_color_times() const;
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
std::vector<std::string> get_color_times_dhms() const;
// If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)"
std::vector<std::string> get_color_times_dhms(bool include_remaining) const;
// Returns the estimated time, in minutes (integer), for each color
std::vector<std::string> get_color_times_minutes() const;
// If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)"
std::vector<std::string> get_color_times_minutes(bool include_remaining) const;
// Return an estimate of the memory consumed by the time estimator.
size_t memory_used() const;

View file

@ -99,8 +99,7 @@ Model Model::read_from_file(const std::string &input_file, DynamicPrintConfig *c
result = load_stl(input_file.c_str(), &model);
else if (boost::algorithm::iends_with(input_file, ".obj"))
result = load_obj(input_file.c_str(), &model);
else if (!boost::algorithm::iends_with(input_file, ".zip.amf") && (boost::algorithm::iends_with(input_file, ".amf") ||
boost::algorithm::iends_with(input_file, ".amf.xml")))
else if (boost::algorithm::iends_with(input_file, ".amf") || boost::algorithm::iends_with(input_file, ".amf.xml"))
result = load_amf(input_file.c_str(), config, &model);
else if (boost::algorithm::iends_with(input_file, ".3mf"))
result = load_3mf(input_file.c_str(), config, &model);

View file

@ -1723,7 +1723,7 @@ void Print::_make_wipe_tower()
break;
lt.has_support = true;
// Insert the new support layer.
double height = lt.print_z - m_wipe_tower_data.tool_ordering.layer_tools()[i-1].print_z;
double height = lt.print_z - (i == 0 ? 0. : m_wipe_tower_data.tool_ordering.layer_tools()[i-1].print_z);
//FIXME the support layer ID is set to -1, as Vojtech hopes it is not being used anyway.
it_layer = m_objects.front()->insert_support_layer(it_layer, -1, height, lt.print_z, lt.print_z - 0.5 * height);
++ it_layer;

View file

@ -422,6 +422,7 @@ void PrintConfigDef::init_fff_params()
def->cli = "bottom-fill-pattern|external-fill-pattern|solid-fill-pattern";
def->enum_keys_map = &ConfigOptionEnum<InfillPattern>::get_enum_values();
def->enum_values = def_top_fill_pattern->enum_values;
def->enum_labels = def_top_fill_pattern->enum_labels;
def->aliases = def_top_fill_pattern->aliases;
def->set_default_value(new ConfigOptionEnum<InfillPattern>(ipRectilinear));