ExtrusionPath.xsp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/ExtrusionEntity.hpp"
  5. #include "libslic3r/ExtrusionEntityCollection.hpp"
  6. %}
  7. %name{Slic3r::ExtrusionPath} class ExtrusionPath {
  8. ~ExtrusionPath();
  9. SV* arrayref()
  10. %code{% RETVAL = to_AV(&THIS->polyline); %};
  11. SV* pp()
  12. %code{% RETVAL = to_SV_pureperl(&THIS->polyline); %};
  13. void pop_back()
  14. %code{% THIS->polyline.points.pop_back(); %};
  15. void reverse();
  16. Lines lines()
  17. %code{% RETVAL = THIS->polyline.lines(); %};
  18. Clone<Point> first_point();
  19. Clone<Point> last_point();
  20. void clip_end(double distance);
  21. void simplify(double tolerance);
  22. double length();
  23. ExtrusionRole role() const;
  24. bool is_bridge()
  25. %code{% RETVAL = is_bridge(THIS->role()); %};
  26. Polygons polygons_covered_by_width();
  27. Polygons polygons_covered_by_spacing();
  28. %{
  29. ExtrusionPath*
  30. _new(CLASS, polyline_sv, role, mm3_per_mm, width, height)
  31. char* CLASS;
  32. SV* polyline_sv;
  33. ExtrusionRole role;
  34. double mm3_per_mm;
  35. float width;
  36. float height;
  37. CODE:
  38. RETVAL = new ExtrusionPath (role);
  39. from_SV_check(polyline_sv, &RETVAL->polyline);
  40. RETVAL->mm3_per_mm = mm3_per_mm;
  41. RETVAL->width = width;
  42. RETVAL->height = height;
  43. OUTPUT:
  44. RETVAL
  45. Ref<Polyline>
  46. ExtrusionPath::polyline(...)
  47. CODE:
  48. if (items > 1) {
  49. from_SV_check(ST(1), &THIS->polyline);
  50. }
  51. RETVAL = &(THIS->polyline);
  52. OUTPUT:
  53. RETVAL
  54. double
  55. ExtrusionPath::mm3_per_mm(...)
  56. CODE:
  57. if (items > 1) {
  58. THIS->mm3_per_mm = (double)SvNV(ST(1));
  59. }
  60. RETVAL = THIS->mm3_per_mm;
  61. OUTPUT:
  62. RETVAL
  63. float
  64. ExtrusionPath::width(...)
  65. CODE:
  66. if (items > 1) {
  67. THIS->width = (float)SvNV(ST(1));
  68. }
  69. RETVAL = THIS->width;
  70. OUTPUT:
  71. RETVAL
  72. float
  73. ExtrusionPath::height(...)
  74. CODE:
  75. if (items > 1) {
  76. THIS->height = (float)SvNV(ST(1));
  77. }
  78. RETVAL = THIS->height;
  79. OUTPUT:
  80. RETVAL
  81. void
  82. ExtrusionPath::append(...)
  83. CODE:
  84. for (unsigned int i = 1; i < items; i++) {
  85. Point p;
  86. from_SV_check(ST(i), &p);
  87. THIS->polyline.points.push_back(p);
  88. }
  89. ExtrusionEntityCollection*
  90. ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
  91. CODE:
  92. RETVAL = new ExtrusionEntityCollection ();
  93. THIS->intersect_expolygons(*collection, RETVAL);
  94. OUTPUT:
  95. RETVAL
  96. ExtrusionEntityCollection*
  97. ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
  98. CODE:
  99. RETVAL = new ExtrusionEntityCollection ();
  100. THIS->subtract_expolygons(*collection, RETVAL);
  101. OUTPUT:
  102. RETVAL
  103. %}
  104. };
  105. %package{Slic3r::ExtrusionPath};
  106. %{
  107. IV
  108. _constant()
  109. ALIAS:
  110. EXTR_ROLE_NONE = erNone
  111. EXTR_ROLE_PERIMETER = erPerimeter
  112. EXTR_ROLE_EXTERNAL_PERIMETER = erExternalPerimeter
  113. EXTR_ROLE_OVERHANG_PERIMETER = erOverhangPerimeter
  114. EXTR_ROLE_FILL = erInternalInfill
  115. EXTR_ROLE_SOLIDFILL = erSolidInfill
  116. EXTR_ROLE_TOPSOLIDFILL = erTopSolidInfill
  117. EXTR_ROLE_BRIDGE = erBridgeInfill
  118. EXTR_ROLE_GAPFILL = erGapFill
  119. EXTR_ROLE_SKIRT = erSkirt
  120. EXTR_ROLE_SUPPORTMATERIAL = erSupportMaterial
  121. EXTR_ROLE_SUPPORTMATERIAL_INTERFACE = erSupportMaterialInterface
  122. EXTR_ROLE_MIXED = erMixed
  123. PROTOTYPE:
  124. CODE:
  125. RETVAL = ix;
  126. OUTPUT: RETVAL
  127. %}