Ported GCodeWriter to XS (faster G-code export!)

This commit is contained in:
Alessandro Ranellucci 2014-11-09 19:02:45 +01:00
parent b69caff93c
commit ee3fb7caa2
10 changed files with 646 additions and 433 deletions

63
xs/xsp/GCodeWriter.xsp Normal file
View file

@ -0,0 +1,63 @@
%module{Slic3r::XS};
%{
#include <myinit.h>
#include "libslic3r/GCodeWriter.hpp"
%}
%name{Slic3r::GCode::Writer} class GCodeWriter {
GCodeWriter();
~GCodeWriter();
Ref<GCodeConfig> config()
%code%{ RETVAL = &THIS->config; %};
bool multiple_extruders()
%code{% RETVAL = THIS->multiple_extruders; %};
Ref<Extruder> extruder();
std::string extrusion_axis();
void apply_print_config(PrintConfig* print_config)
%code{% THIS->apply_print_config(*print_config); %};
void set_extruders(std::vector<unsigned int> extruder_ids);
std::string preamble();
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1);
std::string set_bed_temperature(unsigned int temperature, bool wait = false);
std::string set_fan(unsigned int speed, bool dont_save = false);
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);
bool need_toolchange(unsigned int extruder_id);
std::string set_extruder(unsigned int extruder_id);
std::string toolchange(unsigned int extruder_id);
std::string set_speed(double F, std::string comment = std::string());
std::string travel_to_xy(Pointf* point, std::string comment = std::string())
%code{% RETVAL = THIS->travel_to_xy(*point, comment); %};
std::string travel_to_xyz(Pointf3* point, std::string comment = std::string())
%code{% RETVAL = THIS->travel_to_xyz(*point, comment); %};
std::string travel_to_z(double z, std::string comment = std::string());
bool will_move_z(double z);
std::string extrude_to_xy(Pointf* point, double dE, std::string comment = std::string())
%code{% RETVAL = THIS->extrude_to_xy(*point, dE, comment); %};
std::string extrude_to_xyz(Pointf3* point, double dE, std::string comment = std::string())
%code{% RETVAL = THIS->extrude_to_xyz(*point, dE, comment); %};
std::string retract();
std::string retract_for_toolchange();
std::string unretract();
std::string lift();
std::string unlift();
%{
SV*
GCodeWriter::extruders()
CODE:
AV* av = newAV();
av_fill(av, THIS->extruders.size()-1);
int i = 0;
for (std::map<unsigned int,Extruder>::iterator it = THIS->extruders.begin(); it != THIS->extruders.end(); ++it) {
av_store(av, i++, perl_to_SV_ref(it->second));
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
RETVAL
%}
};

View file

@ -111,6 +111,8 @@ SurfaceCollection* O_OBJECT_SLIC3R
Ref<SurfaceCollection> O_OBJECT_SLIC3R_T
Extruder* O_OBJECT_SLIC3R
Ref<Extruder> O_OBJECT_SLIC3R_T
Clone<Extruder> O_OBJECT_SLIC3R_T
Model* O_OBJECT_SLIC3R
Ref<Model> O_OBJECT_SLIC3R_T
@ -159,6 +161,10 @@ MotionPlanner* O_OBJECT_SLIC3R
Ref<MotionPlanner> O_OBJECT_SLIC3R_T
Clone<MotionPlanner> O_OBJECT_SLIC3R_T
GCodeWriter* O_OBJECT_SLIC3R
Ref<GCodeWriter> O_OBJECT_SLIC3R_T
Clone<GCodeWriter> O_OBJECT_SLIC3R_T
ExtrusionLoopRole T_UV
ExtrusionRole T_UV
FlowRole T_UV

View file

@ -9,6 +9,8 @@
%typemap{std::vector<unsigned int>*};
%typemap{std::vector<double>};
%typemap{std::vector<double>*};
%typemap{std::vector<unsigned int>};
%typemap{std::vector<unsigned int>*};
%typemap{std::vector<std::string>};
%typemap{t_layer_height_ranges};
%typemap{SV*};
@ -82,6 +84,9 @@
%typemap{MotionPlanner*};
%typemap{Ref<MotionPlanner>}{simple};
%typemap{Clone<MotionPlanner>}{simple};
%typemap{GCodeWriter*};
%typemap{Ref<GCodeWriter>}{simple};
%typemap{Clone<GCodeWriter>}{simple};
%typemap{Surface*};
%typemap{Ref<Surface>}{simple};
@ -127,6 +132,8 @@
%typemap{TriangleMeshPtrs};
%typemap{Ref<SurfaceCollection>}{simple};
%typemap{Extruder*};
%typemap{Ref<Extruder>}{simple};
%typemap{Clone<Extruder>}{simple};
%typemap{Model*};
%typemap{Ref<Model>}{simple};
%typemap{Clone<Model>}{simple};