Line.xsp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/Line.hpp"
  5. #include "libslic3r/Polyline.hpp"
  6. %}
  7. %name{Slic3r::Line} class Line {
  8. ~Line();
  9. Clone<Line> clone()
  10. %code{% RETVAL = THIS; %};
  11. SV* arrayref()
  12. %code{% RETVAL = to_AV(THIS); %};
  13. SV* pp()
  14. %code{% RETVAL = to_SV_pureperl(THIS); %};
  15. Ref<Point> a()
  16. %code{% RETVAL=&THIS->a; %};
  17. Ref<Point> b()
  18. %code{% RETVAL=&THIS->b; %};
  19. void reverse();
  20. void scale(double factor);
  21. void translate(double x, double y);
  22. double length();
  23. double atan2_();
  24. double orientation();
  25. double direction();
  26. bool parallel_to(double angle);
  27. bool parallel_to_line(Line* line)
  28. %code{% RETVAL = THIS->parallel_to(*line); %};
  29. Clone<Point> midpoint();
  30. Clone<Point> point_at(double distance);
  31. Clone<Point> intersection_infinite(Line* other)
  32. %code{%
  33. Point p;
  34. bool res = THIS->intersection_infinite(*other, &p);
  35. if (!res) CONFESS("Intersection failed");
  36. RETVAL = p;
  37. %};
  38. Clone<Polyline> as_polyline()
  39. %code{% RETVAL = Polyline(*THIS); %};
  40. Clone<Point> normal();
  41. Clone<Point> vector();
  42. double ccw(Point* point)
  43. %code{% RETVAL = THIS->ccw(*point); %};
  44. %{
  45. Line*
  46. Line::new(...)
  47. CODE:
  48. RETVAL = new Line ();
  49. // ST(0) is class name, ST(1) and ST(2) are endpoints
  50. from_SV_check(ST(1), &RETVAL->a);
  51. from_SV_check(ST(2), &RETVAL->b);
  52. OUTPUT:
  53. RETVAL
  54. void
  55. Line::rotate(angle, center_sv)
  56. double angle;
  57. SV* center_sv;
  58. CODE:
  59. Point center;
  60. from_SV_check(center_sv, &center);
  61. THIS->rotate(angle, center);
  62. bool
  63. Line::coincides_with(line_sv)
  64. SV* line_sv;
  65. CODE:
  66. Line line;
  67. from_SV_check(line_sv, &line);
  68. RETVAL = THIS->coincides_with(line);
  69. OUTPUT:
  70. RETVAL
  71. %}
  72. };
  73. %name{Slic3r::Linef3} class Linef3 {
  74. Linef3(Pointf3* a, Pointf3* b)
  75. %code{% RETVAL = new Linef3(*a, *b); %};
  76. ~Linef3();
  77. Clone<Linef3> clone()
  78. %code{% RETVAL = THIS; %};
  79. Ref<Pointf3> a()
  80. %code{% RETVAL = &THIS->a; %};
  81. Ref<Pointf3> b()
  82. %code{% RETVAL = &THIS->b; %};
  83. Clone<Pointf3> intersect_plane(double z);
  84. void scale(double factor);
  85. };