mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 07:38:58 +08:00
#11337: Fixed detection of toolpaths in first layer when using z offset (SPE-1902)
This commit is contained in:
parent
a8155eb8db
commit
fc5a4c1e13
@ -2638,9 +2638,16 @@ void GCodeProcessor::process_G1(const std::array<std::optional<double>, 4>& axes
|
|||||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
|
|
||||||
if (m_forced_height > 0.0f)
|
if (m_forced_height > 0.0f)
|
||||||
|
// use height coming from the gcode tags
|
||||||
m_height = m_forced_height;
|
m_height = m_forced_height;
|
||||||
else if (m_layer_id == 0)
|
else if (m_layer_id == 0) { // first layer
|
||||||
|
if (m_end_position[Z] > 0.0f)
|
||||||
|
// use the current (clamped) z, if greater than zero
|
||||||
|
m_height = std::min<float>(m_end_position[Z], 2.0f);
|
||||||
|
else
|
||||||
|
// use the first layer height
|
||||||
m_height = m_first_layer_height + m_z_offset;
|
m_height = m_first_layer_height + m_z_offset;
|
||||||
|
}
|
||||||
else if (origin == G1DiscretizationOrigin::G1) {
|
else if (origin == G1DiscretizationOrigin::G1) {
|
||||||
if (m_end_position[Z] > m_extruded_last_z + EPSILON && delta_pos[Z] == 0.0)
|
if (m_end_position[Z] > m_extruded_last_z + EPSILON && delta_pos[Z] == 0.0)
|
||||||
m_height = m_end_position[Z] - m_extruded_last_z;
|
m_height = m_end_position[Z] - m_extruded_last_z;
|
||||||
@ -2649,9 +2656,6 @@ void GCodeProcessor::process_G1(const std::array<std::optional<double>, 4>& axes
|
|||||||
if (m_height == 0.0f)
|
if (m_height == 0.0f)
|
||||||
m_height = DEFAULT_TOOLPATH_HEIGHT;
|
m_height = DEFAULT_TOOLPATH_HEIGHT;
|
||||||
|
|
||||||
if (m_end_position[Z] == 0.0f || (m_extrusion_role == GCodeExtrusionRole::Custom && m_layer_id == 0))
|
|
||||||
m_end_position[Z] = m_height;
|
|
||||||
|
|
||||||
if (origin == G1DiscretizationOrigin::G1)
|
if (origin == G1DiscretizationOrigin::G1)
|
||||||
m_extruded_last_z = m_end_position[Z];
|
m_extruded_last_z = m_end_position[Z];
|
||||||
m_options_z_corrector.update(m_height);
|
m_options_z_corrector.update(m_height);
|
||||||
@ -2661,6 +2665,7 @@ void GCodeProcessor::process_G1(const std::array<std::optional<double>, 4>& axes
|
|||||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||||
|
|
||||||
if (m_forced_width > 0.0f)
|
if (m_forced_width > 0.0f)
|
||||||
|
// use width coming from the gcode tags
|
||||||
m_width = m_forced_width;
|
m_width = m_forced_width;
|
||||||
else if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
else if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||||
// cross section: rectangle
|
// cross section: rectangle
|
||||||
|
@ -2264,15 +2264,15 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||||||
// layers zs/ranges
|
// layers zs/ranges
|
||||||
const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back();
|
const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back();
|
||||||
const double z = static_cast<double>(move.position.z());
|
const double z = static_cast<double>(move.position.z());
|
||||||
if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) {
|
if (move.extrusion_role != GCodeExtrusionRole::Custom &&
|
||||||
|
(last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z)) {
|
||||||
// start a new layer
|
// start a new layer
|
||||||
const size_t start_it = (m_layers.empty() && first_travel_s_id != 0) ? first_travel_s_id : last_travel_s_id;
|
const size_t start_it = (m_layers.empty() && first_travel_s_id != 0) ? first_travel_s_id : last_travel_s_id;
|
||||||
m_layers.append(z, { start_it, move_id });
|
m_layers.append(z, { start_it, move_id });
|
||||||
}
|
}
|
||||||
else if (!move.internal_only) {
|
else if (!m_layers.empty() && !move.internal_only)
|
||||||
// update last layer
|
// update last layer
|
||||||
m_layers.get_ranges().back().last = move_id;
|
m_layers.get_ranges().back().last = move_id;
|
||||||
}
|
|
||||||
|
|
||||||
// extruder ids
|
// extruder ids
|
||||||
m_extruder_ids.emplace_back(move.extruder_id);
|
m_extruder_ids.emplace_back(move.extruder_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user