Polyline.xsp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "Polyline.hpp"
  5. %}
  6. %name{Slic3r::Polyline} class Polyline {
  7. ~Polyline();
  8. Polyline* clone()
  9. %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %};
  10. SV* arrayref()
  11. %code{% RETVAL = THIS->to_SV(); %};
  12. SV* pp()
  13. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  14. void scale(double factor);
  15. void translate(double x, double y);
  16. void pop_back()
  17. %code{% THIS->points.pop_back(); %};
  18. void reverse();
  19. Lines lines();
  20. %{
  21. Polyline*
  22. Polyline::new(...)
  23. CODE:
  24. RETVAL = new Polyline ();
  25. // ST(0) is class name, ST(1) is first point
  26. RETVAL->points.resize(items-1);
  27. for (unsigned int i = 1; i < items; i++) {
  28. RETVAL->points[i-1].from_SV_check( ST(i) );
  29. }
  30. OUTPUT:
  31. RETVAL
  32. void
  33. Polyline::append(...)
  34. CODE:
  35. for (unsigned int i = 1; i < items; i++) {
  36. Point p;
  37. p.from_SV_check( ST(i) );
  38. THIS->points.push_back(p);
  39. }
  40. void
  41. Polyline::rotate(angle, center_sv)
  42. double angle;
  43. SV* center_sv;
  44. CODE:
  45. Point center;
  46. center.from_SV_check(center_sv);
  47. THIS->rotate(angle, &center);
  48. %}
  49. };