Make C++ gcode generator use C++ Extruder object directly.

This commit is contained in:
Y. Sapir 2014-04-08 02:43:02 +03:00
parent 66d23a2416
commit 04fad70cbf
3 changed files with 6 additions and 16 deletions

View file

@ -2,6 +2,7 @@
#include "ExtrusionEntityCollection.hpp" #include "ExtrusionEntityCollection.hpp"
#include "ExPolygonCollection.hpp" #include "ExPolygonCollection.hpp"
#include "ClipperUtils.hpp" #include "ClipperUtils.hpp"
#include "Extruder.hpp"
#include <sstream> #include <sstream>
#ifdef SLIC3RXS #ifdef SLIC3RXS
#include "perlglue.hpp" #include "perlglue.hpp"
@ -109,7 +110,7 @@ ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCo
REGISTER_CLASS(ExtrusionPath, "ExtrusionPath"); REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
std::string std::string
ExtrusionPath::gcode(SV* extruder, double e, double F, ExtrusionPath::gcode(Extruder* extruder, double e, double F,
double xofs, double yofs, std::string extrusion_axis, double xofs, double yofs, std::string extrusion_axis,
std::string gcode_line_suffix) const std::string gcode_line_suffix) const
{ {
@ -127,19 +128,7 @@ ExtrusionPath::gcode(SV* extruder, double e, double F,
const double line_length = line_it->length() * SCALING_FACTOR; const double line_length = line_it->length() * SCALING_FACTOR;
// calculate extrusion length for this line // calculate extrusion length for this line
double E = 0; double E = (e == 0) ? 0 : extruder->extrude(e * line_length);
if (e != 0) {
PUSHMARK(SP);
XPUSHs(extruder);
XPUSHs(sv_2mortal(newSVnv(e * line_length)));
PUTBACK;
const int count = call_method("extrude", G_SCALAR);
SPAGAIN;
// TODO: check that count is 1
E = POPn;
}
// compose G-code line // compose G-code line

View file

@ -9,6 +9,7 @@ namespace Slic3r {
class ExPolygonCollection; class ExPolygonCollection;
class ExtrusionEntityCollection; class ExtrusionEntityCollection;
class Extruder;
enum ExtrusionRole { enum ExtrusionRole {
erPerimeter, erPerimeter,
@ -57,7 +58,7 @@ class ExtrusionPath : public ExtrusionEntity
double length() const; double length() const;
#ifdef SLIC3RXS #ifdef SLIC3RXS
std::string gcode(SV* extruder, double e, double F, std::string gcode(Extruder* extruder, double e, double F,
double xofs, double yofs, std::string extrusion_axis, double xofs, double yofs, std::string extrusion_axis,
std::string gcode_line_suffix) const; std::string gcode_line_suffix) const;
#endif #endif

View file

@ -25,7 +25,7 @@
bool is_perimeter(); bool is_perimeter();
bool is_fill(); bool is_fill();
bool is_bridge(); bool is_bridge();
std::string gcode(SV* extruder, double e, double F, std::string gcode(Extruder* extruder, double e, double F,
double xofs, double yofs, std::string extrusion_axis, double xofs, double yofs, std::string extrusion_axis,
std::string gcode_line_suffix); std::string gcode_line_suffix);
%{ %{