Surface.xsp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "Surface.hpp"
  5. %}
  6. %name{Slic3r::Surface} class Surface {
  7. ~Surface();
  8. ExPolygon* expolygon()
  9. %code{% const char* CLASS = "Slic3r::ExPolygon::Ref"; RETVAL = &(THIS->expolygon); %};
  10. double thickness()
  11. %code{% RETVAL = THIS->thickness; %};
  12. unsigned short thickness_layers()
  13. %code{% RETVAL = THIS->thickness_layers; %};
  14. %{
  15. Surface*
  16. _new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, extra_perimeters)
  17. char* CLASS;
  18. ExPolygon* expolygon;
  19. SurfaceType surface_type;
  20. double thickness;
  21. unsigned short thickness_layers;
  22. double bridge_angle;
  23. unsigned short extra_perimeters;
  24. CODE:
  25. RETVAL = new Surface ();
  26. RETVAL->expolygon = *expolygon;
  27. RETVAL->surface_type = surface_type;
  28. RETVAL->thickness = thickness;
  29. RETVAL->thickness_layers = thickness_layers;
  30. RETVAL->bridge_angle = bridge_angle;
  31. RETVAL->extra_perimeters = extra_perimeters;
  32. // we don't delete expolygon here because it's referenced by a Perl SV
  33. // whose DESTROY will take care of destruction
  34. OUTPUT:
  35. RETVAL
  36. SurfaceType
  37. Surface::surface_type(...)
  38. CODE:
  39. if (items > 1) {
  40. THIS->surface_type = (SurfaceType)SvUV(ST(1));
  41. }
  42. RETVAL = THIS->surface_type;
  43. OUTPUT:
  44. RETVAL
  45. double
  46. Surface::bridge_angle(...)
  47. CODE:
  48. if (items > 1) {
  49. THIS->bridge_angle = (double)SvNV(ST(1));
  50. }
  51. RETVAL = THIS->bridge_angle;
  52. OUTPUT:
  53. RETVAL
  54. unsigned short
  55. Surface::extra_perimeters(...)
  56. CODE:
  57. if (items > 1) {
  58. THIS->extra_perimeters = (double)SvUV(ST(1));
  59. }
  60. RETVAL = THIS->extra_perimeters;
  61. OUTPUT:
  62. RETVAL
  63. Polygons
  64. Surface::polygons()
  65. CODE:
  66. RETVAL.push_back(THIS->expolygon.contour);
  67. for (Polygons::iterator it = THIS->expolygon.holes.begin(); it != THIS->expolygon.holes.end(); ++it) {
  68. RETVAL.push_back((*it));
  69. }
  70. OUTPUT:
  71. RETVAL
  72. %}
  73. };
  74. %package{Slic3r::Surface};
  75. %{
  76. IV
  77. _constant()
  78. ALIAS:
  79. S_TYPE_TOP = stTop
  80. S_TYPE_BOTTOM = stBottom
  81. S_TYPE_INTERNAL = stInternal
  82. S_TYPE_INTERNALSOLID = stInternalSolid
  83. S_TYPE_INTERNALBRIDGE = stInternalBridge
  84. S_TYPE_INTERNALVOID = stInternalVoid
  85. PROTOTYPE:
  86. CODE:
  87. RETVAL = ix;
  88. OUTPUT: RETVAL
  89. %}