ExPolygon.xsp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_trapezoids2(double angle)
  33. %code{% THIS->get_trapezoids2(&RETVAL, angle); %};
  34. Polygons triangulate()
  35. %code{% THIS->triangulate(&RETVAL); %};
  36. %{
  37. ExPolygon*
  38. ExPolygon::new(...)
  39. CODE:
  40. RETVAL = new ExPolygon ();
  41. // ST(0) is class name, ST(1) is contour and others are holes
  42. from_SV_check(ST(1), &RETVAL->contour);
  43. RETVAL->holes.resize(items-2);
  44. for (unsigned int i = 2; i < items; i++) {
  45. from_SV_check(ST(i), &RETVAL->holes[i-2]);
  46. }
  47. OUTPUT:
  48. RETVAL
  49. void
  50. ExPolygon::rotate(angle, center_sv)
  51. double angle;
  52. SV* center_sv;
  53. CODE:
  54. Point center;
  55. from_SV_check(center_sv, &center);
  56. THIS->rotate(angle, center);
  57. %}
  58. };