Point.xsp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. %module{Slic3r::XS};
  2. %{
  3. #include <myinit.h>
  4. #include "libslic3r/Point.hpp"
  5. #include "libslic3r/Polygon.hpp"
  6. #include "libslic3r/Polyline.hpp"
  7. %}
  8. %name{Slic3r::Point} class Point {
  9. Point(long _x = 0, long _y = 0);
  10. ~Point();
  11. Clone<Point> clone()
  12. %code{% RETVAL=THIS; %};
  13. void scale(double factor);
  14. void translate(double x, double y);
  15. SV* arrayref()
  16. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  17. SV* pp()
  18. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  19. long x()
  20. %code{% RETVAL = THIS->x; %};
  21. long y()
  22. %code{% RETVAL = THIS->y; %};
  23. int nearest_point_index(Points points);
  24. Point* nearest_point(Points points)
  25. %code{% RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
  26. double distance_to(Point* point)
  27. %code{% RETVAL = THIS->distance_to(*point); %};
  28. double distance_to_line(Line* line)
  29. %code{% RETVAL = THIS->distance_to(*line); %};
  30. double ccw(Point* p1, Point* p2)
  31. %code{% RETVAL = THIS->ccw(*p1, *p2); %};
  32. Clone<Point> projection_onto_polygon(Polygon* polygon)
  33. %code{% RETVAL = new Point(THIS->projection_onto(*polygon)); %};
  34. Clone<Point> projection_onto_polyline(Polyline* polyline)
  35. %code{% RETVAL = new Point(THIS->projection_onto(*polyline)); %};
  36. Clone<Point> projection_onto_line(Line* line)
  37. %code{% RETVAL = new Point(THIS->projection_onto(*line)); %};
  38. Clone<Point> negative()
  39. %code{% RETVAL = new Point(THIS->negative()); %};
  40. bool coincides_with_epsilon(Point* point)
  41. %code{% RETVAL = THIS->coincides_with_epsilon(*point); %};
  42. %{
  43. void
  44. Point::rotate(angle, center_sv)
  45. double angle;
  46. SV* center_sv;
  47. CODE:
  48. Point center;
  49. center.from_SV_check(center_sv);
  50. THIS->rotate(angle, center);
  51. bool
  52. Point::coincides_with(point_sv)
  53. SV* point_sv;
  54. CODE:
  55. Point point;
  56. point.from_SV_check(point_sv);
  57. RETVAL = THIS->coincides_with(point);
  58. OUTPUT:
  59. RETVAL
  60. %}
  61. };
  62. %name{Slic3r::Point3} class Point3 {
  63. Point3(long _x = 0, long _y = 0, long _z = 0);
  64. ~Point3();
  65. Clone<Point3> clone()
  66. %code{% RETVAL = THIS; %};
  67. long x()
  68. %code{% RETVAL = THIS->x; %};
  69. long y()
  70. %code{% RETVAL = THIS->y; %};
  71. long z()
  72. %code{% RETVAL = THIS->z; %};
  73. };
  74. %name{Slic3r::Pointf} class Pointf {
  75. Pointf(double _x = 0, double _y = 0);
  76. ~Pointf();
  77. Clone<Pointf> clone()
  78. %code{% RETVAL = THIS; %};
  79. SV* arrayref()
  80. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  81. SV* pp()
  82. %code{% RETVAL = THIS->to_SV_pureperl(); %};
  83. double x()
  84. %code{% RETVAL = THIS->x; %};
  85. double y()
  86. %code{% RETVAL = THIS->y; %};
  87. void set_x(double val)
  88. %code{% THIS->x = val; %};
  89. void set_y(double val)
  90. %code{% THIS->y = val; %};
  91. void translate(double x, double y);
  92. void scale(double factor);
  93. void rotate(double angle, Pointf* center)
  94. %code{% THIS->rotate(angle, *center); %};
  95. };
  96. %name{Slic3r::Pointf3} class Pointf3 {
  97. Pointf3(double _x = 0, double _y = 0, double _z = 0);
  98. ~Pointf3();
  99. Clone<Pointf3> clone()
  100. %code{% RETVAL = THIS; %};
  101. double x()
  102. %code{% RETVAL = THIS->x; %};
  103. double y()
  104. %code{% RETVAL = THIS->y; %};
  105. double z()
  106. %code{% RETVAL = THIS->z; %};
  107. void set_x(double val)
  108. %code{% THIS->x = val; %};
  109. void set_y(double val)
  110. %code{% THIS->y = val; %};
  111. void set_z(double val)
  112. %code{% THIS->z = val; %};
  113. void translate(double x, double y, double z);
  114. double distance_to(Pointf3* point)
  115. %code{% RETVAL = THIS->distance_to(*point); %};
  116. Clone<Pointf3> negative()
  117. %code{% RETVAL = THIS->negative(); %};
  118. Clone<Pointf3> vector_to(Pointf3* point)
  119. %code{% RETVAL = THIS->vector_to(*point); %};
  120. };