Polygon.xsp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "Polygon.hpp"
  5. %}
  6. %name{Slic3r::Polygon} class Polygon {
  7. ~Polygon();
  8. Polygon* clone()
  9. %code{% const char* CLASS = "Slic3r::Polygon"; RETVAL = new Polygon(*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 reverse();
  17. Lines lines();
  18. Polyline* split_at(Point* point)
  19. %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at(point); %};
  20. Polyline* split_at_index(int index)
  21. %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_index(index); %};
  22. Polyline* split_at_first_point()
  23. %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = THIS->split_at_first_point(); %};
  24. Points equally_spaced_points(double distance);
  25. double length();
  26. double area();
  27. bool is_counter_clockwise();
  28. bool is_clockwise();
  29. bool make_counter_clockwise();
  30. bool make_clockwise();
  31. bool is_valid();
  32. Point* first_point()
  33. %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->first_point(); %};
  34. %{
  35. Polygon*
  36. Polygon::new(...)
  37. CODE:
  38. RETVAL = new Polygon ();
  39. // ST(0) is class name, ST(1) is first point
  40. RETVAL->points.resize(items-1);
  41. for (unsigned int i = 1; i < items; i++) {
  42. RETVAL->points[i-1].from_SV_check( ST(i) );
  43. }
  44. OUTPUT:
  45. RETVAL
  46. void
  47. Polygon::rotate(angle, center_sv)
  48. double angle;
  49. SV* center_sv;
  50. CODE:
  51. Point center;
  52. center.from_SV_check(center_sv);
  53. THIS->rotate(angle, &center);
  54. %}
  55. };