Line.xsp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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> intersection_infinite(Line* other)
  31. %code{%
  32. Point p;
  33. bool res = THIS->intersection_infinite(*other, &p);
  34. if (!res) CONFESS("Intersection failed");
  35. RETVAL = p;
  36. %};
  37. Polyline* as_polyline()
  38. %code{% RETVAL = new Polyline(THIS->a, THIS->b); %};
  39. Clone<Point> normal();
  40. Clone<Point> vector();
  41. double ccw(Point* point)
  42. %code{% RETVAL = THIS->ccw(*point); %};
  43. %{
  44. Line*
  45. Line::new(...)
  46. CODE:
  47. RETVAL = new Line ();
  48. // ST(0) is class name, ST(1) and ST(2) are endpoints
  49. from_SV_check(ST(1), &RETVAL->a);
  50. from_SV_check(ST(2), &RETVAL->b);
  51. OUTPUT:
  52. RETVAL
  53. void
  54. Line::rotate(angle, center_sv)
  55. double angle;
  56. SV* center_sv;
  57. CODE:
  58. Point center;
  59. from_SV_check(center_sv, &center);
  60. THIS->rotate(angle, center);
  61. bool
  62. Line::coincides_with(line_sv)
  63. SV* line_sv;
  64. CODE:
  65. Line line;
  66. from_SV_check(line_sv, &line);
  67. RETVAL = (*THIS) == line;
  68. OUTPUT:
  69. RETVAL
  70. %}
  71. };
  72. %name{Slic3r::Linef3} class Linef3 {
  73. Linef3(Vec3d* a, Vec3d* b)
  74. %code{% RETVAL = new Linef3(*a, *b); %};
  75. ~Linef3();
  76. Clone<Linef3> clone()
  77. %code{% RETVAL = THIS; %};
  78. Ref<Vec3d> a()
  79. %code{% RETVAL = &THIS->a; %};
  80. Ref<Vec3d> b()
  81. %code{% RETVAL = &THIS->b; %};
  82. Clone<Vec3d> intersect_plane(double z);
  83. void scale(double factor);
  84. };