Polygon.xsp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.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 = THIS->to_AV(); %};
  14. SV* pp()
  15. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  16. void scale(double factor);
  17. void translate(double x, double y);
  18. void reverse();
  19. Lines lines();
  20. Polyline* split_at_vertex(Point* point)
  21. %code{% RETVAL = new Polyline(); THIS->split_at_vertex(*point, RETVAL); %};
  22. Polyline* split_at_index(int index)
  23. %code{% RETVAL = new Polyline(); THIS->split_at_index(index, RETVAL); %};
  24. Polyline* split_at_first_point()
  25. %code{% RETVAL = new Polyline(); THIS->split_at_first_point(RETVAL); %};
  26. Points equally_spaced_points(double distance)
  27. %code{% THIS->equally_spaced_points(distance, &RETVAL); %};
  28. double length();
  29. double area();
  30. bool is_counter_clockwise();
  31. bool is_clockwise();
  32. bool make_counter_clockwise();
  33. bool make_clockwise();
  34. bool is_valid();
  35. Clone<Point> first_point();
  36. bool contains_point(Point* point)
  37. %code{% RETVAL = THIS->contains(*point); %};
  38. Polygons simplify(double tolerance);
  39. Polygons triangulate_convex()
  40. %code{% THIS->triangulate_convex(&RETVAL); %};
  41. Clone<Point> centroid();
  42. BoundingBox* bounding_box()
  43. %code{%
  44. RETVAL = new BoundingBox();
  45. THIS->bounding_box(RETVAL);
  46. %};
  47. std::string wkt();
  48. Points concave_points(double angle)
  49. %code{% THIS->concave_points(angle, &RETVAL); %};
  50. Points convex_points(double angle)
  51. %code{% THIS->convex_points(angle, &RETVAL); %};
  52. %{
  53. Polygon*
  54. Polygon::new(...)
  55. CODE:
  56. RETVAL = new Polygon ();
  57. // ST(0) is class name, ST(1) is first point
  58. RETVAL->points.resize(items-1);
  59. for (unsigned int i = 1; i < items; i++) {
  60. RETVAL->points[i-1].from_SV_check( ST(i) );
  61. }
  62. OUTPUT:
  63. RETVAL
  64. void
  65. Polygon::rotate(angle, center_sv)
  66. double angle;
  67. SV* center_sv;
  68. CODE:
  69. Point center;
  70. center.from_SV_check(center_sv);
  71. THIS->rotate(angle, center);
  72. %}
  73. };