ExPolygon.xsp 1.5 KB

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