Line.xsp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "Line.hpp"
  5. %}
  6. %name{Slic3r::Line} class Line {
  7. ~Line();
  8. Line* clone()
  9. %code{% const char* CLASS = "Slic3r::Line"; RETVAL = new Line(*THIS); %};
  10. SV* arrayref()
  11. %code{% RETVAL = THIS->to_AV(); %};
  12. SV* pp()
  13. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  14. Point* a()
  15. %code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->a); %};
  16. Point* b()
  17. %code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->b); %};
  18. void reverse();
  19. void scale(double factor);
  20. void translate(double x, double y);
  21. double length();
  22. Point* midpoint()
  23. %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->midpoint(); %};
  24. Point* point_at(double distance)
  25. %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->point_at(distance); %};
  26. Polyline* as_polyline()
  27. %code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %};
  28. %{
  29. Line*
  30. Line::new(...)
  31. CODE:
  32. RETVAL = new Line ();
  33. // ST(0) is class name, ST(1) and ST(2) are endpoints
  34. RETVAL->a.from_SV_check( ST(1) );
  35. RETVAL->b.from_SV_check( ST(2) );
  36. OUTPUT:
  37. RETVAL
  38. void
  39. Line::rotate(angle, center_sv)
  40. double angle;
  41. SV* center_sv;
  42. CODE:
  43. Point center;
  44. center.from_SV_check(center_sv);
  45. THIS->rotate(angle, &center);
  46. bool
  47. Line::coincides_with(line_sv)
  48. SV* line_sv;
  49. CODE:
  50. Line line;
  51. line.from_SV_check(line_sv);
  52. RETVAL = THIS->coincides_with(&line);
  53. OUTPUT:
  54. RETVAL
  55. %}
  56. };