Print.xsp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/Print.hpp"
  5. %}
  6. %name{Slic3r::Print} class Print {
  7. Print();
  8. ~Print();
  9. Ref<Model> model()
  10. %code%{ RETVAL = const_cast<Model*>(&THIS->model()); %};
  11. Ref<StaticPrintConfig> config()
  12. %code%{ RETVAL = const_cast<GCodeConfig*>(static_cast<const GCodeConfig*>(&THIS->config())); %};
  13. double total_used_filament()
  14. %code%{ RETVAL = THIS->print_statistics().total_used_filament; %};
  15. void auto_assign_extruders(ModelObject* model_object);
  16. std::string output_filepath(std::string path = "")
  17. %code%{
  18. try {
  19. RETVAL = THIS->output_filepath(path);
  20. } catch (std::exception& e) {
  21. croak("%s\n", e.what());
  22. }
  23. %};
  24. bool apply(Model *model, DynamicPrintConfig* config)
  25. %code%{
  26. // Touching every config as the Perl bindings does not correctly export ModelConfig,
  27. // therefore the configs have often invalid timestamps.
  28. for (auto obj : model->objects) {
  29. obj->config.touch();
  30. for (auto vol : obj->volumes)
  31. vol->config.touch();
  32. }
  33. for (auto mat : model->materials)
  34. mat.second->config.touch();
  35. RETVAL = THIS->apply(*model, *config);
  36. %};
  37. std::vector<unsigned int> extruders() const;
  38. int validate() %code%{
  39. std::string err = THIS->validate();
  40. if (! err.empty())
  41. croak("Configuration is not valid: %s\n", err.c_str());
  42. RETVAL = 1;
  43. %};
  44. void set_status_silent();
  45. void process() %code%{
  46. try {
  47. THIS->process();
  48. } catch (std::exception& e) {
  49. croak("%s\n", e.what());
  50. }
  51. %};
  52. void export_gcode(char *path_template) %code%{
  53. try {
  54. THIS->export_gcode(path_template, nullptr);
  55. } catch (std::exception& e) {
  56. croak("%s\n", e.what());
  57. }
  58. %};
  59. };