Polyline.xsp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/BoundingBox.hpp"
  5. #include "libslic3r/ClipperUtils.hpp"
  6. #include "libslic3r/Polyline.hpp"
  7. %}
  8. %name{Slic3r::Polyline} class Polyline {
  9. ~Polyline();
  10. Clone<Polyline> clone()
  11. %code{% RETVAL = THIS; %};
  12. SV* arrayref()
  13. %code{% RETVAL = to_AV(THIS); %};
  14. SV* pp()
  15. %code{% RETVAL = to_SV_pureperl(THIS); %};
  16. void scale(double factor);
  17. void translate(double x, double y);
  18. void pop_back()
  19. %code{% THIS->points.pop_back(); %};
  20. void reverse();
  21. Lines lines();
  22. Clone<Point> first_point();
  23. Clone<Point> last_point();
  24. Points equally_spaced_points(double distance);
  25. double length();
  26. bool is_valid();
  27. void clip_end(double distance);
  28. void clip_start(double distance);
  29. void extend_end(double distance);
  30. void extend_start(double distance);
  31. void simplify(double tolerance);
  32. void split_at(Point* point, Polyline* p1, Polyline* p2)
  33. %code{% THIS->split_at(*point, p1, p2); %};
  34. bool is_straight();
  35. Clone<BoundingBox> bounding_box();
  36. void remove_duplicate_points();
  37. %{
  38. Polyline*
  39. Polyline::new(...)
  40. CODE:
  41. RETVAL = new Polyline ();
  42. // ST(0) is class name, ST(1) is first point
  43. RETVAL->points.resize(items-1);
  44. for (unsigned int i = 1; i < items; i++) {
  45. from_SV_check(ST(i), &RETVAL->points[i-1]);
  46. }
  47. OUTPUT:
  48. RETVAL
  49. void
  50. Polyline::append(...)
  51. CODE:
  52. for (unsigned int i = 1; i < items; i++) {
  53. Point p;
  54. from_SV_check(ST(i), &p);
  55. THIS->points.push_back(p);
  56. }
  57. void
  58. Polyline::append_polyline(polyline)
  59. Polyline* polyline;
  60. CODE:
  61. for (Points::const_iterator it = polyline->points.begin(); it != polyline->points.end(); ++it) {
  62. THIS->points.push_back((*it));
  63. }
  64. void
  65. Polyline::rotate(angle, center_sv)
  66. double angle;
  67. SV* center_sv;
  68. CODE:
  69. Point center;
  70. from_SV_check(center_sv, &center);
  71. THIS->rotate(angle, center);
  72. Polygons
  73. Polyline::grow(delta, joinType = Slic3r::ClipperLib::jtSquare, miterLimit = 3)
  74. const float delta
  75. Slic3r::ClipperLib::JoinType joinType
  76. double miterLimit
  77. CODE:
  78. RETVAL = offset(*THIS, delta, joinType, miterLimit);
  79. OUTPUT:
  80. RETVAL
  81. %}
  82. };