ExPolygon.xsp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/ExPolygon.hpp"
  5. %}
  6. %name{Slic3r::ExPolygon} class ExPolygon {
  7. ~ExPolygon();
  8. Clone<ExPolygon> 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. Ref<Polygon> contour()
  15. %code{% RETVAL = &(THIS->contour); %};
  16. Polygons* holes()
  17. %code{% RETVAL = &(THIS->holes); %};
  18. void scale(double factor);
  19. void translate(double x, double y);
  20. double area();
  21. bool is_valid();
  22. bool contains_line(Line* line)
  23. %code{% RETVAL = THIS->contains(*line); %};
  24. bool contains_polyline(Polyline* polyline)
  25. %code{% RETVAL = THIS->contains(*polyline); %};
  26. bool contains_point(Point* point)
  27. %code{% RETVAL = THIS->contains(*point); %};
  28. ExPolygons simplify(double tolerance);
  29. Polygons simplify_p(double tolerance);
  30. Polylines medial_axis(double max_width, double min_width)
  31. %code{% THIS->medial_axis(max_width, min_width, &RETVAL); %};
  32. Polygons get_trapezoids(double angle)
  33. %code{% THIS->get_trapezoids(&RETVAL, angle); %};
  34. Polygons get_trapezoids2(double angle)
  35. %code{% THIS->get_trapezoids2(&RETVAL, angle); %};
  36. Polygons triangulate()
  37. %code{% THIS->triangulate(&RETVAL); %};
  38. Polygons triangulate_pp()
  39. %code{% THIS->triangulate_pp(&RETVAL); %};
  40. %{
  41. ExPolygon*
  42. ExPolygon::new(...)
  43. CODE:
  44. RETVAL = new ExPolygon ();
  45. // ST(0) is class name, ST(1) is contour and others are holes
  46. from_SV_check(ST(1), &RETVAL->contour);
  47. RETVAL->holes.resize(items-2);
  48. for (unsigned int i = 2; i < items; i++) {
  49. from_SV_check(ST(i), &RETVAL->holes[i-2]);
  50. }
  51. OUTPUT:
  52. RETVAL
  53. void
  54. ExPolygon::rotate(angle, center_sv)
  55. double angle;
  56. SV* center_sv;
  57. CODE:
  58. Point center;
  59. from_SV_check(center_sv, &center);
  60. THIS->rotate(angle, center);
  61. %}
  62. };