PolylineCollection.xsp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/PolylineCollection.hpp"
  5. %}
  6. %name{Slic3r::Polyline::Collection} class PolylineCollection {
  7. ~PolylineCollection();
  8. Clone<PolylineCollection> clone()
  9. %code{% RETVAL = THIS; %};
  10. void clear()
  11. %code{% THIS->polylines.clear(); %};
  12. PolylineCollection* chained_path(bool no_reverse)
  13. %code{%
  14. RETVAL = new PolylineCollection();
  15. THIS->chained_path(RETVAL, no_reverse);
  16. %};
  17. PolylineCollection* chained_path_from(Point* start_near, bool no_reverse)
  18. %code{%
  19. RETVAL = new PolylineCollection();
  20. THIS->chained_path_from(*start_near, RETVAL, no_reverse);
  21. %};
  22. int count()
  23. %code{% RETVAL = THIS->polylines.size(); %};
  24. Clone<Point> leftmost_point();
  25. %{
  26. PolylineCollection*
  27. PolylineCollection::new(...)
  28. CODE:
  29. RETVAL = new PolylineCollection ();
  30. // ST(0) is class name, others are Polylines
  31. RETVAL->polylines.resize(items-1);
  32. for (unsigned int i = 1; i < items; i++) {
  33. // Note: a COPY of the input is stored
  34. from_SV_check(ST(i), &RETVAL->polylines[i-1]);
  35. }
  36. OUTPUT:
  37. RETVAL
  38. SV*
  39. PolylineCollection::arrayref()
  40. CODE:
  41. AV* av = newAV();
  42. av_fill(av, THIS->polylines.size()-1);
  43. int i = 0;
  44. for (Polylines::iterator it = THIS->polylines.begin(); it != THIS->polylines.end(); ++it) {
  45. av_store(av, i++, perl_to_SV_ref(*it));
  46. }
  47. RETVAL = newRV_noinc((SV*)av);
  48. OUTPUT:
  49. RETVAL
  50. SV*
  51. PolylineCollection::pp()
  52. CODE:
  53. AV* av = newAV();
  54. av_fill(av, THIS->polylines.size()-1);
  55. int i = 0;
  56. for (Polylines::iterator it = THIS->polylines.begin(); it != THIS->polylines.end(); ++it) {
  57. av_store(av, i++, to_SV_pureperl(&*it));
  58. }
  59. RETVAL = newRV_noinc((SV*)av);
  60. OUTPUT:
  61. RETVAL
  62. void
  63. PolylineCollection::append(...)
  64. CODE:
  65. for (unsigned int i = 1; i < items; i++) {
  66. Polyline polyline;
  67. from_SV_check(ST(i), &polyline);
  68. THIS->polylines.push_back(polyline);
  69. }
  70. %}
  71. };