Layer.xsp 4.0 KB

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