Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-05-03 19:28:22 +0300
committerbubnikv <bubnikv@gmail.com>2017-05-03 19:28:22 +0300
commite90279c513a1fb1fb50bf78d7e58a74e4889d7af (patch)
tree8aa1de52f2571bc93d47524b852ff65abd7005e9 /xs/src/libslic3r/GCodeWriter.hpp
parent72ae3585e415189286cdb85f6e02e4ec150084ee (diff)
Ported the G-code generator from Perl to C++.
Removed GCode.pm Removed the Perl bindigns for AvoidCrossingPerimeters, OozePrevention, SpiralVase, Wipe Changed the std::set of extruder IDs to vector of IDs. Removed some MSVC compiler warnings, removed obnoxious compiler warnings when compiling the Perl bindings.
Diffstat (limited to 'xs/src/libslic3r/GCodeWriter.hpp')
-rw-r--r--xs/src/libslic3r/GCodeWriter.hpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/xs/src/libslic3r/GCodeWriter.hpp b/xs/src/libslic3r/GCodeWriter.hpp
index cd1eab008..c3c90397a 100644
--- a/xs/src/libslic3r/GCodeWriter.hpp
+++ b/xs/src/libslic3r/GCodeWriter.hpp
@@ -12,17 +12,25 @@ namespace Slic3r {
class GCodeWriter {
public:
GCodeConfig config;
- std::map<unsigned int,Extruder> extruders;
+ std::set<Extruder> extruders;
bool multiple_extruders;
- GCodeWriter()
- : multiple_extruders(false), _extrusion_axis("E"), _extruder(NULL),
- _last_acceleration(0), _last_fan_speed(0), _lifted(0)
- {};
- Extruder* extruder() const { return this->_extruder; }
+ GCodeWriter() :
+ multiple_extruders(false), _extrusion_axis("E"), _extruder(nullptr),
+ _last_acceleration(0), _last_fan_speed(0), _lifted(0)
+ {}
+ Extruder* extruder() { return this->_extruder; }
+ const Extruder* extruder() const { return this->_extruder; }
std::string extrusion_axis() const { return this->_extrusion_axis; }
- void apply_print_config(const PrintConfig &print_config);
- void set_extruders(const std::vector<unsigned int> &extruder_ids);
+ void apply_print_config(const PrintConfig &print_config);
+ void set_extruders(const std::vector<unsigned int> &extruder_ids);
+ std::vector<unsigned int> extruder_ids() const {
+ std::vector<unsigned int> out;
+ out.reserve(extruders.size());
+ for (const auto e : extruders)
+ out.push_back(e.id);
+ return out;
+ }
std::string preamble();
std::string postamble() const;
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const;
@@ -31,14 +39,17 @@ public:
std::string set_acceleration(unsigned int acceleration);
std::string reset_e(bool force = false);
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
- bool need_toolchange(unsigned int extruder_id) const;
- std::string set_extruder(unsigned int extruder_id);
+ // return false if this extruder was already selected
+ bool need_toolchange(unsigned int extruder_id) const
+ { return (this->_extruder == nullptr) || (this->_extruder->id != extruder_id); }
+ std::string set_extruder(unsigned int extruder_id)
+ { return this->need_toolchange(extruder_id) ? this->toolchange(extruder_id) : ""; }
std::string toolchange(unsigned int extruder_id);
std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string()) const;
std::string travel_to_xy(const Pointf &point, const std::string &comment = std::string());
std::string travel_to_xyz(const Pointf3 &point, const std::string &comment = std::string());
std::string travel_to_z(double z, const std::string &comment = std::string());
- bool will_move_z(double z) const;
+ bool will_move_z(double z) const;
std::string extrude_to_xy(const Pointf &point, double dE, const std::string &comment = std::string());
std::string extrude_to_xyz(const Pointf3 &point, double dE, const std::string &comment = std::string());
std::string retract();
@@ -46,14 +57,15 @@ public:
std::string unretract();
std::string lift();
std::string unlift();
- Pointf3 get_position() const { return this->_pos; }
+ Pointf3 get_position() const { return this->_pos; }
+
private:
- std::string _extrusion_axis;
- Extruder* _extruder;
- unsigned int _last_acceleration;
- unsigned int _last_fan_speed;
- double _lifted;
- Pointf3 _pos;
+ std::string _extrusion_axis;
+ Extruder* _extruder;
+ unsigned int _last_acceleration;
+ unsigned int _last_fan_speed;
+ double _lifted;
+ Pointf3 _pos;
std::string _travel_to_z(double z, const std::string &comment);
std::string _retract(double length, double restart_extra, const std::string &comment);