Use GCodeWriter for path segments (refactoring)
This commit is contained in:
parent
fbd640fdc5
commit
9a17efc480
@ -114,57 +114,6 @@ ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCo
|
||||
REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
|
||||
#endif
|
||||
|
||||
std::string
|
||||
ExtrusionPath::gcode(Extruder* extruder, double e, double F,
|
||||
double xofs, double yofs, std::string extrusion_axis,
|
||||
std::string gcode_line_suffix) const
|
||||
{
|
||||
dSP;
|
||||
|
||||
std::stringstream stream;
|
||||
stream.setf(std::ios::fixed);
|
||||
|
||||
double local_F = F;
|
||||
|
||||
Lines lines = this->polyline.lines();
|
||||
for (Lines::const_iterator line_it = lines.begin();
|
||||
line_it != lines.end(); ++line_it)
|
||||
{
|
||||
const double line_length = line_it->length() * SCALING_FACTOR;
|
||||
|
||||
// calculate extrusion length for this line
|
||||
double E = 0;
|
||||
if (e > 0) {
|
||||
extruder->extrude(e * line_length);
|
||||
E = extruder->E;
|
||||
}
|
||||
|
||||
// compose G-code line
|
||||
|
||||
Point point = line_it->b;
|
||||
const double x = point.x * SCALING_FACTOR + xofs;
|
||||
const double y = point.y * SCALING_FACTOR + yofs;
|
||||
stream.precision(3);
|
||||
stream << "G1 X" << x << " Y" << y;
|
||||
|
||||
if (E != 0) {
|
||||
stream.precision(5);
|
||||
stream << " " << extrusion_axis << E;
|
||||
}
|
||||
|
||||
if (local_F != 0) {
|
||||
stream.precision(3);
|
||||
stream << " F" << local_F;
|
||||
local_F = 0;
|
||||
}
|
||||
|
||||
stream << gcode_line_suffix;
|
||||
stream << "\n";
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
Polygons
|
||||
ExtrusionPath::grow() const
|
||||
{
|
||||
|
@ -79,9 +79,6 @@ class ExtrusionPath : public ExtrusionEntity
|
||||
bool is_infill() const;
|
||||
bool is_solid_infill() const;
|
||||
bool is_bridge() const;
|
||||
std::string gcode(Extruder* extruder, double e, double F,
|
||||
double xofs, double yofs, std::string extrusion_axis,
|
||||
std::string gcode_line_suffix) const;
|
||||
Polygons grow() const;
|
||||
double min_mm3_per_mm() const {
|
||||
return this->mm3_per_mm;
|
||||
|
@ -357,22 +357,29 @@ GCode::_extrude_path(ExtrusionPath path, std::string description, double speed)
|
||||
// extrude arc or line
|
||||
if (path.is_bridge() && this->enable_cooling_markers)
|
||||
gcode += ";_BRIDGE_FAN_START\n";
|
||||
double path_length = unscale(path.length());
|
||||
gcode += this->writer.set_speed(F);
|
||||
double path_length = 0;
|
||||
{
|
||||
Pointf extruder_offset = EXTRUDER_CONFIG(extruder_offset);
|
||||
gcode += path.gcode(this->writer.extruder(), e_per_mm, F,
|
||||
this->origin.x - extruder_offset.x,
|
||||
this->origin.y - extruder_offset.y,
|
||||
this->writer.extrusion_axis(),
|
||||
this->config.gcode_comments ? (" ; " + description) : "");
|
||||
std::string comment = this->config.gcode_comments ? (" ; " + description) : "";
|
||||
Lines lines = path.polyline.lines();
|
||||
for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) {
|
||||
const double line_length = line->length() * SCALING_FACTOR;
|
||||
path_length += line_length;
|
||||
|
||||
gcode += this->writer.extrude_to_xy(
|
||||
this->point_to_gcode(line->b),
|
||||
e_per_mm * line_length,
|
||||
comment
|
||||
);
|
||||
}
|
||||
}
|
||||
if (this->wipe.enable) {
|
||||
this->wipe.path = path.polyline;
|
||||
this->wipe.path.reverse();
|
||||
}
|
||||
}
|
||||
if (path.is_bridge() && this->enable_cooling_markers)
|
||||
gcode += ";_BRIDGE_FAN_END\n";
|
||||
|
||||
this->set_last_pos(path.last_point());
|
||||
|
||||
if (this->config.cooling)
|
||||
|
@ -26,9 +26,6 @@
|
||||
bool is_infill();
|
||||
bool is_solid_infill();
|
||||
bool is_bridge();
|
||||
std::string gcode(Extruder* extruder, double e, double F,
|
||||
double xofs, double yofs, std::string extrusion_axis,
|
||||
std::string gcode_line_suffix);
|
||||
Polygons grow();
|
||||
%{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user