Polygon.xsp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/Polygon.hpp"
  5. %}
  6. %name{Slic3r::Polygon} class Polygon {
  7. ~Polygon();
  8. Clone<Polygon> clone()
  9. %code{% RETVAL = THIS; %};
  10. SV* arrayref()
  11. %code{% RETVAL = to_AV(THIS); %};
  12. SV* pp()
  13. %code{% RETVAL = to_SV_pureperl(THIS); %};
  14. void scale(double factor);
  15. void translate(double x, double y);
  16. void reverse();
  17. Lines lines();
  18. Clone<Polyline> split_at_vertex(Point* point)
  19. %code{% RETVAL = THIS->split_at_vertex(*point); %};
  20. Clone<Polyline> split_at_first_point();
  21. double length();
  22. double area();
  23. bool is_counter_clockwise();
  24. bool is_clockwise();
  25. bool make_counter_clockwise();
  26. bool make_clockwise();
  27. bool is_valid();
  28. Clone<Point> first_point();
  29. bool contains_point(Point* point)
  30. %code{% RETVAL = THIS->contains(*point); %};
  31. Polygons simplify(double tolerance);
  32. Clone<Point> centroid();
  33. Clone<Point> first_intersection(Line* line)
  34. %code{%
  35. Point p;
  36. (void)THIS->first_intersection(*line, &p);
  37. RETVAL = p;
  38. %};
  39. %{
  40. Polygon*
  41. Polygon::new(...)
  42. CODE:
  43. RETVAL = new Polygon ();
  44. // ST(0) is class name, ST(1) is first point
  45. RETVAL->points.resize(items-1);
  46. for (unsigned int i = 1; i < items; i++) {
  47. from_SV_check(ST(i), &RETVAL->points[i-1]);
  48. }
  49. OUTPUT:
  50. RETVAL
  51. void
  52. Polygon::rotate(angle, center_sv)
  53. double angle;
  54. SV* center_sv;
  55. CODE:
  56. Point center;
  57. from_SV_check(center_sv, &center);
  58. THIS->rotate(angle, center);
  59. %}
  60. };