Polygon.xsp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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> intersection(Line* line)
  44. %code{%
  45. Point p;
  46. (void)THIS->intersection(*line, &p);
  47. RETVAL = p;
  48. %};
  49. %{
  50. Polygon*
  51. Polygon::new(...)
  52. CODE:
  53. RETVAL = new Polygon ();
  54. // ST(0) is class name, ST(1) is first point
  55. RETVAL->points.resize(items-1);
  56. for (unsigned int i = 1; i < items; i++) {
  57. from_SV_check(ST(i), &RETVAL->points[i-1]);
  58. }
  59. OUTPUT:
  60. RETVAL
  61. void
  62. Polygon::rotate(angle, center_sv)
  63. double angle;
  64. SV* center_sv;
  65. CODE:
  66. Point center;
  67. from_SV_check(center_sv, &center);
  68. THIS->rotate(angle, center);
  69. %}
  70. };