mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
Fix contour extrusion path logic and improve GCode extrusion handling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<double>(this->height()) / 2;
|
||||
|
||||
double z = this->m_model_object->min_z();
|
||||
trans.set_offset(Vec3d(-unscale<double>(center_offset.x()), -unscale<double>(center_offset.y()), 0));
|
||||
mesh.transform(trans.get_matrix());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user