mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-25 09:41:11 -06:00
Fixed conflicts after merge with master
This commit is contained in:
commit
ab1e90ec0d
33 changed files with 688 additions and 544 deletions
|
|
@ -64,6 +64,7 @@ add_library(libslic3r STATIC
|
|||
Fill/FillRectilinear3.hpp
|
||||
Flow.cpp
|
||||
Flow.hpp
|
||||
format.hpp
|
||||
Format/3mf.cpp
|
||||
Format/3mf.hpp
|
||||
Format/AMF.cpp
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "Config.hpp"
|
||||
#include "format.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include <assert.h>
|
||||
#include <fstream>
|
||||
|
|
@ -464,7 +465,7 @@ bool ConfigBase::set_deserialize_nothrow(const t_config_option_key &opt_key_src,
|
|||
void ConfigBase::set_deserialize(const t_config_option_key &opt_key_src, const std::string &value_src, bool append)
|
||||
{
|
||||
if (! this->set_deserialize_nothrow(opt_key_src, value_src, append))
|
||||
throw BadOptionTypeException((boost::format("ConfigBase::set_deserialize() failed for parameter \"%1%\", value \"%2%\"") % opt_key_src % value_src).str());
|
||||
throw BadOptionTypeException(format("ConfigBase::set_deserialize() failed for parameter \"%1%\", value \"%2%\"", opt_key_src, value_src));
|
||||
}
|
||||
|
||||
void ConfigBase::set_deserialize(std::initializer_list<SetDeserializeItem> items)
|
||||
|
|
@ -620,7 +621,7 @@ void ConfigBase::load_from_gcode_file(const std::string &file)
|
|||
|
||||
size_t key_value_pairs = load_from_gcode_string(data.data());
|
||||
if (key_value_pairs < 80)
|
||||
throw std::runtime_error((boost::format("Suspiciously low number of configuration values extracted from %1%: %2%") % file % key_value_pairs).str());
|
||||
throw std::runtime_error(format("Suspiciously low number of configuration values extracted from %1%: %2%", file, key_value_pairs));
|
||||
}
|
||||
|
||||
// Load the config keys from the given string.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ static const float INCHES_TO_MM = 25.4f;
|
|||
static const float DEFAULT_FEEDRATE = 0.0f;
|
||||
static const unsigned int DEFAULT_EXTRUDER_ID = 0;
|
||||
static const unsigned int DEFAULT_COLOR_PRINT_ID = 0;
|
||||
static const Slic3r::Vec3d DEFAULT_START_POSITION = Slic3r::Vec3d(0.0f, 0.0f, 0.0f);
|
||||
static const Slic3r::Vec3f DEFAULT_START_POSITION = Slic3r::Vec3f::Zero();
|
||||
static const float DEFAULT_START_EXTRUSION = 0.0f;
|
||||
static const float DEFAULT_FAN_SPEED = 0.0f;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ const std::string GCodeAnalyzer::Pause_Print_Tag = "_ANALYZER_PAUSE_PRINT";
|
|||
const std::string GCodeAnalyzer::Custom_Code_Tag = "_ANALYZER_CUSTOM_CODE";
|
||||
const std::string GCodeAnalyzer::End_Pause_Print_Or_Custom_Code_Tag = "_ANALYZER_END_PAUSE_PRINT_OR_CUSTOM_CODE";
|
||||
|
||||
const double GCodeAnalyzer::Default_mm3_per_mm = 0.0;
|
||||
const float GCodeAnalyzer::Default_mm3_per_mm = 0.0f;
|
||||
const float GCodeAnalyzer::Default_Width = 0.0f;
|
||||
const float GCodeAnalyzer::Default_Height = 0.0f;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ GCodeAnalyzer::Metadata::Metadata()
|
|||
{
|
||||
}
|
||||
|
||||
GCodeAnalyzer::Metadata::Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, float fan_speed, unsigned int cp_color_id/* = 0*/)
|
||||
GCodeAnalyzer::Metadata::Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, float mm3_per_mm, float width, float height, float feedrate, float fan_speed, unsigned int cp_color_id/* = 0*/)
|
||||
: extrusion_role(extrusion_role)
|
||||
, extruder_id(extruder_id)
|
||||
, mm3_per_mm(mm3_per_mm)
|
||||
|
|
@ -90,7 +90,7 @@ bool GCodeAnalyzer::Metadata::operator != (const GCodeAnalyzer::Metadata& other)
|
|||
return false;
|
||||
}
|
||||
|
||||
GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder, float fan_speed, unsigned int cp_color_id/* = 0*/)
|
||||
GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, float mm3_per_mm, float width, float height, float feedrate, const Vec3f& start_position, const Vec3f& end_position, float delta_extruder, float fan_speed, unsigned int cp_color_id/* = 0*/)
|
||||
: type(type)
|
||||
, data(extrusion_role, extruder_id, mm3_per_mm, width, height, feedrate, fan_speed, cp_color_id)
|
||||
, start_position(start_position)
|
||||
|
|
@ -99,7 +99,7 @@ GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusi
|
|||
{
|
||||
}
|
||||
|
||||
GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, const GCodeAnalyzer::Metadata& data, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder)
|
||||
GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, const GCodeAnalyzer::Metadata& data, const Vec3f& start_position, const Vec3f& end_position, float delta_extruder)
|
||||
: type(type)
|
||||
, data(data)
|
||||
, start_position(start_position)
|
||||
|
|
@ -704,7 +704,7 @@ void GCodeAnalyzer::_process_extrusion_role_tag(const std::string& comment, size
|
|||
|
||||
void GCodeAnalyzer::_process_mm3_per_mm_tag(const std::string& comment, size_t pos)
|
||||
{
|
||||
_set_mm3_per_mm(::strtod(comment.substr(pos + Mm3_Per_Mm_Tag.length()).c_str(), nullptr));
|
||||
_set_mm3_per_mm((float)::strtod(comment.substr(pos + Mm3_Per_Mm_Tag.length()).c_str(), nullptr));
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_process_width_tag(const std::string& comment, size_t pos)
|
||||
|
|
@ -797,12 +797,12 @@ unsigned int GCodeAnalyzer::_get_cp_color_id() const
|
|||
return m_state.data.cp_color_id;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_mm3_per_mm(double value)
|
||||
void GCodeAnalyzer::_set_mm3_per_mm(float value)
|
||||
{
|
||||
m_state.data.mm3_per_mm = value;
|
||||
}
|
||||
|
||||
double GCodeAnalyzer::_get_mm3_per_mm() const
|
||||
float GCodeAnalyzer::_get_mm3_per_mm() const
|
||||
{
|
||||
return m_state.data.mm3_per_mm;
|
||||
}
|
||||
|
|
@ -877,12 +877,12 @@ void GCodeAnalyzer::_reset_axes_origin()
|
|||
::memset((void*)m_state.origin, 0, Num_Axis * sizeof(float));
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_start_position(const Vec3d& position)
|
||||
void GCodeAnalyzer::_set_start_position(const Vec3f& position)
|
||||
{
|
||||
m_state.start_position = position;
|
||||
}
|
||||
|
||||
const Vec3d& GCodeAnalyzer::_get_start_position() const
|
||||
const Vec3f& GCodeAnalyzer::_get_start_position() const
|
||||
{
|
||||
return m_state.start_position;
|
||||
}
|
||||
|
|
@ -913,9 +913,9 @@ float GCodeAnalyzer::_get_delta_extrusion() const
|
|||
return _get_axis_position(E) - m_state.start_extrusion;
|
||||
}
|
||||
|
||||
Vec3d GCodeAnalyzer::_get_end_position() const
|
||||
Vec3f GCodeAnalyzer::_get_end_position() const
|
||||
{
|
||||
return Vec3d(m_state.position[X], m_state.position[Y], m_state.position[Z]);
|
||||
return Vec3f(m_state.position[X], m_state.position[Y], m_state.position[Z]);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
|
||||
|
|
@ -926,14 +926,14 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
|
|||
it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
|
||||
|
||||
// store move
|
||||
Vec3d extruder_offset = Vec3d::Zero();
|
||||
Vec3f extruder_offset = Vec3f::Zero();
|
||||
unsigned int extruder_id = _get_extruder_id();
|
||||
ExtruderOffsetsMap::iterator extr_it = m_extruder_offsets.find(extruder_id);
|
||||
if (extr_it != m_extruder_offsets.end())
|
||||
extruder_offset = Vec3d(extr_it->second(0), extr_it->second(1), 0.0);
|
||||
extruder_offset = Vec3f((float)extr_it->second(0), (float)extr_it->second(1), 0.0f);
|
||||
|
||||
Vec3d start_position = _get_start_position() + extruder_offset;
|
||||
Vec3d end_position = _get_end_position() + extruder_offset;
|
||||
Vec3f start_position = _get_start_position() + extruder_offset;
|
||||
Vec3f end_position = _get_end_position() + extruder_offset;
|
||||
it->second.emplace_back(type, _get_extrusion_role(), extruder_id, _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), start_position, end_position, _get_delta_extrusion(), _get_fan_speed(), _get_cp_color_id());
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_DEBUG_OUTPUT
|
||||
|
|
@ -941,7 +941,7 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
|
|||
{
|
||||
m_debug_output << std::to_string((int)type);
|
||||
m_debug_output << ", " << std::to_string((int)_get_extrusion_role());
|
||||
m_debug_output << ", " << Slic3r::to_string(_get_end_position());
|
||||
m_debug_output << ", " << Slic3r::to_string((Vec3d)_get_end_position().cast<double>());
|
||||
m_debug_output << ", " << std::to_string(extruder_id);
|
||||
m_debug_output << ", " << std::to_string(_get_feedrate());
|
||||
m_debug_output << ", " << std::to_string(_get_width());
|
||||
|
|
@ -985,8 +985,8 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
GCodePreviewData::Extrusion::Path &path = paths.back();
|
||||
path.polyline = polyline;
|
||||
path.extrusion_role = data.extrusion_role;
|
||||
path.mm3_per_mm = float(data.mm3_per_mm);
|
||||
path.width = data.width;
|
||||
path.mm3_per_mm = data.mm3_per_mm;
|
||||
path.width = data.width;
|
||||
path.height = data.height;
|
||||
path.feedrate = data.feedrate;
|
||||
path.extruder_id = data.extruder_id;
|
||||
|
|
@ -1003,7 +1003,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
Metadata data;
|
||||
float z = FLT_MAX;
|
||||
Polyline polyline;
|
||||
Vec3d position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
Vec3f position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
float volumetric_rate = FLT_MAX;
|
||||
GCodePreviewData::Range height_range;
|
||||
GCodePreviewData::Range width_range;
|
||||
|
|
@ -1023,7 +1023,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
if (cancel_callback_curr == 0)
|
||||
cancel_callback();
|
||||
|
||||
if ((data != move.data) || (z != move.start_position.z()) || (position != move.start_position) || (volumetric_rate != move.data.feedrate * (float)move.data.mm3_per_mm))
|
||||
if ((data != move.data) || (z != move.start_position.z()) || (position != move.start_position) || (volumetric_rate != move.data.feedrate * move.data.mm3_per_mm))
|
||||
{
|
||||
// store current polyline
|
||||
polyline.remove_duplicate_points();
|
||||
|
|
@ -1039,7 +1039,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
// update current values
|
||||
data = move.data;
|
||||
z = (float)move.start_position.z();
|
||||
volumetric_rate = move.data.feedrate * (float)move.data.mm3_per_mm;
|
||||
volumetric_rate = move.data.feedrate * move.data.mm3_per_mm;
|
||||
height_range.update_from(move.data.height);
|
||||
width_range.update_from(move.data.width);
|
||||
feedrate_range.update_from(move.data.feedrate, GCodePreviewData::FeedrateKind::EXTRUSION);
|
||||
|
|
@ -1087,7 +1087,7 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data, s
|
|||
return;
|
||||
|
||||
Polyline3 polyline;
|
||||
Vec3d position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
Vec3f position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
GCodePreviewData::Travel::EType type = GCodePreviewData::Travel::Num_Types;
|
||||
GCodePreviewData::Travel::Polyline::EDirection direction = GCodePreviewData::Travel::Polyline::Num_Directions;
|
||||
float feedrate = FLT_MAX;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
static const std::string Custom_Code_Tag;
|
||||
static const std::string End_Pause_Print_Or_Custom_Code_Tag;
|
||||
|
||||
static const double Default_mm3_per_mm;
|
||||
static const float Default_mm3_per_mm;
|
||||
static const float Default_Width;
|
||||
static const float Default_Height;
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ public:
|
|||
{
|
||||
ExtrusionRole extrusion_role;
|
||||
unsigned int extruder_id;
|
||||
double mm3_per_mm;
|
||||
float mm3_per_mm;
|
||||
float width; // mm
|
||||
float height; // mm
|
||||
float feedrate; // mm/s
|
||||
|
|
@ -65,7 +65,7 @@ public:
|
|||
unsigned int cp_color_id;
|
||||
|
||||
Metadata();
|
||||
Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, float fan_speed, unsigned int cp_color_id = 0);
|
||||
Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, float mm3_per_mm, float width, float height, float feedrate, float fan_speed, unsigned int cp_color_id = 0);
|
||||
|
||||
bool operator != (const Metadata& other) const;
|
||||
};
|
||||
|
|
@ -85,12 +85,12 @@ public:
|
|||
|
||||
EType type;
|
||||
Metadata data;
|
||||
Vec3d start_position;
|
||||
Vec3d end_position;
|
||||
Vec3f start_position;
|
||||
Vec3f end_position;
|
||||
float delta_extruder;
|
||||
|
||||
GCodeMove(EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder, float fan_speed, unsigned int cp_color_id = 0);
|
||||
GCodeMove(EType type, const Metadata& data, const Vec3d& start_position, const Vec3d& end_position, float delta_extruder);
|
||||
GCodeMove(EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, float mm3_per_mm, float width, float height, float feedrate, const Vec3f& start_position, const Vec3f& end_position, float delta_extruder, float fan_speed, unsigned int cp_color_id = 0);
|
||||
GCodeMove(EType type, const Metadata& data, const Vec3f& start_position, const Vec3f& end_position, float delta_extruder);
|
||||
};
|
||||
|
||||
typedef std::vector<GCodeMove> GCodeMovesList;
|
||||
|
|
@ -105,7 +105,7 @@ private:
|
|||
EPositioningType global_positioning_type;
|
||||
EPositioningType e_local_positioning_type;
|
||||
Metadata data;
|
||||
Vec3d start_position = Vec3d::Zero();
|
||||
Vec3f start_position = Vec3f::Zero();
|
||||
float cached_position[5];
|
||||
float start_extrusion;
|
||||
float position[Num_Axis];
|
||||
|
|
@ -258,8 +258,8 @@ private:
|
|||
void _set_cp_color_id(unsigned int id);
|
||||
unsigned int _get_cp_color_id() const;
|
||||
|
||||
void _set_mm3_per_mm(double value);
|
||||
double _get_mm3_per_mm() const;
|
||||
void _set_mm3_per_mm(float value);
|
||||
float _get_mm3_per_mm() const;
|
||||
|
||||
void _set_width(float width);
|
||||
float _get_width() const;
|
||||
|
|
@ -284,8 +284,8 @@ private:
|
|||
// Sets origin position to zero
|
||||
void _reset_axes_origin();
|
||||
|
||||
void _set_start_position(const Vec3d& position);
|
||||
const Vec3d& _get_start_position() const;
|
||||
void _set_start_position(const Vec3f& position);
|
||||
const Vec3f& _get_start_position() const;
|
||||
|
||||
void _set_cached_position(unsigned char axis, float position);
|
||||
float _get_cached_position(unsigned char axis) const;
|
||||
|
|
@ -297,7 +297,7 @@ private:
|
|||
float _get_delta_extrusion() const;
|
||||
|
||||
// Returns current xyz position (from m_state.position[])
|
||||
Vec3d _get_end_position() const;
|
||||
Vec3f _get_end_position() const;
|
||||
|
||||
// Adds a new move with the given data
|
||||
void _store_move(GCodeMove::EType type);
|
||||
|
|
|
|||
|
|
@ -46,19 +46,19 @@ namespace Slic3r {
|
|||
::memset(abs_axis_feedrate, 0, Num_Axis * sizeof(float));
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::Trapezoid::acceleration_time(float acceleration) const
|
||||
float GCodeTimeEstimator::Block::Trapezoid::acceleration_time(float entry_feedrate, float acceleration) const
|
||||
{
|
||||
return acceleration_time_from_distance(feedrate.entry, accelerate_until, acceleration);
|
||||
return acceleration_time_from_distance(entry_feedrate, accelerate_until, acceleration);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::Trapezoid::cruise_time() const
|
||||
{
|
||||
return (feedrate.cruise != 0.0f) ? cruise_distance() / feedrate.cruise : 0.0f;
|
||||
return (cruise_feedrate != 0.0f) ? cruise_distance() / cruise_feedrate : 0.0f;
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::Trapezoid::deceleration_time(float acceleration) const
|
||||
float GCodeTimeEstimator::Block::Trapezoid::deceleration_time(float distance, float acceleration) const
|
||||
{
|
||||
return acceleration_time_from_distance(feedrate.cruise, (distance - decelerate_after), -acceleration);
|
||||
return acceleration_time_from_distance(cruise_feedrate, (distance - decelerate_after), -acceleration);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::Trapezoid::cruise_distance() const
|
||||
|
|
@ -78,29 +78,9 @@ namespace Slic3r {
|
|||
return ::sqrt(value);
|
||||
}
|
||||
|
||||
GCodeTimeEstimator::Block::Block()
|
||||
{
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::move_length() const
|
||||
{
|
||||
float length = ::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
||||
return (length > 0.0f) ? length : std::abs(delta_pos[E]);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::is_extruder_only_move() const
|
||||
{
|
||||
return (delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f) && (delta_pos[E] != 0.0f);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::is_travel_move() const
|
||||
{
|
||||
return delta_pos[E] == 0.0f;
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::acceleration_time() const
|
||||
{
|
||||
return trapezoid.acceleration_time(acceleration);
|
||||
return trapezoid.acceleration_time(feedrate.entry, acceleration);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::cruise_time() const
|
||||
|
|
@ -110,7 +90,7 @@ namespace Slic3r {
|
|||
|
||||
float GCodeTimeEstimator::Block::deceleration_time() const
|
||||
{
|
||||
return trapezoid.deceleration_time(acceleration);
|
||||
return trapezoid.deceleration_time(distance, acceleration);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::Block::cruise_distance() const
|
||||
|
|
@ -120,10 +100,7 @@ namespace Slic3r {
|
|||
|
||||
void GCodeTimeEstimator::Block::calculate_trapezoid()
|
||||
{
|
||||
float distance = move_length();
|
||||
|
||||
trapezoid.distance = distance;
|
||||
trapezoid.feedrate = feedrate;
|
||||
trapezoid.cruise_feedrate = feedrate.cruise;
|
||||
|
||||
float accelerate_distance = std::max(0.0f, estimate_acceleration_distance(feedrate.entry, feedrate.cruise, acceleration));
|
||||
float decelerate_distance = std::max(0.0f, estimate_acceleration_distance(feedrate.cruise, feedrate.exit, -acceleration));
|
||||
|
|
@ -134,9 +111,9 @@ namespace Slic3r {
|
|||
// and start braking in order to reach the exit_feedrate exactly at the end of this block.
|
||||
if (cruise_distance < 0.0f)
|
||||
{
|
||||
accelerate_distance = clamp(0.0f, distance, intersection_distance(feedrate.entry, feedrate.exit, acceleration, distance));
|
||||
accelerate_distance = std::clamp(intersection_distance(feedrate.entry, feedrate.exit, acceleration, distance), 0.0f, distance);
|
||||
cruise_distance = 0.0f;
|
||||
trapezoid.feedrate.cruise = Trapezoid::speed_from_distance(feedrate.entry, accelerate_distance, acceleration);
|
||||
trapezoid.cruise_feedrate = Trapezoid::speed_from_distance(feedrate.entry, accelerate_distance, acceleration);
|
||||
}
|
||||
|
||||
trapezoid.accelerate_until = accelerate_distance;
|
||||
|
|
@ -207,11 +184,8 @@ namespace Slic3r {
|
|||
{
|
||||
PROFILE_FUNC();
|
||||
if (start_from_beginning)
|
||||
{
|
||||
_reset_time();
|
||||
m_last_st_synchronized_block_id = -1;
|
||||
}
|
||||
_calculate_time();
|
||||
_calculate_time(0);
|
||||
|
||||
if (m_needs_custom_gcode_times && (m_custom_gcode_time_cache != 0.0f))
|
||||
m_custom_gcode_times.push_back({ cgtColorChange, m_custom_gcode_time_cache });
|
||||
|
|
@ -221,6 +195,7 @@ namespace Slic3r {
|
|||
#endif // ENABLE_MOVE_STATS
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GCodeTimeEstimator::calculate_time_from_text(const std::string& gcode)
|
||||
{
|
||||
reset();
|
||||
|
|
@ -229,7 +204,7 @@ namespace Slic3r {
|
|||
[this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
|
||||
{ this->_process_gcode_line(reader, line); });
|
||||
|
||||
_calculate_time();
|
||||
_calculate_time(0);
|
||||
|
||||
if (m_needs_custom_gcode_times && (m_custom_gcode_time_cache != 0.0f))
|
||||
m_custom_gcode_times.push_back({ cgtColorChange, m_custom_gcode_time_cache });
|
||||
|
|
@ -244,7 +219,7 @@ namespace Slic3r {
|
|||
reset();
|
||||
|
||||
m_parser.parse_file(file, boost::bind(&GCodeTimeEstimator::_process_gcode_line, this, _1, _2));
|
||||
_calculate_time();
|
||||
_calculate_time(0);
|
||||
|
||||
if (m_needs_custom_gcode_times && (m_custom_gcode_time_cache != 0.0f))
|
||||
m_custom_gcode_times.push_back({ cgtColorChange, m_custom_gcode_time_cache });
|
||||
|
|
@ -262,7 +237,7 @@ namespace Slic3r {
|
|||
{ this->_process_gcode_line(reader, line); };
|
||||
for (const std::string& line : gcode_lines)
|
||||
m_parser.parse_line(line, action);
|
||||
_calculate_time();
|
||||
_calculate_time(0);
|
||||
|
||||
if (m_needs_custom_gcode_times && (m_custom_gcode_time_cache != 0.0f))
|
||||
m_custom_gcode_times.push_back({ cgtColorChange, m_custom_gcode_time_cache});
|
||||
|
|
@ -271,6 +246,7 @@ namespace Slic3r {
|
|||
_log_moves_stats();
|
||||
#endif // ENABLE_MOVE_STATS
|
||||
}
|
||||
#endif
|
||||
|
||||
bool GCodeTimeEstimator::post_process(const std::string& filename, float interval_sec, const PostProcessData* const normal_mode, const PostProcessData* const silent_mode)
|
||||
{
|
||||
|
|
@ -317,25 +293,25 @@ namespace Slic3r {
|
|||
if (data == nullptr)
|
||||
return;
|
||||
|
||||
assert((g1_line_id >= (int)data->g1_line_ids.size()) || (data->g1_line_ids[g1_line_id].first >= g1_lines_count));
|
||||
const Block* block = nullptr;
|
||||
if (g1_line_id < (int)data->g1_line_ids.size())
|
||||
assert((g1_line_id >= (int)data->g1_times.size()) || (data->g1_times[g1_line_id].first >= (int)g1_lines_count));
|
||||
float elapsed_time = -1.0f;
|
||||
if (g1_line_id < (int)data->g1_times.size())
|
||||
{
|
||||
const G1LineIdToBlockId& map_item = data->g1_line_ids[g1_line_id];
|
||||
const G1LineIdTime& map_item = data->g1_times[g1_line_id];
|
||||
if (map_item.first == g1_lines_count)
|
||||
{
|
||||
if (line.has_e() && (map_item.second < (unsigned int)data->blocks.size()))
|
||||
block = &data->blocks[map_item.second];
|
||||
if (line.has_e())
|
||||
elapsed_time = map_item.second;
|
||||
++g1_line_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ((block != nullptr) && (block->elapsed_time != -1.0f))
|
||||
if (elapsed_time != -1.0f)
|
||||
{
|
||||
float block_remaining_time = data->time - block->elapsed_time;
|
||||
float block_remaining_time = data->time - elapsed_time;
|
||||
if (std::abs(last_recorded_time - block_remaining_time) > interval_sec)
|
||||
{
|
||||
sprintf(line_M73, time_mask.c_str(), std::to_string((int)(100.0f * block->elapsed_time / data->time)).c_str(), _get_time_minutes(block_remaining_time).c_str());
|
||||
sprintf(line_M73, time_mask.c_str(), std::to_string((int)(100.0f * elapsed_time / data->time)).c_str(), _get_time_minutes(block_remaining_time).c_str());
|
||||
gcode_line += line_M73;
|
||||
|
||||
last_recorded_time = block_remaining_time;
|
||||
|
|
@ -643,22 +619,6 @@ namespace Slic3r {
|
|||
m_state.extruder_id = m_state.extruder_id_unloaded;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::add_additional_time(float timeSec)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
m_state.additional_time += timeSec;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_additional_time(float timeSec)
|
||||
{
|
||||
m_state.additional_time = timeSec;
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::get_additional_time() const
|
||||
{
|
||||
return m_state.additional_time;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_default()
|
||||
{
|
||||
set_units(Millimeters);
|
||||
|
|
@ -788,7 +748,7 @@ namespace Slic3r {
|
|||
{
|
||||
size_t out = sizeof(*this);
|
||||
out += SLIC3R_STDVEC_MEMSIZE(this->m_blocks, Block);
|
||||
out += SLIC3R_STDVEC_MEMSIZE(this->m_g1_line_ids, G1LineIdToBlockId);
|
||||
out += SLIC3R_STDVEC_MEMSIZE(this->m_g1_times, G1LineIdTime);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -807,13 +767,9 @@ namespace Slic3r {
|
|||
if (get_e_local_positioning_type() == Absolute)
|
||||
set_axis_position(E, 0.0f);
|
||||
|
||||
set_additional_time(0.0f);
|
||||
|
||||
reset_extruder_id();
|
||||
reset_g1_line_id();
|
||||
m_g1_line_ids.clear();
|
||||
|
||||
m_last_st_synchronized_block_id = -1;
|
||||
m_g1_times.clear();
|
||||
|
||||
m_needs_custom_gcode_times = false;
|
||||
m_custom_gcode_times.clear();
|
||||
|
|
@ -830,17 +786,19 @@ namespace Slic3r {
|
|||
m_blocks.clear();
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_calculate_time()
|
||||
void GCodeTimeEstimator::_calculate_time(size_t keep_last_n_blocks)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
|
||||
assert(keep_last_n_blocks <= m_blocks.size());
|
||||
|
||||
_forward_pass();
|
||||
_reverse_pass();
|
||||
_recalculate_trapezoids();
|
||||
|
||||
m_time += get_additional_time();
|
||||
m_custom_gcode_time_cache += get_additional_time();
|
||||
|
||||
for (int i = m_last_st_synchronized_block_id + 1; i < (int)m_blocks.size(); ++i)
|
||||
size_t n_blocks_process = m_blocks.size() - keep_last_n_blocks;
|
||||
m_g1_times.reserve(m_g1_times.size() + n_blocks_process);
|
||||
for (size_t i = 0; i < n_blocks_process; ++ i)
|
||||
{
|
||||
Block& block = m_blocks[i];
|
||||
float block_time = 0.0f;
|
||||
|
|
@ -848,7 +806,8 @@ namespace Slic3r {
|
|||
block_time += block.cruise_time();
|
||||
block_time += block.deceleration_time();
|
||||
m_time += block_time;
|
||||
block.elapsed_time = m_time;
|
||||
if (block.g1_line_id >= 0)
|
||||
m_g1_times.emplace_back(block.g1_line_id, m_time);
|
||||
|
||||
#if ENABLE_MOVE_STATS
|
||||
MovesStatsMap::iterator it = _moves_stats.find(block.move_type);
|
||||
|
|
@ -862,9 +821,10 @@ namespace Slic3r {
|
|||
m_custom_gcode_time_cache += block_time;
|
||||
}
|
||||
|
||||
m_last_st_synchronized_block_id = (int)m_blocks.size() - 1;
|
||||
// The additional time has been consumed (added to the total time), reset it to zero.
|
||||
set_additional_time(0.);
|
||||
if (keep_last_n_blocks)
|
||||
m_blocks.erase(m_blocks.begin(), m_blocks.begin() + n_blocks_process);
|
||||
else
|
||||
m_blocks.clear();
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
|
||||
|
|
@ -1021,6 +981,17 @@ namespace Slic3r {
|
|||
return current_absolute_position;
|
||||
};
|
||||
|
||||
// delta_pos must have size >= Num_Axis
|
||||
auto move_length = [](const float* delta_pos) {
|
||||
float xyz_length = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
||||
return (xyz_length > 0.0f) ? xyz_length : std::abs(delta_pos[E]);
|
||||
};
|
||||
|
||||
// delta_pos must have size >= Num_Axis
|
||||
auto is_extruder_only_move = [](const float* delta_pos) {
|
||||
return (delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f) && (delta_pos[E] != 0.0f);
|
||||
};
|
||||
|
||||
PROFILE_FUNC();
|
||||
increment_g1_line_id();
|
||||
|
||||
|
|
@ -1040,10 +1011,11 @@ namespace Slic3r {
|
|||
|
||||
// calculates block movement deltas
|
||||
float max_abs_delta = 0.0f;
|
||||
float delta_pos[Num_Axis];
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
block.delta_pos[a] = new_pos[a] - get_axis_position((EAxis)a);
|
||||
max_abs_delta = std::max(max_abs_delta, std::abs(block.delta_pos[a]));
|
||||
delta_pos[a] = new_pos[a] - get_axis_position((EAxis)a);
|
||||
max_abs_delta = std::max(max_abs_delta, std::abs(delta_pos[a]));
|
||||
}
|
||||
|
||||
// is it a move ?
|
||||
|
|
@ -1051,15 +1023,15 @@ namespace Slic3r {
|
|||
return;
|
||||
|
||||
// calculates block feedrate
|
||||
m_curr.feedrate = std::max(get_feedrate(), block.is_travel_move() ? get_minimum_travel_feedrate() : get_minimum_feedrate());
|
||||
m_curr.feedrate = std::max(get_feedrate(), (delta_pos[E] == 0.0f) ? get_minimum_travel_feedrate() : get_minimum_feedrate());
|
||||
|
||||
float distance = block.move_length();
|
||||
float invDistance = 1.0f / distance;
|
||||
block.distance = move_length(delta_pos);
|
||||
float invDistance = 1.0f / block.distance;
|
||||
|
||||
float min_feedrate_factor = 1.0f;
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
m_curr.axis_feedrate[a] = m_curr.feedrate * block.delta_pos[a] * invDistance;
|
||||
m_curr.axis_feedrate[a] = m_curr.feedrate * delta_pos[a] * invDistance;
|
||||
if (a == E)
|
||||
m_curr.axis_feedrate[a] *= get_extrude_factor_override_percentage();
|
||||
|
||||
|
|
@ -1080,12 +1052,12 @@ namespace Slic3r {
|
|||
}
|
||||
|
||||
// calculates block acceleration
|
||||
float acceleration = block.is_extruder_only_move() ? get_retract_acceleration() : get_acceleration();
|
||||
float acceleration = is_extruder_only_move(delta_pos) ? get_retract_acceleration() : get_acceleration();
|
||||
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
float axis_max_acceleration = get_axis_max_acceleration((EAxis)a);
|
||||
if (acceleration * std::abs(block.delta_pos[a]) * invDistance > axis_max_acceleration)
|
||||
if (acceleration * std::abs(delta_pos[a]) * invDistance > axis_max_acceleration)
|
||||
acceleration = axis_max_acceleration;
|
||||
}
|
||||
|
||||
|
|
@ -1165,7 +1137,7 @@ namespace Slic3r {
|
|||
vmax_junction = m_curr.safe_feedrate;
|
||||
}
|
||||
|
||||
float v_allowable = Block::max_allowable_speed(-acceleration, m_curr.safe_feedrate, distance);
|
||||
float v_allowable = Block::max_allowable_speed(-acceleration, m_curr.safe_feedrate, block.distance);
|
||||
block.feedrate.entry = std::min(vmax_junction, v_allowable);
|
||||
|
||||
block.max_entry_speed = vmax_junction;
|
||||
|
|
@ -1189,27 +1161,30 @@ namespace Slic3r {
|
|||
// detects block move type
|
||||
block.move_type = Block::Noop;
|
||||
|
||||
if (block.delta_pos[E] < 0.0f)
|
||||
if (delta_pos[E] < 0.0f)
|
||||
{
|
||||
if ((block.delta_pos[X] != 0.0f) || (block.delta_pos[Y] != 0.0f) || (block.delta_pos[Z] != 0.0f))
|
||||
if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
|
||||
block.move_type = Block::Move;
|
||||
else
|
||||
block.move_type = Block::Retract;
|
||||
}
|
||||
else if (block.delta_pos[E] > 0.0f)
|
||||
else if (delta_pos[E] > 0.0f)
|
||||
{
|
||||
if ((block.delta_pos[X] == 0.0f) && (block.delta_pos[Y] == 0.0f) && (block.delta_pos[Z] == 0.0f))
|
||||
if ((delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f))
|
||||
block.move_type = Block::Unretract;
|
||||
else if ((block.delta_pos[X] != 0.0f) || (block.delta_pos[Y] != 0.0f))
|
||||
else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f))
|
||||
block.move_type = Block::Extrude;
|
||||
}
|
||||
else if ((block.delta_pos[X] != 0.0f) || (block.delta_pos[Y] != 0.0f) || (block.delta_pos[Z] != 0.0f))
|
||||
else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
|
||||
block.move_type = Block::Move;
|
||||
#endif // ENABLE_MOVE_STATS
|
||||
|
||||
// adds block to blocks list
|
||||
block.g1_line_id = this->get_g1_line_id();
|
||||
m_blocks.emplace_back(block);
|
||||
m_g1_line_ids.emplace_back(G1LineIdToBlockIdMap::value_type(get_g1_line_id(), (unsigned int)m_blocks.size() - 1));
|
||||
|
||||
if (m_blocks.size() > planner_refresh_if_larger)
|
||||
_calculate_time(planner_queue_size);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processG4(const GCodeReader::GCodeLine& line)
|
||||
|
|
@ -1218,8 +1193,9 @@ namespace Slic3r {
|
|||
GCodeFlavor dialect = get_dialect();
|
||||
|
||||
float value;
|
||||
float extra_time = 0.f;
|
||||
if (line.has_value('P', value))
|
||||
add_additional_time(value * MILLISEC_TO_SEC);
|
||||
extra_time += value * MILLISEC_TO_SEC;
|
||||
|
||||
// see: http://reprap.org/wiki/G-code#G4:_Dwell
|
||||
if ((dialect == gcfRepetier) ||
|
||||
|
|
@ -1228,10 +1204,10 @@ namespace Slic3r {
|
|||
(dialect == gcfRepRap))
|
||||
{
|
||||
if (line.has_value('S', value))
|
||||
add_additional_time(value);
|
||||
extra_time += value;
|
||||
}
|
||||
|
||||
_simulate_st_synchronize();
|
||||
_simulate_st_synchronize(extra_time);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processG20(const GCodeReader::GCodeLine& line)
|
||||
|
|
@ -1296,7 +1272,7 @@ namespace Slic3r {
|
|||
anyFound = true;
|
||||
}
|
||||
else
|
||||
_simulate_st_synchronize();
|
||||
_simulate_st_synchronize(0.f);
|
||||
|
||||
if (!anyFound)
|
||||
{
|
||||
|
|
@ -1310,7 +1286,7 @@ namespace Slic3r {
|
|||
void GCodeTimeEstimator::_processM1(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
_simulate_st_synchronize();
|
||||
_simulate_st_synchronize(0.f);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processM82(const GCodeReader::GCodeLine& line)
|
||||
|
|
@ -1462,9 +1438,9 @@ namespace Slic3r {
|
|||
// MK3 MMU2 specific M code:
|
||||
// M702 C is expected to be sent by the custom end G-code when finalizing a print.
|
||||
// The MK3 unit shall unload and park the active filament into the MMU2 unit.
|
||||
add_additional_time(get_filament_unload_time(get_extruder_id()));
|
||||
float extra_time = get_filament_unload_time(get_extruder_id());
|
||||
reset_extruder_id();
|
||||
_simulate_st_synchronize();
|
||||
_simulate_st_synchronize(extra_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1478,10 +1454,10 @@ namespace Slic3r {
|
|||
{
|
||||
// Specific to the MK3 MMU2: The initial extruder ID is set to -1 indicating
|
||||
// that the filament is parked in the MMU2 unit and there is nothing to be unloaded yet.
|
||||
add_additional_time(get_filament_unload_time(get_extruder_id()));
|
||||
float extra_time = get_filament_unload_time(get_extruder_id());
|
||||
set_extruder_id(id);
|
||||
add_additional_time(get_filament_load_time(get_extruder_id()));
|
||||
_simulate_st_synchronize();
|
||||
extra_time += get_filament_load_time(get_extruder_id());
|
||||
_simulate_st_synchronize(extra_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1513,7 +1489,9 @@ namespace Slic3r {
|
|||
{
|
||||
PROFILE_FUNC();
|
||||
m_needs_custom_gcode_times = true;
|
||||
_calculate_time();
|
||||
//FIXME this simulates st_synchronize! is it correct?
|
||||
// The estimated time may be longer than the real print time.
|
||||
_simulate_st_synchronize(0.f);
|
||||
if (m_custom_gcode_time_cache != 0.0f)
|
||||
{
|
||||
m_custom_gcode_times.push_back({code, m_custom_gcode_time_cache});
|
||||
|
|
@ -1521,34 +1499,26 @@ namespace Slic3r {
|
|||
}
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_simulate_st_synchronize()
|
||||
void GCodeTimeEstimator::_simulate_st_synchronize(float extra_time)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
_calculate_time();
|
||||
m_time += extra_time;
|
||||
m_custom_gcode_time_cache += extra_time;
|
||||
_calculate_time(0);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_forward_pass()
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
if (m_blocks.size() > 1)
|
||||
{
|
||||
for (int i = m_last_st_synchronized_block_id + 1; i < (int)m_blocks.size() - 1; ++i)
|
||||
{
|
||||
_planner_forward_pass_kernel(m_blocks[i], m_blocks[i + 1]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i + 1 < (int)m_blocks.size(); ++i)
|
||||
_planner_forward_pass_kernel(m_blocks[i], m_blocks[i + 1]);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_reverse_pass()
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
if (m_blocks.size() > 1)
|
||||
{
|
||||
for (int i = (int)m_blocks.size() - 1; i >= m_last_st_synchronized_block_id + 2; --i)
|
||||
{
|
||||
_planner_reverse_pass_kernel(m_blocks[i - 1], m_blocks[i]);
|
||||
}
|
||||
}
|
||||
for (int i = (int)m_blocks.size() - 1; i > 0; -- i)
|
||||
_planner_reverse_pass_kernel(m_blocks[i - 1], m_blocks[i]);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_planner_forward_pass_kernel(Block& prev, Block& curr)
|
||||
|
|
@ -1562,7 +1532,7 @@ namespace Slic3r {
|
|||
{
|
||||
if (prev.feedrate.entry < curr.feedrate.entry)
|
||||
{
|
||||
float entry_speed = std::min(curr.feedrate.entry, Block::max_allowable_speed(-prev.acceleration, prev.feedrate.entry, prev.move_length()));
|
||||
float entry_speed = std::min(curr.feedrate.entry, Block::max_allowable_speed(-prev.acceleration, prev.feedrate.entry, prev.distance));
|
||||
|
||||
// Check for junction speed change
|
||||
if (curr.feedrate.entry != entry_speed)
|
||||
|
|
@ -1584,7 +1554,7 @@ namespace Slic3r {
|
|||
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
|
||||
// for max allowable speed if block is decelerating and nominal length is false.
|
||||
if (!curr.flags.nominal_length && (curr.max_entry_speed > next.feedrate.entry))
|
||||
curr.feedrate.entry = std::min(curr.max_entry_speed, Block::max_allowable_speed(-curr.acceleration, next.feedrate.entry, curr.move_length()));
|
||||
curr.feedrate.entry = std::min(curr.max_entry_speed, Block::max_allowable_speed(-curr.acceleration, next.feedrate.entry, curr.distance));
|
||||
else
|
||||
curr.feedrate.entry = curr.max_entry_speed;
|
||||
|
||||
|
|
@ -1598,7 +1568,7 @@ namespace Slic3r {
|
|||
Block* curr = nullptr;
|
||||
Block* next = nullptr;
|
||||
|
||||
for (int i = m_last_st_synchronized_block_id + 1; i < (int)m_blocks.size(); ++i)
|
||||
for (size_t i = 0; i < m_blocks.size(); ++ i)
|
||||
{
|
||||
Block& b = m_blocks[i];
|
||||
|
||||
|
|
@ -1657,7 +1627,7 @@ namespace Slic3r {
|
|||
{
|
||||
char buffer[64];
|
||||
|
||||
int minutes = std::round(time_in_secs / 60.);
|
||||
int minutes = int(std::round(time_in_secs / 60.));
|
||||
if (minutes <= 0) {
|
||||
::sprintf(buffer, "%ds", (int)time_in_secs);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ namespace Slic3r {
|
|||
// hard limit for the acceleration, to which the firmware will clamp.
|
||||
float max_acceleration; // mm/s^2
|
||||
float retract_acceleration; // mm/s^2
|
||||
float additional_time; // s
|
||||
float minimum_feedrate; // mm/s
|
||||
float minimum_travel_feedrate; // mm/s
|
||||
float extrude_factor_override_percentage;
|
||||
|
|
@ -125,14 +124,13 @@ namespace Slic3r {
|
|||
|
||||
struct Trapezoid
|
||||
{
|
||||
float distance; // mm
|
||||
float accelerate_until; // mm
|
||||
float decelerate_after; // mm
|
||||
FeedrateProfile feedrate;
|
||||
float cruise_feedrate; // mm/sec
|
||||
|
||||
float acceleration_time(float acceleration) const;
|
||||
float acceleration_time(float entry_feedrate, float acceleration) const;
|
||||
float cruise_time() const;
|
||||
float deceleration_time(float acceleration) const;
|
||||
float deceleration_time(float distance, float acceleration) const;
|
||||
float cruise_distance() const;
|
||||
|
||||
// This function gives the time needed to accelerate from an initial speed to reach a final distance.
|
||||
|
|
@ -153,25 +151,16 @@ namespace Slic3r {
|
|||
#endif // ENABLE_MOVE_STATS
|
||||
Flags flags;
|
||||
|
||||
float delta_pos[Num_Axis]; // mm
|
||||
float distance; // mm
|
||||
float acceleration; // mm/s^2
|
||||
float max_entry_speed; // mm/s
|
||||
float safe_feedrate; // mm/s
|
||||
|
||||
FeedrateProfile feedrate;
|
||||
Trapezoid trapezoid;
|
||||
float elapsed_time;
|
||||
|
||||
Block();
|
||||
|
||||
// Returns the length of the move covered by this block, in mm
|
||||
float move_length() const;
|
||||
|
||||
// Returns true if this block is a retract/unretract move only
|
||||
float is_extruder_only_move() const;
|
||||
|
||||
// Returns true if this block is a move with no extrusion
|
||||
float is_travel_move() const;
|
||||
// Ordnary index of this G1 line in the file.
|
||||
int g1_line_id { -1 };
|
||||
|
||||
// Returns the time spent accelerating toward cruise speed, in seconds
|
||||
float acceleration_time() const;
|
||||
|
|
@ -217,16 +206,13 @@ namespace Slic3r {
|
|||
#endif // ENABLE_MOVE_STATS
|
||||
|
||||
public:
|
||||
typedef std::pair<unsigned int, unsigned int> G1LineIdToBlockId;
|
||||
typedef std::vector<G1LineIdToBlockId> G1LineIdToBlockIdMap;
|
||||
typedef std::pair<int, float> G1LineIdTime;
|
||||
typedef std::vector<G1LineIdTime> G1LineIdsTimes;
|
||||
|
||||
struct PostProcessData
|
||||
{
|
||||
const G1LineIdToBlockIdMap& g1_line_ids;
|
||||
const BlocksList& blocks;
|
||||
const G1LineIdsTimes& g1_times;
|
||||
float time;
|
||||
|
||||
PostProcessData(const G1LineIdToBlockIdMap& g1_line_ids, const BlocksList& blocks, float time) : g1_line_ids(g1_line_ids), blocks(blocks), time(time) {}
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
@ -236,10 +222,14 @@ namespace Slic3r {
|
|||
Feedrates m_curr;
|
||||
Feedrates m_prev;
|
||||
BlocksList m_blocks;
|
||||
// Map between g1 line id and blocks id, used to speed up export of remaining times
|
||||
G1LineIdToBlockIdMap m_g1_line_ids;
|
||||
// Index of the last block already st_synchronized
|
||||
int m_last_st_synchronized_block_id;
|
||||
// Size of the firmware planner queue. The old 8-bit Marlins usually just managed 16 trapezoidal blocks.
|
||||
// Let's be conservative and plan for newer boards with more memory.
|
||||
static constexpr size_t planner_queue_size = 64;
|
||||
// The firmware recalculates last planner_queue_size trapezoidal blocks each time a new block is added.
|
||||
// We are not simulating the firmware exactly, we calculate a sequence of blocks once a reasonable number of blocks accumulate.
|
||||
static constexpr size_t planner_refresh_if_larger = planner_queue_size * 4;
|
||||
// Map from g1 line id to its elapsed time from the start of the print.
|
||||
G1LineIdsTimes m_g1_times;
|
||||
float m_time; // s
|
||||
|
||||
// data to calculate custom code times
|
||||
|
|
@ -267,13 +257,13 @@ namespace Slic3r {
|
|||
void calculate_time(bool start_from_beginning);
|
||||
|
||||
// Calculates the time estimate from the given gcode in string format
|
||||
void calculate_time_from_text(const std::string& gcode);
|
||||
//void calculate_time_from_text(const std::string& gcode);
|
||||
|
||||
// Calculates the time estimate from the gcode contained in the file with the given filename
|
||||
void calculate_time_from_file(const std::string& file);
|
||||
//void calculate_time_from_file(const std::string& file);
|
||||
|
||||
// Calculates the time estimate from the gcode contained in given list of gcode lines
|
||||
void calculate_time_from_lines(const std::vector<std::string>& gcode_lines);
|
||||
//void calculate_time_from_lines(const std::vector<std::string>& gcode_lines);
|
||||
|
||||
// Process the gcode contained in the file with the given filename,
|
||||
// replacing placeholders with correspondent new lines M73
|
||||
|
|
@ -350,10 +340,6 @@ namespace Slic3r {
|
|||
unsigned int get_extruder_id() const;
|
||||
void reset_extruder_id();
|
||||
|
||||
void add_additional_time(float timeSec);
|
||||
void set_additional_time(float timeSec);
|
||||
float get_additional_time() const;
|
||||
|
||||
void set_default();
|
||||
|
||||
// Call this method before to start adding lines using add_gcode_line() when reusing an instance of GCodeTimeEstimator
|
||||
|
|
@ -389,7 +375,7 @@ namespace Slic3r {
|
|||
// Return an estimate of the memory consumed by the time estimator.
|
||||
size_t memory_used() const;
|
||||
|
||||
PostProcessData get_post_process_data() const { return PostProcessData(m_g1_line_ids, m_blocks, m_time); }
|
||||
PostProcessData get_post_process_data() const { return PostProcessData{ m_g1_times, m_time }; }
|
||||
|
||||
private:
|
||||
void _reset();
|
||||
|
|
@ -397,7 +383,7 @@ namespace Slic3r {
|
|||
void _reset_blocks();
|
||||
|
||||
// Calculates the time estimate
|
||||
void _calculate_time();
|
||||
void _calculate_time(size_t keep_last_n_blocks);
|
||||
|
||||
// Processes the given gcode line
|
||||
void _process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line);
|
||||
|
|
@ -470,7 +456,7 @@ namespace Slic3r {
|
|||
void _process_custom_gcode_tag(CustomGcodeType code);
|
||||
|
||||
// Simulates firmware st_synchronize() call
|
||||
void _simulate_st_synchronize();
|
||||
void _simulate_st_synchronize(float additional_time);
|
||||
|
||||
void _forward_pass();
|
||||
void _reverse_pass();
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ bool Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb)
|
|||
if (input[i].bed_idx != 0) ret = false;
|
||||
if (input[i].bed_idx >= 0) {
|
||||
input[i].translation += Vec2crd{input[i].bed_idx * stride, 0};
|
||||
instances[i]->apply_arrange_result(input[i].translation,
|
||||
instances[i]->apply_arrange_result(input[i].translation.cast<double>(),
|
||||
input[i].rotation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@ public:
|
|||
arrangement::ArrangePolygon get_arrange_polygon() const;
|
||||
|
||||
// Apply the arrange result on the ModelInstance
|
||||
void apply_arrange_result(const Vec2crd& offs, double rotation)
|
||||
void apply_arrange_result(const Vec2d& offs, double rotation)
|
||||
{
|
||||
// write the transformation data into the model instance
|
||||
set_rotation(Z, rotation);
|
||||
|
|
|
|||
|
|
@ -44,19 +44,15 @@
|
|||
// Enable fix for dragging mouse event handling for gizmobar
|
||||
#define ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX (1 && ENABLE_2_2_0_FINAL)
|
||||
|
||||
//============
|
||||
// 2.3.0 techs
|
||||
//============
|
||||
#define ENABLE_2_3_0 1
|
||||
|
||||
// Enable rendering of objects colored by facets' slope
|
||||
#define ENABLE_SLOPE_RENDERING (1 && ENABLE_2_3_0)
|
||||
|
||||
//===================
|
||||
// 2.3.0.alpha1 techs
|
||||
//===================
|
||||
#define ENABLE_2_3_0_ALPHA1 1
|
||||
|
||||
// Enable rendering of objects colored by facets' slope
|
||||
#define ENABLE_SLOPE_RENDERING (1 && ENABLE_2_3_0_ALPHA1)
|
||||
|
||||
// Moves GLCanvas3DManager from being a static member of _3DScene to be a normal member of GUI_App
|
||||
#define ENABLE_NON_STATIC_CANVAS_MANAGER (1 && ENABLE_2_3_0_ALPHA1)
|
||||
|
||||
|
|
|
|||
57
src/libslic3r/format.hpp
Normal file
57
src/libslic3r/format.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef slic3r_format_hpp_
|
||||
#define slic3r_format_hpp_
|
||||
|
||||
// Functional wrapper around boost::format.
|
||||
// One day we may replace this wrapper with C++20 format
|
||||
// https://en.cppreference.com/w/cpp/utility/format/format
|
||||
// though C++20 format uses a different template pattern for position independent parameters.
|
||||
//
|
||||
// Boost::format works around the missing variadic templates by an ugly % chaining operator. The usage of boost::format looks like this:
|
||||
// (boost::format("template") % arg1 %arg2).str()
|
||||
// This wrapper allows for a nicer syntax:
|
||||
// Slic3r::format("template", arg1, arg2)
|
||||
// One can also override Slic3r::internal::format::cook() function to convert a Slic3r::format() argument to something that
|
||||
// boost::format may convert to string, see slic3r/GUI/I18N.hpp for a "cook" function to convert wxString to UTF8.
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// https://gist.github.com/gchudnov/6a90d51af004d97337ec
|
||||
namespace internal {
|
||||
namespace format {
|
||||
// Default "cook" function - just forward.
|
||||
template<typename T>
|
||||
inline T&& cook(T&& arg) {
|
||||
return std::forward<T>(arg);
|
||||
}
|
||||
|
||||
// End of the recursive chain.
|
||||
inline std::string format_recursive(boost::format& message) {
|
||||
return message.str();
|
||||
}
|
||||
|
||||
template<typename TValue, typename... TArgs>
|
||||
std::string format_recursive(boost::format& message, TValue&& arg, TArgs&&... args) {
|
||||
// Format, possibly convert the argument by the "cook" function.
|
||||
message % cook(std::forward<TValue>(arg));
|
||||
return format_recursive(message, std::forward<TArgs>(args)...);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... TArgs>
|
||||
inline std::string format(const char* fmt, TArgs&&... args) {
|
||||
boost::format message(fmt);
|
||||
return internal::format::format_recursive(message, std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
template<typename... TArgs>
|
||||
inline std::string format(const std::string& fmt, TArgs&&... args) {
|
||||
boost::format message(fmt);
|
||||
return internal::format::format_recursive(message, std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_format_hpp_
|
||||
|
|
@ -111,6 +111,7 @@
|
|||
#include "BoundingBox.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Config.hpp"
|
||||
#include "format.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "MultiPoint.hpp"
|
||||
#include "Point.hpp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue