Surface.xsp 3.0 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_bridge() const;
  21. %{
  22. Surface*
  23. _new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, extra_perimeters)
  24. char* CLASS;
  25. ExPolygon* expolygon;
  26. SurfaceType surface_type;
  27. double thickness;
  28. unsigned short thickness_layers;
  29. double bridge_angle;
  30. unsigned short extra_perimeters;
  31. CODE:
  32. RETVAL = new Surface (surface_type, *expolygon);
  33. RETVAL->thickness = thickness;
  34. RETVAL->thickness_layers = thickness_layers;
  35. RETVAL->bridge_angle = bridge_angle;
  36. RETVAL->extra_perimeters = extra_perimeters;
  37. // we don't delete expolygon here because it's referenced by a Perl SV
  38. // whose DESTROY will take care of destruction
  39. OUTPUT:
  40. RETVAL
  41. SurfaceType
  42. Surface::surface_type(...)
  43. CODE:
  44. if (items > 1) {
  45. THIS->surface_type = (SurfaceType)SvUV(ST(1));
  46. }
  47. RETVAL = THIS->surface_type;
  48. OUTPUT:
  49. RETVAL
  50. double
  51. Surface::bridge_angle(...)
  52. CODE:
  53. if (items > 1) {
  54. THIS->bridge_angle = (double)SvNV(ST(1));
  55. }
  56. RETVAL = THIS->bridge_angle;
  57. OUTPUT:
  58. RETVAL
  59. unsigned short
  60. Surface::extra_perimeters(...)
  61. CODE:
  62. if (items > 1) {
  63. THIS->extra_perimeters = (double)SvUV(ST(1));
  64. }
  65. RETVAL = THIS->extra_perimeters;
  66. OUTPUT:
  67. RETVAL
  68. Polygons
  69. Surface::polygons()
  70. CODE:
  71. RETVAL.push_back(THIS->expolygon.contour);
  72. for (Polygons::iterator it = THIS->expolygon.holes.begin(); it != THIS->expolygon.holes.end(); ++it) {
  73. RETVAL.push_back((*it));
  74. }
  75. OUTPUT:
  76. RETVAL
  77. Surfaces
  78. Surface::offset(delta, joinType = ClipperLib::jtMiter, miterLimit = 3)
  79. const float delta
  80. Slic3r::ClipperLib::JoinType joinType
  81. double miterLimit
  82. CODE:
  83. surfaces_append(RETVAL, offset_ex(THIS->expolygon, delta, joinType, miterLimit), *THIS);
  84. OUTPUT:
  85. RETVAL
  86. %}
  87. };
  88. %package{Slic3r::Surface};
  89. %{
  90. IV
  91. _constant()
  92. ALIAS:
  93. S_TYPE_TOP = stTop
  94. S_TYPE_BOTTOM = stBottom
  95. S_TYPE_BOTTOMBRIDGE = stBottomBridge
  96. S_TYPE_INTERNAL = stInternal
  97. S_TYPE_INTERNALSOLID = stInternalSolid
  98. S_TYPE_INTERNALBRIDGE = stInternalBridge
  99. S_TYPE_INTERNALVOID = stInternalVoid
  100. S_TYPW_PERIMETER = stPerimeter
  101. PROTOTYPE:
  102. CODE:
  103. RETVAL = ix;
  104. OUTPUT: RETVAL
  105. %}