Polygon.xsp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. std::string wkt();
  41. Points concave_points(double angle);
  42. Points convex_points(double angle);
  43. Clone<Point> point_projection(Point* point)
  44. %code{% RETVAL = THIS->point_projection(*point); %};
  45. Clone<Point> intersection(Line* line)
  46. %code{%
  47. Point p;
  48. (void)THIS->intersection(*line, &p);
  49. RETVAL = p;
  50. %};
  51. Clone<Point> first_intersection(Line* line)
  52. %code{%
  53. Point p;
  54. (void)THIS->first_intersection(*line, &p);
  55. RETVAL = p;
  56. %};
  57. %{
  58. Polygon*
  59. Polygon::new(...)
  60. CODE:
  61. RETVAL = new Polygon ();
  62. // ST(0) is class name, ST(1) is first point
  63. RETVAL->points.resize(items-1);
  64. for (unsigned int i = 1; i < items; i++) {
  65. from_SV_check(ST(i), &RETVAL->points[i-1]);
  66. }
  67. OUTPUT:
  68. RETVAL
  69. void
  70. Polygon::rotate(angle, center_sv)
  71. double angle;
  72. SV* center_sv;
  73. CODE:
  74. Point center;
  75. from_SV_check(center_sv, &center);
  76. THIS->rotate(angle, center);
  77. %}
  78. };