Polyline.xsp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_AV(); %};
  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. Point* first_point()
  21. %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %};
  22. Point* last_point()
  23. %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->last_point(); %};
  24. Points equally_spaced_points(double distance);
  25. double length();
  26. bool is_valid();
  27. void clip_end(double distance);
  28. void clip_start(double distance);
  29. %{
  30. Polyline*
  31. Polyline::new(...)
  32. CODE:
  33. RETVAL = new Polyline ();
  34. // ST(0) is class name, ST(1) is first point
  35. RETVAL->points.resize(items-1);
  36. for (unsigned int i = 1; i < items; i++) {
  37. RETVAL->points[i-1].from_SV_check( ST(i) );
  38. }
  39. OUTPUT:
  40. RETVAL
  41. void
  42. Polyline::append(...)
  43. CODE:
  44. for (unsigned int i = 1; i < items; i++) {
  45. Point p;
  46. p.from_SV_check( ST(i) );
  47. THIS->points.push_back(p);
  48. }
  49. void
  50. Polyline::append_polyline(polyline)
  51. Polyline* polyline;
  52. CODE:
  53. for (Points::const_iterator it = polyline->points.begin(); it != polyline->points.end(); ++it) {
  54. THIS->points.push_back((*it));
  55. }
  56. void
  57. Polyline::rotate(angle, center_sv)
  58. double angle;
  59. SV* center_sv;
  60. CODE:
  61. Point center;
  62. center.from_SV_check(center_sv);
  63. THIS->rotate(angle, &center);
  64. %}
  65. };