GCode.xsp 1.8 KB

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