Surface.xsp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/Surface.hpp"
  5. #include "libslic3r/ClipperUtils.hpp"
  6. %}
  7. %name{Slic3r::Surface} class Surface {
  8. ~Surface();
  9. Ref<ExPolygon> expolygon()
  10. %code{% RETVAL = &(THIS->expolygon); %};
  11. double thickness()
  12. %code{% RETVAL = THIS->thickness; %};
  13. unsigned short thickness_layers()
  14. %code{% RETVAL = THIS->thickness_layers; %};
  15. double area();
  16. bool is_solid() const;
  17. bool is_external() const;
  18. bool is_internal() const;
  19. bool is_bottom() const;
  20. bool is_top() const;
  21. bool is_bridge() const;
  22. %{
  23. Surface*
  24. _new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, extra_perimeters)
  25. char* CLASS;
  26. ExPolygon* expolygon;
  27. SurfaceType surface_type;
  28. double thickness;
  29. unsigned short thickness_layers;
  30. double bridge_angle;
  31. unsigned short extra_perimeters;
  32. CODE:
  33. RETVAL = new Surface (surface_type, *expolygon);
  34. RETVAL->thickness = thickness;
  35. RETVAL->thickness_layers = thickness_layers;
  36. RETVAL->bridge_angle = bridge_angle;
  37. RETVAL->extra_perimeters = extra_perimeters;
  38. // we don't delete expolygon here because it's referenced by a Perl SV
  39. // whose DESTROY will take care of destruction
  40. OUTPUT:
  41. RETVAL
  42. SurfaceType
  43. Surface::surface_type(...)
  44. CODE:
  45. if (items > 1) {
  46. THIS->surface_type = (SurfaceType)SvUV(ST(1));
  47. }
  48. RETVAL = THIS->surface_type;
  49. OUTPUT:
  50. RETVAL
  51. double
  52. Surface::bridge_angle(...)
  53. CODE:
  54. if (items > 1) {
  55. THIS->bridge_angle = (double)SvNV(ST(1));
  56. }
  57. RETVAL = THIS->bridge_angle;
  58. OUTPUT:
  59. RETVAL
  60. unsigned short
  61. Surface::extra_perimeters(...)
  62. CODE:
  63. if (items > 1) {
  64. THIS->extra_perimeters = (double)SvUV(ST(1));
  65. }
  66. RETVAL = THIS->extra_perimeters;
  67. OUTPUT:
  68. RETVAL
  69. Polygons
  70. Surface::polygons()
  71. CODE:
  72. RETVAL.push_back(THIS->expolygon.contour);
  73. for (Polygons::iterator it = THIS->expolygon.holes.begin(); it != THIS->expolygon.holes.end(); ++it) {
  74. RETVAL.push_back((*it));
  75. }
  76. OUTPUT:
  77. RETVAL
  78. Surfaces
  79. Surface::offset(delta, scale = CLIPPER_OFFSET_SCALE, joinType = ClipperLib::jtMiter, miterLimit = 3)
  80. const float delta
  81. double scale
  82. ClipperLib::JoinType joinType
  83. double miterLimit
  84. CODE:
  85. RETVAL = offset(*THIS, delta, scale, joinType, miterLimit);
  86. OUTPUT:
  87. RETVAL
  88. %}
  89. };
  90. %package{Slic3r::Surface};
  91. %{
  92. IV
  93. _constant()
  94. ALIAS:
  95. S_TYPE_TOP = stTop
  96. S_TYPE_BOTTOM = stBottom
  97. S_TYPE_INTERNAL = stInternal
  98. S_TYPE_SOLID = stSolid
  99. S_TYPE_BRIDGE = stBridge
  100. S_TYPE_VOID = stVoid
  101. PROTOTYPE:
  102. CODE:
  103. RETVAL = ix;
  104. OUTPUT: RETVAL
  105. %}