BoundingBox.xsp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/BoundingBox.hpp"
  5. #include "libslic3r/Point.hpp"
  6. %}
  7. %name{Slic3r::Geometry::BoundingBox} class BoundingBox {
  8. BoundingBox();
  9. ~BoundingBox();
  10. Clone<BoundingBox> clone()
  11. %code{% RETVAL = THIS; %};
  12. void merge(BoundingBox* bb) %code{% THIS->merge(*bb); %};
  13. void merge_point(Point* point) %code{% THIS->merge(*point); %};
  14. void scale(double factor);
  15. void translate(double x, double y);
  16. void offset(double delta);
  17. bool contains_point(Point* point) %code{% RETVAL = THIS->contains(*point); %};
  18. bool overlap(BoundingBox* bbox) %code{% RETVAL = THIS->overlap(*bbox); %};
  19. Clone<Polygon> polygon();
  20. Clone<Point> size();
  21. Clone<Point> center();
  22. bool empty() %code{% RETVAL = empty(*THIS); %};
  23. double radius();
  24. Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
  25. Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
  26. int x_min() %code{% RETVAL = THIS->min(0); %};
  27. int x_max() %code{% RETVAL = THIS->max(0); %};
  28. int y_min() %code{% RETVAL = THIS->min(1); %};
  29. int y_max() %code{% RETVAL = THIS->max(1); %};
  30. void set_x_min(double val) %code{% THIS->min(0) = val; %};
  31. void set_x_max(double val) %code{% THIS->max(0) = val; %};
  32. void set_y_min(double val) %code{% THIS->min(1) = val; %};
  33. void set_y_max(double val) %code{% THIS->max(1) = val; %};
  34. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min(0), THIS->min(1), THIS->max(0), THIS->max(1)); RETVAL = buf; %};
  35. bool defined() %code{% RETVAL = THIS->defined; %};
  36. %{
  37. BoundingBox*
  38. new_from_points(CLASS, points)
  39. char* CLASS
  40. Points points
  41. CODE:
  42. RETVAL = new BoundingBox(points);
  43. OUTPUT:
  44. RETVAL
  45. %}
  46. };
  47. %name{Slic3r::Geometry::BoundingBoxf} class BoundingBoxf {
  48. BoundingBoxf();
  49. ~BoundingBoxf();
  50. Clone<BoundingBoxf> clone()
  51. %code{% RETVAL = THIS; %};
  52. void merge(BoundingBoxf* bb) %code{% THIS->merge(*bb); %};
  53. void merge_point(Vec2d* point) %code{% THIS->merge(*point); %};
  54. void scale(double factor);
  55. void translate(double x, double y);
  56. Clone<Vec2d> size();
  57. Clone<Vec2d> center();
  58. double radius();
  59. bool empty() %code{% RETVAL = empty(*THIS); %};
  60. Clone<Vec2d> min_point() %code{% RETVAL = THIS->min; %};
  61. Clone<Vec2d> max_point() %code{% RETVAL = THIS->max; %};
  62. double x_min() %code{% RETVAL = THIS->min(0); %};
  63. double x_max() %code{% RETVAL = THIS->max(0); %};
  64. double y_min() %code{% RETVAL = THIS->min(1); %};
  65. double y_max() %code{% RETVAL = THIS->max(1); %};
  66. void set_x_min(double val) %code{% THIS->min(0) = val; %};
  67. void set_x_max(double val) %code{% THIS->max(0) = val; %};
  68. void set_y_min(double val) %code{% THIS->min(1) = val; %};
  69. void set_y_max(double val) %code{% THIS->max(1) = val; %};
  70. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min(0), THIS->min(1), THIS->max(0), THIS->max(1)); RETVAL = buf; %};
  71. bool defined() %code{% RETVAL = THIS->defined; %};
  72. %{
  73. BoundingBoxf*
  74. new_from_points(CLASS, points)
  75. char* CLASS
  76. Pointfs points
  77. CODE:
  78. RETVAL = new BoundingBoxf(points);
  79. OUTPUT:
  80. RETVAL
  81. %}
  82. };
  83. %name{Slic3r::Geometry::BoundingBoxf3} class BoundingBoxf3 {
  84. BoundingBoxf3();
  85. ~BoundingBoxf3();
  86. Clone<BoundingBoxf3> clone()
  87. %code{% RETVAL = THIS; %};
  88. void merge(BoundingBoxf3* bb) %code{% THIS->merge(*bb); %};
  89. void merge_point(Vec3d* point) %code{% THIS->merge(*point); %};
  90. void scale(double factor);
  91. void translate(double x, double y, double z);
  92. void offset(double delta);
  93. bool contains_point(Vec3d* point) %code{% RETVAL = THIS->contains(*point); %};
  94. Clone<Vec3d> size();
  95. Clone<Vec3d> center();
  96. double radius();
  97. bool empty() %code{% RETVAL = empty(*THIS); %};
  98. Clone<Vec3d> min_point() %code{% RETVAL = THIS->min; %};
  99. Clone<Vec3d> max_point() %code{% RETVAL = THIS->max; %};
  100. double x_min() %code{% RETVAL = THIS->min(0); %};
  101. double x_max() %code{% RETVAL = THIS->max(0); %};
  102. double y_min() %code{% RETVAL = THIS->min(1); %};
  103. double y_max() %code{% RETVAL = THIS->max(1); %};
  104. double z_min() %code{% RETVAL = THIS->min(2); %};
  105. double z_max() %code{% RETVAL = THIS->max(2); %};
  106. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min(0), THIS->min(1), THIS->min(2), THIS->max(0), THIS->max(1), THIS->max(2)); RETVAL = buf; %};
  107. bool defined() %code{% RETVAL = THIS->defined; %};
  108. };