ExPolygonCollection.xsp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/ExPolygonCollection.hpp"
  5. %}
  6. %name{Slic3r::ExPolygon::Collection} class ExPolygonCollection {
  7. ~ExPolygonCollection();
  8. Clone<ExPolygonCollection> clone()
  9. %code{% RETVAL = THIS; %};
  10. void clear()
  11. %code{% THIS->expolygons.clear(); %};
  12. void scale(double factor);
  13. void translate(double x, double y);
  14. void rotate(double angle, Point* center)
  15. %code{% THIS->rotate(angle, *center); %};
  16. int count()
  17. %code{% RETVAL = THIS->expolygons.size(); %};
  18. bool contains_point(Point* point)
  19. %code{% RETVAL = THIS->contains(*point); %};
  20. bool contains_line(Line* line)
  21. %code{% RETVAL = THIS->contains(*line); %};
  22. bool contains_polyline(Polyline* polyline)
  23. %code{% RETVAL = THIS->contains(*polyline); %};
  24. void simplify(double tolerance);
  25. Polygons polygons()
  26. %code{% RETVAL = (Polygons)*THIS; %};
  27. Clone<Polygon> convex_hull();
  28. %{
  29. ExPolygonCollection*
  30. ExPolygonCollection::new(...)
  31. CODE:
  32. RETVAL = new ExPolygonCollection ();
  33. // ST(0) is class name, others are expolygons
  34. RETVAL->expolygons.resize(items-1);
  35. for (unsigned int i = 1; i < items; i++) {
  36. // Note: a COPY of the input is stored
  37. from_SV_check(ST(i), &RETVAL->expolygons[i-1]);
  38. }
  39. OUTPUT:
  40. RETVAL
  41. SV*
  42. ExPolygonCollection::arrayref()
  43. CODE:
  44. AV* av = newAV();
  45. av_fill(av, THIS->expolygons.size()-1);
  46. int i = 0;
  47. for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
  48. av_store(av, i++, perl_to_SV_ref(*it));
  49. }
  50. RETVAL = newRV_noinc((SV*)av);
  51. OUTPUT:
  52. RETVAL
  53. SV*
  54. ExPolygonCollection::pp()
  55. CODE:
  56. AV* av = newAV();
  57. av_fill(av, THIS->expolygons.size()-1);
  58. int i = 0;
  59. for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
  60. av_store(av, i++, to_SV_pureperl(&*it));
  61. }
  62. RETVAL = newRV_noinc((SV*)av);
  63. OUTPUT:
  64. RETVAL
  65. void
  66. ExPolygonCollection::append(...)
  67. CODE:
  68. for (unsigned int i = 1; i < items; i++) {
  69. ExPolygon expolygon;
  70. from_SV_check(ST(i), &expolygon);
  71. THIS->expolygons.push_back(expolygon);
  72. }
  73. %}
  74. };