ExPolygon.xsp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "ExPolygon.hpp"
  5. %}
  6. %name{Slic3r::ExPolygon} class ExPolygon {
  7. ~ExPolygon();
  8. ExPolygon* clone()
  9. %code{% const char* CLASS = "Slic3r::ExPolygon"; RETVAL = new ExPolygon(*THIS); %};
  10. SV* arrayref()
  11. %code{% RETVAL = THIS->to_AV(); %};
  12. SV* pp()
  13. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  14. Polygon* contour()
  15. %code{% const char* CLASS = "Slic3r::Polygon::Ref"; 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. bool contains_point(Point* point);
  24. ExPolygons simplify(double tolerance);
  25. Polygons simplify_p(double tolerance);
  26. %{
  27. ExPolygon*
  28. ExPolygon::new(...)
  29. CODE:
  30. RETVAL = new ExPolygon ();
  31. // ST(0) is class name, ST(1) is contour and others are holes
  32. RETVAL->contour.from_SV_check(ST(1));
  33. RETVAL->holes.resize(items-2);
  34. for (unsigned int i = 2; i < items; i++) {
  35. RETVAL->holes[i-2].from_SV_check(ST(i));
  36. }
  37. OUTPUT:
  38. RETVAL
  39. void
  40. ExPolygon::rotate(angle, center_sv)
  41. double angle;
  42. SV* center_sv;
  43. CODE:
  44. Point center;
  45. center.from_SV_check(center_sv);
  46. THIS->rotate(angle, &center);
  47. %}
  48. };