PrusaSlicer-NonPlainar/xs/src/libslic3r/GCode.hpp

141 lines
4.9 KiB
C++
Raw Normal View History

#ifndef slic3r_GCode_hpp_
#define slic3r_GCode_hpp_
#include "libslic3r.h"
#include "ExPolygon.hpp"
2015-07-01 19:47:17 +00:00
#include "GCodeWriter.hpp"
#include "Layer.hpp"
#include "MotionPlanner.hpp"
2015-07-01 19:47:17 +00:00
#include "Point.hpp"
#include "PlaceholderParser.hpp"
#include "Print.hpp"
#include "PrintConfig.hpp"
#include <string>
namespace Slic3r {
// Forward declarations.
class GCode;
namespace EdgeGrid { class Grid; }
class AvoidCrossingPerimeters {
public:
// 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);
Polyline travel_to(GCode &gcodegen, Point point);
private:
MotionPlanner* _external_mp;
MotionPlanner* _layer_mp;
};
class OozePrevention {
public:
bool enable;
Points standby_points;
OozePrevention();
std::string pre_toolchange(GCode &gcodegen);
std::string post_toolchange(GCode &gcodegen);
private:
int _get_temp(GCode &gcodegen);
};
class Wipe {
public:
bool enable;
Polyline path;
Wipe();
bool has_path();
void reset_path();
std::string wipe(GCode &gcodegen, bool toolchange = false);
};
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;
// 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;
// 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;
// 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;
// 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.
const Layer* layer;
std::map<const PrintObject*,Point> _seam_position;
// 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
// 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.
float elapsed_time; // seconds
2015-07-01 19:47:17 +00:00
double volumetric_speed;
// Support for the extrusion role markers. Which marker is active?
ExtrusionRole _last_extrusion_role;
2015-07-01 19:47:17 +00:00
GCode();
~GCode();
const Point& last_pos() const;
void set_last_pos(const Point &pos);
bool last_pos_defined() const;
void apply_print_config(const PrintConfig &print_config);
void set_extruders(const std::vector<unsigned int> &extruder_ids);
void set_origin(const Pointf &pointf);
std::string preamble();
std::string change_layer(const Layer &layer);
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);
std::string retract(bool toolchange = false);
std::string unretract();
std::string set_extruder(unsigned int extruder_id);
Pointf point_to_gcode(const Point &point);
private:
Point _last_pos;
bool _last_pos_defined;
std::string _extrude(ExtrusionPath path, std::string description = "", double speed = -1);
2015-07-01 19:47:17 +00:00
};
}
#endif