ExtrusionPath.xsp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. bool is_perimeter();
  24. bool is_infill();
  25. bool is_solid_infill();
  26. bool is_bridge();
  27. Polygons grow();
  28. Clone<Polyline> as_polyline();
  29. %{
  30. ExtrusionPath*
  31. _new(CLASS, polyline_sv, role, mm3_per_mm, width, height)
  32. char* CLASS;
  33. SV* polyline_sv;
  34. ExtrusionRole role;
  35. double mm3_per_mm;
  36. float width;
  37. float height;
  38. CODE:
  39. RETVAL = new ExtrusionPath (role);
  40. from_SV_check(polyline_sv, &RETVAL->polyline);
  41. RETVAL->mm3_per_mm = mm3_per_mm;
  42. RETVAL->width = width;
  43. RETVAL->height = height;
  44. OUTPUT:
  45. RETVAL
  46. Ref<Polyline>
  47. ExtrusionPath::polyline(...)
  48. CODE:
  49. if (items > 1) {
  50. from_SV_check(ST(1), &THIS->polyline);
  51. }
  52. RETVAL = &(THIS->polyline);
  53. OUTPUT:
  54. RETVAL
  55. ExtrusionRole
  56. ExtrusionPath::role(...)
  57. CODE:
  58. if (items > 1) {
  59. THIS->role = (ExtrusionRole)SvUV(ST(1));
  60. }
  61. RETVAL = THIS->role;
  62. OUTPUT:
  63. RETVAL
  64. double
  65. ExtrusionPath::mm3_per_mm(...)
  66. CODE:
  67. if (items > 1) {
  68. THIS->mm3_per_mm = (double)SvNV(ST(1));
  69. }
  70. RETVAL = THIS->mm3_per_mm;
  71. OUTPUT:
  72. RETVAL
  73. float
  74. ExtrusionPath::width(...)
  75. CODE:
  76. if (items > 1) {
  77. THIS->width = (float)SvNV(ST(1));
  78. }
  79. RETVAL = THIS->width;
  80. OUTPUT:
  81. RETVAL
  82. float
  83. ExtrusionPath::height(...)
  84. CODE:
  85. if (items > 1) {
  86. THIS->height = (float)SvNV(ST(1));
  87. }
  88. RETVAL = THIS->height;
  89. OUTPUT:
  90. RETVAL
  91. void
  92. ExtrusionPath::append(...)
  93. CODE:
  94. for (unsigned int i = 1; i < items; i++) {
  95. Point p;
  96. from_SV_check(ST(i), &p);
  97. THIS->polyline.points.push_back(p);
  98. }
  99. ExtrusionEntityCollection*
  100. ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
  101. CODE:
  102. RETVAL = new ExtrusionEntityCollection ();
  103. THIS->intersect_expolygons(*collection, RETVAL);
  104. OUTPUT:
  105. RETVAL
  106. ExtrusionEntityCollection*
  107. ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
  108. CODE:
  109. RETVAL = new ExtrusionEntityCollection ();
  110. THIS->subtract_expolygons(*collection, RETVAL);
  111. OUTPUT:
  112. RETVAL
  113. %}
  114. };
  115. %package{Slic3r::ExtrusionPath};
  116. %{
  117. IV
  118. _constant()
  119. ALIAS:
  120. EXTR_ROLE_NONE = erNone
  121. EXTR_ROLE_PERIMETER = erPerimeter
  122. EXTR_ROLE_EXTERNAL_PERIMETER = erExternalPerimeter
  123. EXTR_ROLE_OVERHANG_PERIMETER = erOverhangPerimeter
  124. EXTR_ROLE_FILL = erInternalInfill
  125. EXTR_ROLE_SOLIDFILL = erSolidInfill
  126. EXTR_ROLE_TOPSOLIDFILL = erTopSolidInfill
  127. EXTR_ROLE_BRIDGE = erBridgeInfill
  128. EXTR_ROLE_GAPFILL = erGapFill
  129. EXTR_ROLE_SKIRT = erSkirt
  130. EXTR_ROLE_SUPPORTMATERIAL = erSupportMaterial
  131. EXTR_ROLE_SUPPORTMATERIAL_INTERFACE = erSupportMaterialInterface
  132. PROTOTYPE:
  133. CODE:
  134. RETVAL = ix;
  135. OUTPUT: RETVAL
  136. %}