diff --git a/src/libslic3r/ContourZ.cpp b/src/libslic3r/ContourZ.cpp index 8eb1a8b5a8..48a3da13c3 100644 --- a/src/libslic3r/ContourZ.cpp +++ b/src/libslic3r/ContourZ.cpp @@ -63,10 +63,14 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh & int num_segments = int(std::ceil(length_mm / resolution_mm)); Vec2d delta = line.vector(); - for (int i = 0; i < num_segments+1; i++) { - Vec2d p = p1d + delta*i/num_segments; + if (num_segments == 0) { + continue; + } - coordf_t x = p.x(); + for (int i = 0; i < num_segments + 1; i++) { + Vec2d p = p1d + delta * i / num_segments; + + coordf_t x = p.x(); coordf_t y = p.y(); sla::IndexedMesh::hit_result hit_up = mesh.query_ray_hit({x, y, mesh_z}, {0.0, 0.0, 1.0}); @@ -116,24 +120,22 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh & was_contoured = true; } - Vec3d new_point = {p.x(), p.y(), d}; + Vec3d new_point = {p.x(), p.y(), d}; - if (contoured_points.size() > 2) { - double dist = Linef3::distance_to_infinite_squared( - contoured_points[contoured_points.size() - 2], - contoured_points[contoured_points.size() - 1], - new_point); - if (dist < EPSILON) { - contoured_points[contoured_points.size() - 1] = new_point; - continue; - } - } + if (contoured_points.size() >= 2) { + double dist = Linef3::distance_to_infinite_squared(new_point, contoured_points[contoured_points.size() - 2], + contoured_points[contoured_points.size() - 1]); + if (dist < EPSILON * EPSILON) { + contoured_points[contoured_points.size() - 1] = new_point; + continue; + } + } - contoured_points.push_back(new_point); - } - } + contoured_points.push_back(new_point); + } + } - if (!was_contoured) { + if (!was_contoured) { return false; } diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 3693ffa872..39ac5b4d83 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -6760,10 +6760,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (z < 0.1) { throw RuntimeError("GCode: very low z"); } - gcode += m_writer.extrude_to_xyz( - Vec3d(dest2d.x(), dest2d.y(), z), - e, - tempDescription + "; z_diff " + std::to_string(z_diff) + " " + ExtrusionEntity::role_to_string(path.role()) + "; eratio " + std::to_string(extrusion_ratio)); + gcode += m_writer.extrude_to_xyz(Vec3d(dest2d.x(), dest2d.y(), z), e, + GCodeWriter::full_gcode_comment ? tempDescription : ""); } else if (sloped == nullptr) { // Normal extrusion diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 5dd342eaf9..e4d47c065e 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -732,7 +732,8 @@ void PrintObject::contour_z() ModelInstance *inst = m_model_object->instances.front(); Point center_offset = this->center_offset(); Geometry::Transformation trans = inst->get_transformation(); - double z = trans.get_offset().z() - unscale(this->height()) / 2; + + double z = this->m_model_object->min_z(); trans.set_offset(Vec3d(-unscale(center_offset.x()), -unscale(center_offset.y()), 0)); mesh.transform(trans.get_matrix());