PolylineCollection.xsp 2.2 KB

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