Polygon.xsp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/BoundingBox.hpp"
  5. #include "libslic3r/Polygon.hpp"
  6. #include "libslic3r/BoundingBox.hpp"
  7. %}
  8. %name{Slic3r::Polygon} class Polygon {
  9. ~Polygon();
  10. Clone<Polygon> clone()
  11. %code{% RETVAL = THIS; %};
  12. SV* arrayref()
  13. %code{% RETVAL = to_AV(THIS); %};
  14. SV* pp()
  15. %code{% RETVAL = to_SV_pureperl(THIS); %};
  16. void scale(double factor);
  17. void translate(double x, double y);
  18. void reverse();
  19. Lines lines();
  20. Clone<Polyline> split_at_vertex(Point* point)
  21. %code{% RETVAL = THIS->split_at_vertex(*point); %};
  22. Clone<Polyline> split_at_index(int index);
  23. Clone<Polyline> 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. Clone<Point> first_point();
  33. bool contains_point(Point* point)
  34. %code{% RETVAL = THIS->contains(*point); %};
  35. Polygons simplify(double tolerance);
  36. Polygons triangulate_convex()
  37. %code{% THIS->triangulate_convex(&RETVAL); %};
  38. Clone<Point> centroid();
  39. Clone<BoundingBox> bounding_box();
  40. Points concave_points(double angle);
  41. Points convex_points(double angle);
  42. Clone<Point> point_projection(Point* point)
  43. %code{% RETVAL = THIS->point_projection(*point); %};
  44. Clone<Point> intersection(Line* line)
  45. %code{%
  46. Point p;
  47. (void)THIS->intersection(*line, &p);
  48. RETVAL = p;
  49. %};
  50. Clone<Point> first_intersection(Line* line)
  51. %code{%
  52. Point p;
  53. (void)THIS->first_intersection(*line, &p);
  54. RETVAL = p;
  55. %};
  56. %{
  57. Polygon*
  58. Polygon::new(...)
  59. CODE:
  60. RETVAL = new Polygon ();
  61. // ST(0) is class name, ST(1) is first point
  62. RETVAL->points.resize(items-1);
  63. for (unsigned int i = 1; i < items; i++) {
  64. from_SV_check(ST(i), &RETVAL->points[i-1]);
  65. }
  66. OUTPUT:
  67. RETVAL
  68. void
  69. Polygon::rotate(angle, center_sv)
  70. double angle;
  71. SV* center_sv;
  72. CODE:
  73. Point center;
  74. from_SV_check(center_sv, &center);
  75. THIS->rotate(angle, center);
  76. %}
  77. };