BoundingBox.xsp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. long x_min() %code{% RETVAL = THIS->min.x; %};
  27. long x_max() %code{% RETVAL = THIS->max.x; %};
  28. long y_min() %code{% RETVAL = THIS->min.y; %};
  29. long y_max() %code{% RETVAL = THIS->max.y; %};
  30. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
  31. bool defined() %code{% RETVAL = THIS->defined; %};
  32. %{
  33. BoundingBox*
  34. new_from_points(CLASS, points)
  35. char* CLASS
  36. Points points
  37. CODE:
  38. RETVAL = new BoundingBox(points);
  39. OUTPUT:
  40. RETVAL
  41. %}
  42. };
  43. %name{Slic3r::Geometry::BoundingBoxf} class BoundingBoxf {
  44. BoundingBoxf();
  45. ~BoundingBoxf();
  46. Clone<BoundingBoxf> clone()
  47. %code{% RETVAL = THIS; %};
  48. void merge(BoundingBoxf* bb) %code{% THIS->merge(*bb); %};
  49. void merge_point(Pointf* point) %code{% THIS->merge(*point); %};
  50. void scale(double factor);
  51. void translate(double x, double y);
  52. Clone<Pointf> size();
  53. Clone<Pointf> center();
  54. double radius();
  55. bool empty() %code{% RETVAL = empty(*THIS); %};
  56. Clone<Pointf> min_point() %code{% RETVAL = THIS->min; %};
  57. Clone<Pointf> max_point() %code{% RETVAL = THIS->max; %};
  58. double x_min() %code{% RETVAL = THIS->min.x; %};
  59. double x_max() %code{% RETVAL = THIS->max.x; %};
  60. double y_min() %code{% RETVAL = THIS->min.y; %};
  61. double y_max() %code{% RETVAL = THIS->max.y; %};
  62. void set_x_min(double val) %code{% THIS->min.x = val; %};
  63. void set_x_max(double val) %code{% THIS->max.x = val; %};
  64. void set_y_min(double val) %code{% THIS->min.y = val; %};
  65. void set_y_max(double val) %code{% THIS->max.y = val; %};
  66. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf;%lf,%lf", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
  67. bool defined() %code{% RETVAL = THIS->defined; %};
  68. %{
  69. BoundingBoxf*
  70. new_from_points(CLASS, points)
  71. char* CLASS
  72. Pointfs points
  73. CODE:
  74. RETVAL = new BoundingBoxf(points);
  75. OUTPUT:
  76. RETVAL
  77. %}
  78. };
  79. %name{Slic3r::Geometry::BoundingBoxf3} class BoundingBoxf3 {
  80. BoundingBoxf3();
  81. ~BoundingBoxf3();
  82. Clone<BoundingBoxf3> clone()
  83. %code{% RETVAL = THIS; %};
  84. void merge(BoundingBoxf3* bb) %code{% THIS->merge(*bb); %};
  85. void merge_point(Pointf3* point) %code{% THIS->merge(*point); %};
  86. void scale(double factor);
  87. void translate(double x, double y, double z);
  88. void offset(double delta);
  89. bool contains_point(Pointf3* point) %code{% RETVAL = THIS->contains(*point); %};
  90. Clone<Pointf3> size();
  91. Clone<Pointf3> center();
  92. double radius();
  93. bool empty() %code{% RETVAL = empty(*THIS); %};
  94. Clone<Pointf3> min_point() %code{% RETVAL = THIS->min; %};
  95. Clone<Pointf3> max_point() %code{% RETVAL = THIS->max; %};
  96. double x_min() %code{% RETVAL = THIS->min.x; %};
  97. double x_max() %code{% RETVAL = THIS->max.x; %};
  98. double y_min() %code{% RETVAL = THIS->min.y; %};
  99. double y_max() %code{% RETVAL = THIS->max.y; %};
  100. double z_min() %code{% RETVAL = THIS->min.z; %};
  101. double z_max() %code{% RETVAL = THIS->max.z; %};
  102. std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf;%lf,%lf,%lf", THIS->min.x, THIS->min.y, THIS->min.z, THIS->max.x, THIS->max.y, THIS->max.z); RETVAL = buf; %};
  103. bool defined() %code{% RETVAL = THIS->defined; %};
  104. };