GCode.xsp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/GCode.hpp"
  5. #include "libslic3r/GCode/CoolingBuffer.hpp"
  6. %}
  7. %name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
  8. CoolingBuffer(GCode* gcode)
  9. %code{% RETVAL = new CoolingBuffer(*gcode); %};
  10. ~CoolingBuffer();
  11. std::string process_layer(std::string gcode, size_t layer_id)
  12. %code{% RETVAL = THIS->process_layer(std::move(gcode), layer_id, true); %};
  13. };
  14. %name{Slic3r::GCode} class GCode {
  15. GCode();
  16. ~GCode();
  17. void do_export(Print *print, const char *path)
  18. %code%{
  19. try {
  20. THIS->do_export(print, path);
  21. } catch (std::exception& e) {
  22. croak("%s\n", e.what());
  23. }
  24. %};
  25. Ref<Vec2d> origin()
  26. %code{% RETVAL = &(THIS->origin()); %};
  27. void set_origin(Vec2d* pointf)
  28. %code{% THIS->set_origin(*pointf); %};
  29. Ref<Point> last_pos()
  30. %code{% RETVAL = &(THIS->last_pos()); %};
  31. unsigned int layer_count() const;
  32. void set_layer_count(unsigned int value);
  33. void set_extruders(std::vector<unsigned int> extruders)
  34. %code{% THIS->writer().set_extruders(extruders); THIS->writer().set_extruder(0); %};
  35. void apply_print_config(StaticPrintConfig* print_config)
  36. %code{%
  37. if (const PrintConfig* config = dynamic_cast<PrintConfig*>(print_config)) {
  38. THIS->apply_print_config(*config);
  39. } else {
  40. CONFESS("A PrintConfig object was not supplied to apply_print_config()");
  41. }
  42. %};
  43. Ref<StaticPrintConfig> config()
  44. %code{% RETVAL = const_cast<StaticPrintConfig*>(static_cast<const StaticPrintConfig*>(static_cast<const PrintObjectConfig*>(&THIS->config()))); %};
  45. };