2014-05-10 13:08:49 +00:00
|
|
|
#ifndef slic3r_GCode_hpp_
|
|
|
|
#define slic3r_GCode_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2015-07-01 18:14:05 +00:00
|
|
|
#include "ExPolygon.hpp"
|
2015-07-01 19:47:17 +00:00
|
|
|
#include "GCodeWriter.hpp"
|
|
|
|
#include "Layer.hpp"
|
2015-07-01 18:14:05 +00:00
|
|
|
#include "MotionPlanner.hpp"
|
2015-07-01 19:47:17 +00:00
|
|
|
#include "Point.hpp"
|
|
|
|
#include "PlaceholderParser.hpp"
|
|
|
|
#include "Print.hpp"
|
|
|
|
#include "PrintConfig.hpp"
|
2014-05-10 13:08:49 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2016-09-12 14:25:15 +00:00
|
|
|
// Forward declarations.
|
2015-07-01 21:00:52 +00:00
|
|
|
class GCode;
|
2016-09-12 14:25:15 +00:00
|
|
|
namespace EdgeGrid { class Grid; }
|
2014-05-10 13:08:49 +00:00
|
|
|
|
2015-07-01 18:14:05 +00:00
|
|
|
class AvoidCrossingPerimeters {
|
2014-05-10 13:08:49 +00:00
|
|
|
public:
|
|
|
|
|
2015-07-01 18:14:05 +00:00
|
|
|
// this flag triggers the use of the external configuration space
|
|
|
|
bool use_external_mp;
|
|
|
|
bool use_external_mp_once; // just for the next travel move
|
|
|
|
|
|
|
|
// this flag disables avoid_crossing_perimeters just for the next travel move
|
|
|
|
// we enable it by default for the first travel move in print
|
|
|
|
bool disable_once;
|
|
|
|
|
|
|
|
AvoidCrossingPerimeters();
|
|
|
|
~AvoidCrossingPerimeters();
|
|
|
|
void init_external_mp(const ExPolygons &islands);
|
|
|
|
void init_layer_mp(const ExPolygons &islands);
|
2015-07-01 21:00:52 +00:00
|
|
|
Polyline travel_to(GCode &gcodegen, Point point);
|
2015-07-01 18:14:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
MotionPlanner* _external_mp;
|
|
|
|
MotionPlanner* _layer_mp;
|
2014-05-10 13:08:49 +00:00
|
|
|
};
|
|
|
|
|
2015-07-01 19:01:42 +00:00
|
|
|
class OozePrevention {
|
|
|
|
public:
|
|
|
|
bool enable;
|
|
|
|
Points standby_points;
|
|
|
|
|
|
|
|
OozePrevention();
|
2015-07-02 13:02:20 +00:00
|
|
|
std::string pre_toolchange(GCode &gcodegen);
|
|
|
|
std::string post_toolchange(GCode &gcodegen);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int _get_temp(GCode &gcodegen);
|
2015-07-01 19:01:42 +00:00
|
|
|
};
|
|
|
|
|
2015-07-01 18:57:16 +00:00
|
|
|
class Wipe {
|
|
|
|
public:
|
|
|
|
bool enable;
|
|
|
|
Polyline path;
|
|
|
|
|
|
|
|
Wipe();
|
|
|
|
bool has_path();
|
|
|
|
void reset_path();
|
2015-07-01 21:00:52 +00:00
|
|
|
std::string wipe(GCode &gcodegen, bool toolchange = false);
|
2015-07-01 18:57:16 +00:00
|
|
|
};
|
|
|
|
|
2015-07-01 19:47:17 +00:00
|
|
|
class GCode {
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* Origin of print coordinates expressed in unscaled G-code coordinates.
|
|
|
|
This affects the input arguments supplied to the extrude*() and travel_to()
|
|
|
|
methods. */
|
|
|
|
Pointf origin;
|
|
|
|
FullPrintConfig config;
|
|
|
|
GCodeWriter writer;
|
|
|
|
PlaceholderParser* placeholder_parser;
|
|
|
|
OozePrevention ooze_prevention;
|
|
|
|
Wipe wipe;
|
|
|
|
AvoidCrossingPerimeters avoid_crossing_perimeters;
|
|
|
|
bool enable_loop_clipping;
|
2016-09-13 11:30:00 +00:00
|
|
|
// If enabled, the G-code generator will put following comments at the ends
|
|
|
|
// of the G-code lines: _EXTRUDE_SET_SPEED, _WIPE, _BRIDGE_FAN_START, _BRIDGE_FAN_END
|
|
|
|
// Those comments are received and consumed (removed from the G-code) by the CoolingBuffer.pm Perl module.
|
2015-07-01 19:47:17 +00:00
|
|
|
bool enable_cooling_markers;
|
2016-09-12 14:25:15 +00:00
|
|
|
// Markers for the Pressure Equalizer to recognize the extrusion type.
|
|
|
|
// The Pressure Equalizer removes the markers from the final G-code.
|
|
|
|
bool enable_extrusion_role_markers;
|
2016-09-26 10:52:40 +00:00
|
|
|
// Extended markers for the G-code Analyzer.
|
|
|
|
// The G-code Analyzer will remove these comments from the final G-code.
|
|
|
|
bool enable_analyzer_markers;
|
|
|
|
// How many times will change_layer() be called?
|
|
|
|
// change_layer() will update the progress bar.
|
2015-07-01 19:47:17 +00:00
|
|
|
size_t layer_count;
|
2016-09-26 10:52:40 +00:00
|
|
|
// Progress bar indicator. Increments from -1 up to layer_count.
|
|
|
|
int layer_index;
|
|
|
|
// Current layer processed. Insequential printing mode, only a single copy will be printed.
|
|
|
|
// In non-sequential mode, all its copies will be printed.
|
2015-07-02 17:33:08 +00:00
|
|
|
const Layer* layer;
|
2015-07-02 18:24:16 +00:00
|
|
|
std::map<const PrintObject*,Point> _seam_position;
|
2016-09-12 14:25:15 +00:00
|
|
|
// Distance Field structure to
|
|
|
|
EdgeGrid::Grid *_lower_layer_edge_grid;
|
2015-07-01 19:47:17 +00:00
|
|
|
bool first_layer; // this flag triggers first layer speeds
|
2016-09-13 11:30:00 +00:00
|
|
|
// Used by the CoolingBuffer.pm Perl module to calculate time spent per layer change.
|
|
|
|
// This value is not quite precise. First it only accouts for extrusion moves and travel moves,
|
|
|
|
// it does not account for wipe, retract / unretract moves.
|
|
|
|
// second it does not account for the velocity profiles of the printer.
|
2016-04-12 17:10:58 +00:00
|
|
|
float elapsed_time; // seconds
|
2015-07-01 19:47:17 +00:00
|
|
|
double volumetric_speed;
|
2016-09-12 14:25:15 +00:00
|
|
|
// Support for the extrusion role markers. Which marker is active?
|
|
|
|
ExtrusionRole _last_extrusion_role;
|
2015-07-01 19:47:17 +00:00
|
|
|
|
|
|
|
GCode();
|
2016-09-12 14:25:15 +00:00
|
|
|
~GCode();
|
2015-12-19 13:49:29 +00:00
|
|
|
const Point& last_pos() const;
|
2015-07-01 21:00:52 +00:00
|
|
|
void set_last_pos(const Point &pos);
|
|
|
|
bool last_pos_defined() const;
|
|
|
|
void apply_print_config(const PrintConfig &print_config);
|
2015-07-02 17:33:08 +00:00
|
|
|
void set_extruders(const std::vector<unsigned int> &extruder_ids);
|
2015-07-01 21:00:52 +00:00
|
|
|
void set_origin(const Pointf &pointf);
|
|
|
|
std::string preamble();
|
2015-07-02 17:33:08 +00:00
|
|
|
std::string change_layer(const Layer &layer);
|
2015-07-02 18:24:16 +00:00
|
|
|
std::string extrude(const ExtrusionEntity &entity, std::string description = "", double speed = -1);
|
|
|
|
std::string extrude(ExtrusionLoop loop, std::string description = "", double speed = -1);
|
|
|
|
std::string extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
|
2015-07-02 13:12:04 +00:00
|
|
|
std::string travel_to(const Point &point, ExtrusionRole role, std::string comment);
|
2015-07-02 12:29:20 +00:00
|
|
|
bool needs_retraction(const Polyline &travel, ExtrusionRole role = erNone);
|
2015-07-01 21:00:52 +00:00
|
|
|
std::string retract(bool toolchange = false);
|
|
|
|
std::string unretract();
|
2015-07-02 13:02:20 +00:00
|
|
|
std::string set_extruder(unsigned int extruder_id);
|
2015-07-01 21:00:52 +00:00
|
|
|
Pointf point_to_gcode(const Point &point);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Point _last_pos;
|
|
|
|
bool _last_pos_defined;
|
2015-07-02 18:24:16 +00:00
|
|
|
std::string _extrude(ExtrusionPath path, std::string description = "", double speed = -1);
|
2015-07-01 19:47:17 +00:00
|
|
|
};
|
|
|
|
|
2014-05-10 13:08:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|