ExPolygon.xsp 1.6 KB

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