Layer.xsp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/Layer.hpp"
  5. #include "libslic3r/ExPolygonCollection.hpp"
  6. %}
  7. %name{Slic3r::Layer::Region} class LayerRegion {
  8. // owned by Layer, no constructor/destructor
  9. Ref<Layer> layer();
  10. Ref<PrintRegion> region();
  11. Ref<SurfaceCollection> slices()
  12. %code%{ RETVAL = &THIS->slices; %};
  13. Ref<ExtrusionEntityCollection> thin_fills()
  14. %code%{ RETVAL = &THIS->thin_fills; %};
  15. Ref<SurfaceCollection> fill_surfaces()
  16. %code%{ RETVAL = &THIS->fill_surfaces; %};
  17. Ref<ExtrusionEntityCollection> perimeters()
  18. %code%{ RETVAL = &THIS->perimeters; %};
  19. Ref<ExtrusionEntityCollection> fills()
  20. %code%{ RETVAL = &THIS->fills; %};
  21. Clone<Flow> flow(FlowRole role, bool bridge = false, double width = -1)
  22. %code%{ RETVAL = THIS->flow(role, bridge, width); %};
  23. void prepare_fill_surfaces();
  24. void make_perimeters(SurfaceCollection* slices, SurfaceCollection* fill_surfaces)
  25. %code%{ THIS->make_perimeters(*slices, fill_surfaces); %};
  26. double infill_area_threshold();
  27. void export_region_slices_to_svg(const char *path) const;
  28. void export_region_fill_surfaces_to_svg(const char *path) const;
  29. void export_region_slices_to_svg_debug(const char *name) const;
  30. void export_region_fill_surfaces_to_svg_debug(const char *name) const;
  31. };
  32. %name{Slic3r::Layer} class Layer {
  33. // owned by PrintObject, no constructor/destructor
  34. Ref<Layer> as_layer()
  35. %code%{ RETVAL = THIS; %};
  36. int id();
  37. void set_id(int id);
  38. Ref<PrintObject> object();
  39. bool slicing_errors()
  40. %code%{ RETVAL = THIS->slicing_errors; %};
  41. coordf_t slice_z()
  42. %code%{ RETVAL = THIS->slice_z; %};
  43. coordf_t print_z()
  44. %code%{ RETVAL = THIS->print_z; %};
  45. coordf_t height()
  46. %code%{ RETVAL = THIS->height; %};
  47. size_t region_count();
  48. Ref<LayerRegion> get_region(int idx);
  49. Ref<LayerRegion> add_region(PrintRegion* print_region);
  50. ExPolygonCollection* slices()
  51. %code%{ RETVAL = new ExPolygonCollection(THIS->lslices); %};
  52. int ptr()
  53. %code%{ RETVAL = (int)(intptr_t)THIS; %};
  54. Ref<SupportLayer> as_support_layer()
  55. %code%{ RETVAL = dynamic_cast<SupportLayer*>(THIS); %};
  56. void make_slices();
  57. void backup_untyped_slices();
  58. void restore_untyped_slices();
  59. void make_perimeters();
  60. void make_fills();
  61. void export_region_slices_to_svg(const char *path);
  62. void export_region_fill_surfaces_to_svg(const char *path);
  63. void export_region_slices_to_svg_debug(const char *name);
  64. void export_region_fill_surfaces_to_svg_debug(const char *name);
  65. };
  66. %name{Slic3r::Layer::Support} class SupportLayer {
  67. // owned by PrintObject, no constructor/destructor
  68. Ref<Layer> as_layer()
  69. %code%{ RETVAL = THIS; %};
  70. Ref<ExPolygonCollection> support_islands()
  71. %code%{ RETVAL = &THIS->support_islands; %};
  72. Ref<ExtrusionEntityCollection> support_fills()
  73. %code%{ RETVAL = &THIS->support_fills; %};
  74. // copies of some Layer methods, because the parameter wrapper code
  75. // gets confused about getting a Layer::Support instead of a Layer
  76. int id();
  77. void set_id(int id);
  78. Ref<PrintObject> object();
  79. bool slicing_errors()
  80. %code%{ RETVAL = THIS->slicing_errors; %};
  81. coordf_t slice_z()
  82. %code%{ RETVAL = THIS->slice_z; %};
  83. coordf_t print_z()
  84. %code%{ RETVAL = THIS->print_z; %};
  85. coordf_t height()
  86. %code%{ RETVAL = THIS->height; %};
  87. size_t region_count();
  88. Ref<LayerRegion> get_region(int idx);
  89. Ref<LayerRegion> add_region(PrintRegion* print_region);
  90. ExPolygonCollection* slices()
  91. %code%{ RETVAL = new ExPolygonCollection(THIS->lslices); %};
  92. void export_region_slices_to_svg(const char *path);
  93. void export_region_fill_surfaces_to_svg(const char *path);
  94. void export_region_slices_to_svg_debug(const char *name);
  95. void export_region_fill_surfaces_to_svg_debug(const char *name);
  96. };