GCode.xsp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/GCode.hpp"
  5. #include "libslic3r/GCode/CoolingBuffer.hpp"
  6. #include "libslic3r/GCode/SpiralVase.hpp"
  7. %}
  8. %name{Slic3r::GCode::AvoidCrossingPerimeters} class AvoidCrossingPerimeters {
  9. AvoidCrossingPerimeters();
  10. ~AvoidCrossingPerimeters();
  11. void init_external_mp(ExPolygons islands);
  12. void init_layer_mp(ExPolygons islands);
  13. Clone<Polyline> travel_to(GCode* gcode, Point* point)
  14. %code{% RETVAL = THIS->travel_to(*gcode, *point); %};
  15. bool use_external_mp()
  16. %code{% RETVAL = THIS->use_external_mp; %};
  17. void set_use_external_mp(bool value)
  18. %code{% THIS->use_external_mp = value; %};
  19. bool use_external_mp_once()
  20. %code{% RETVAL = THIS->use_external_mp_once; %};
  21. void set_use_external_mp_once(bool value)
  22. %code{% THIS->use_external_mp_once = value; %};
  23. bool disable_once()
  24. %code{% RETVAL = THIS->disable_once; %};
  25. void set_disable_once(bool value)
  26. %code{% THIS->disable_once = value; %};
  27. };
  28. %name{Slic3r::GCode::OozePrevention} class OozePrevention {
  29. OozePrevention();
  30. ~OozePrevention();
  31. bool enable()
  32. %code{% RETVAL = THIS->enable; %};
  33. void set_enable(bool value)
  34. %code{% THIS->enable = value; %};
  35. Points standby_points()
  36. %code{% RETVAL = THIS->standby_points; %};
  37. void set_standby_points(Points points)
  38. %code{% THIS->standby_points = points; %};
  39. std::string pre_toolchange(GCode* gcodegen)
  40. %code{% RETVAL = THIS->pre_toolchange(*gcodegen); %};
  41. std::string post_toolchange(GCode* gcodegen)
  42. %code{% RETVAL = THIS->post_toolchange(*gcodegen); %};
  43. };
  44. %name{Slic3r::GCode::Wipe} class Wipe {
  45. Wipe();
  46. ~Wipe();
  47. bool has_path();
  48. void reset_path();
  49. std::string wipe(GCode* gcodegen, bool toolchange = false)
  50. %code{% RETVAL = THIS->wipe(*gcodegen, toolchange); %};
  51. bool enable()
  52. %code{% RETVAL = THIS->enable; %};
  53. void set_enable(bool value)
  54. %code{% THIS->enable = value; %};
  55. Ref<Polyline> path()
  56. %code{% RETVAL = &(THIS->path); %};
  57. void set_path(Polyline* value)
  58. %code{% THIS->path = *value; %};
  59. };
  60. %name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
  61. CoolingBuffer(GCode* gcode)
  62. %code{% RETVAL = new CoolingBuffer(*gcode); %};
  63. ~CoolingBuffer();
  64. Ref<GCode> gcodegen();
  65. std::string append(std::string gcode, std::string obj_id, size_t layer_id, float print_z);
  66. std::string flush();
  67. };
  68. %name{Slic3r::GCode::SpiralVase} class SpiralVase {
  69. SpiralVase(StaticPrintConfig* config)
  70. %code{% RETVAL = new SpiralVase(*dynamic_cast<PrintConfig*>(config)); %};
  71. ~SpiralVase();
  72. bool enable()
  73. %code{% RETVAL = THIS->enable; %};
  74. void set_enable(bool enable)
  75. %code{% THIS->enable = enable; %};
  76. std::string process_layer(std::string gcode);
  77. };
  78. %name{Slic3r::GCode} class GCode {
  79. GCode();
  80. ~GCode();
  81. Ref<Pointf> origin()
  82. %code{% RETVAL = &(THIS->origin); %};
  83. Ref<StaticPrintConfig> config()
  84. %code{% RETVAL = &(THIS->config); %};
  85. Ref<GCodeWriter> writer()
  86. %code{% RETVAL = &(THIS->writer); %};
  87. Ref<PlaceholderParser> placeholder_parser()
  88. %code{% RETVAL = THIS->placeholder_parser; %};
  89. void set_placeholder_parser(PlaceholderParser* ptr)
  90. %code{% THIS->placeholder_parser = ptr; %};
  91. Ref<OozePrevention> ooze_prevention()
  92. %code{% RETVAL = &(THIS->ooze_prevention); %};
  93. Ref<Wipe> wipe()
  94. %code{% RETVAL = &(THIS->wipe); %};
  95. Ref<AvoidCrossingPerimeters> avoid_crossing_perimeters()
  96. %code{% RETVAL = &(THIS->avoid_crossing_perimeters); %};
  97. bool enable_loop_clipping()
  98. %code{% RETVAL = THIS->enable_loop_clipping; %};
  99. void set_enable_loop_clipping(bool value)
  100. %code{% THIS->enable_loop_clipping = value; %};
  101. bool enable_cooling_markers()
  102. %code{% RETVAL = THIS->enable_cooling_markers; %};
  103. void set_enable_cooling_markers(bool value)
  104. %code{% THIS->enable_cooling_markers = value; %};
  105. int layer_count()
  106. %code{% RETVAL = THIS->layer_count; %};
  107. void set_layer_count(int value)
  108. %code{% THIS->layer_count = value; %};
  109. int layer_index()
  110. %code{% RETVAL = THIS->layer_index; %};
  111. void set_layer_index(int value)
  112. %code{% THIS->layer_index = value; %};
  113. bool has_layer()
  114. %code{% RETVAL = THIS->layer != NULL; %};
  115. Ref<Layer> layer()
  116. %code{% RETVAL = THIS->layer; %};
  117. void set_layer(Layer* ptr)
  118. %code{% THIS->layer = ptr; %};
  119. bool first_layer()
  120. %code{% RETVAL = THIS->first_layer; %};
  121. void set_first_layer(bool value)
  122. %code{% THIS->first_layer = value; %};
  123. float elapsed_time()
  124. %code{% RETVAL = THIS->elapsed_time; %};
  125. void set_elapsed_time(float value)
  126. %code{% THIS->elapsed_time = value; %};
  127. bool last_pos_defined();
  128. Ref<Point> last_pos()
  129. %code{% RETVAL = &(THIS->last_pos()); %};
  130. void set_last_pos(Point* pos)
  131. %code{% THIS->set_last_pos(*pos); %};
  132. double volumetric_speed()
  133. %code{% RETVAL = THIS->volumetric_speed; %};
  134. void set_volumetric_speed(double value)
  135. %code{% THIS->volumetric_speed = value; %};
  136. void apply_print_config(StaticPrintConfig* print_config)
  137. %code{%
  138. if (const PrintConfig* config = dynamic_cast<PrintConfig*>(print_config)) {
  139. THIS->apply_print_config(*config);
  140. } else {
  141. CONFESS("A PrintConfig object was not supplied to apply_print_config()");
  142. }
  143. %};
  144. void set_extruders(std::vector<unsigned int> extruder_ids);
  145. void set_origin(Pointf* pointf)
  146. %code{% THIS->set_origin(*pointf); %};
  147. std::string preamble();
  148. std::string notes();
  149. std::string change_layer(Layer* layer)
  150. %code{% RETVAL = THIS->change_layer(*layer); %};
  151. %name{extrude_loop} std::string extrude(ExtrusionLoop* loop, std::string description = "", double speed = -1)
  152. %code{% RETVAL = THIS->extrude(*loop, description, speed); %};
  153. %name{extrude_path} std::string extrude(ExtrusionPath* path, std::string description = "", double speed = -1)
  154. %code{% RETVAL = THIS->extrude(*path, description, speed); %};
  155. std::string travel_to(Point* point, ExtrusionRole role, std::string comment)
  156. %code{% RETVAL = THIS->travel_to(*point, role, comment); %};
  157. bool needs_retraction(Polyline* travel, ExtrusionRole role = erNone)
  158. %code{% RETVAL = THIS->needs_retraction(*travel, role); %};
  159. std::string retract(bool toolchange = false);
  160. std::string unretract();
  161. std::string set_extruder(unsigned int extruder_id);
  162. Clone<Pointf> point_to_gcode(Point* point)
  163. %code{% RETVAL = THIS->point_to_gcode(*point); %};
  164. %{
  165. std::string
  166. GCode::extrude(entity, description, speed)
  167. SV* entity
  168. std::string description;
  169. double speed;
  170. CODE:
  171. ExtrusionEntity* e = (ExtrusionEntity *)SvIV((SV*)SvRV( entity ));
  172. RETVAL = THIS->extrude(*e, description, speed);
  173. OUTPUT:
  174. RETVAL
  175. %}
  176. };