Merge remote-tracking branch 'origin/et_lower_ram_footprint'
This commit is contained in:
commit
87ba9f251b
5 changed files with 78 additions and 103 deletions
|
@ -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)
|
||||
|
@ -691,7 +691,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)
|
||||
|
@ -784,12 +784,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;
|
||||
}
|
||||
|
@ -864,12 +864,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;
|
||||
}
|
||||
|
@ -900,9 +900,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)
|
||||
|
@ -913,14 +913,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());
|
||||
}
|
||||
|
||||
|
@ -958,8 +958,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;
|
||||
|
@ -976,7 +976,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;
|
||||
|
@ -996,7 +996,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();
|
||||
|
@ -1012,7 +1012,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);
|
||||
|
@ -1060,7 +1060,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;
|
||||
|
|
|
@ -24,7 +24,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;
|
||||
|
||||
|
@ -53,7 +53,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
|
||||
|
@ -61,7 +61,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;
|
||||
};
|
||||
|
@ -81,12 +81,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;
|
||||
|
@ -101,7 +101,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];
|
||||
|
@ -246,8 +246,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;
|
||||
|
@ -272,8 +272,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;
|
||||
|
@ -285,7 +285,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;
|
||||
|
@ -1004,11 +981,20 @@ namespace Slic3r {
|
|||
return current_absolute_position;
|
||||
};
|
||||
|
||||
auto move_length = [](const std::array<float, Num_Axis>& 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]);
|
||||
};
|
||||
|
||||
auto is_extruder_only_move = [](const std::array<float, Num_Axis>& 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();
|
||||
|
||||
// updates axes positions from line
|
||||
float new_pos[Num_Axis];
|
||||
std::array<float, Num_Axis> new_pos;
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
new_pos[a] = axis_absolute_position((EAxis)a, line);
|
||||
|
@ -1023,10 +1009,11 @@ namespace Slic3r {
|
|||
|
||||
// calculates block movement deltas
|
||||
float max_abs_delta = 0.0f;
|
||||
std::array<float, Num_Axis> delta_pos;
|
||||
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 ?
|
||||
|
@ -1034,15 +1021,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();
|
||||
|
||||
|
@ -1063,12 +1050,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;
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1135,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;
|
||||
|
@ -1172,21 +1159,21 @@ 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
|
||||
|
||||
|
@ -1543,7 +1530,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)
|
||||
|
@ -1565,7 +1552,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;
|
||||
|
||||
|
|
|
@ -124,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.
|
||||
|
@ -152,7 +151,7 @@ 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
|
||||
|
@ -163,17 +162,6 @@ namespace Slic3r {
|
|||
// Ordnary index of this G1 line in the file.
|
||||
int g1_line_id { -1 };
|
||||
|
||||
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;
|
||||
|
||||
// Returns the time spent accelerating toward cruise speed, in seconds
|
||||
float acceleration_time() const;
|
||||
|
||||
|
|
|
@ -6508,7 +6508,7 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
|
|||
case GCodePreviewData::Extrusion::FanSpeed:
|
||||
return path.fan_speed;
|
||||
case GCodePreviewData::Extrusion::VolumetricRate:
|
||||
return path.feedrate * (float)path.mm3_per_mm;
|
||||
return path.feedrate * path.mm3_per_mm;
|
||||
case GCodePreviewData::Extrusion::Tool:
|
||||
return (float)path.extruder_id;
|
||||
case GCodePreviewData::Extrusion::ColorPrint:
|
||||
|
|
Loading…
Reference in a new issue