mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
Fix contour extrusion path logic and improve GCode extrusion handling
This commit is contained in:
@@ -63,6 +63,10 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh &
|
|||||||
int num_segments = int(std::ceil(length_mm / resolution_mm));
|
int num_segments = int(std::ceil(length_mm / resolution_mm));
|
||||||
Vec2d delta = line.vector();
|
Vec2d delta = line.vector();
|
||||||
|
|
||||||
|
if (num_segments == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < num_segments + 1; i++) {
|
for (int i = 0; i < num_segments + 1; i++) {
|
||||||
Vec2d p = p1d + delta * i / num_segments;
|
Vec2d p = p1d + delta * i / num_segments;
|
||||||
|
|
||||||
@@ -118,12 +122,10 @@ static bool contour_extrusion_path(LayerRegion *region, const sla::IndexedMesh &
|
|||||||
|
|
||||||
Vec3d new_point = {p.x(), p.y(), d};
|
Vec3d new_point = {p.x(), p.y(), d};
|
||||||
|
|
||||||
if (contoured_points.size() > 2) {
|
if (contoured_points.size() >= 2) {
|
||||||
double dist = Linef3::distance_to_infinite_squared(
|
double dist = Linef3::distance_to_infinite_squared(new_point, contoured_points[contoured_points.size() - 2],
|
||||||
contoured_points[contoured_points.size() - 2],
|
contoured_points[contoured_points.size() - 1]);
|
||||||
contoured_points[contoured_points.size() - 1],
|
if (dist < EPSILON * EPSILON) {
|
||||||
new_point);
|
|
||||||
if (dist < EPSILON) {
|
|
||||||
contoured_points[contoured_points.size() - 1] = new_point;
|
contoured_points[contoured_points.size() - 1] = new_point;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6760,10 +6760,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||||||
if (z < 0.1) {
|
if (z < 0.1) {
|
||||||
throw RuntimeError("GCode: very low z");
|
throw RuntimeError("GCode: very low z");
|
||||||
}
|
}
|
||||||
gcode += m_writer.extrude_to_xyz(
|
gcode += m_writer.extrude_to_xyz(Vec3d(dest2d.x(), dest2d.y(), z), e,
|
||||||
Vec3d(dest2d.x(), dest2d.y(), z),
|
GCodeWriter::full_gcode_comment ? tempDescription : "");
|
||||||
e,
|
|
||||||
tempDescription + "; z_diff " + std::to_string(z_diff) + " " + ExtrusionEntity::role_to_string(path.role()) + "; eratio " + std::to_string(extrusion_ratio));
|
|
||||||
|
|
||||||
} else if (sloped == nullptr) {
|
} else if (sloped == nullptr) {
|
||||||
// Normal extrusion
|
// Normal extrusion
|
||||||
|
|||||||
@@ -732,7 +732,8 @@ void PrintObject::contour_z()
|
|||||||
ModelInstance *inst = m_model_object->instances.front();
|
ModelInstance *inst = m_model_object->instances.front();
|
||||||
Point center_offset = this->center_offset();
|
Point center_offset = this->center_offset();
|
||||||
Geometry::Transformation trans = inst->get_transformation();
|
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));
|
trans.set_offset(Vec3d(-unscale<double>(center_offset.x()), -unscale<double>(center_offset.y()), 0));
|
||||||
mesh.transform(trans.get_matrix());
|
mesh.transform(trans.get_matrix());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user