Polyline.xsp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 simplify_by_visibility(ExPolygon* expolygon)
  33. %code{% THIS->simplify_by_visibility(*expolygon); %};
  34. void split_at(Point* point, Polyline* p1, Polyline* p2)
  35. %code{% THIS->split_at(*point, p1, p2); %};
  36. bool is_straight();
  37. Clone<BoundingBox> bounding_box();
  38. void remove_duplicate_points();
  39. %{
  40. Polyline*
  41. Polyline::new(...)
  42. CODE:
  43. RETVAL = new Polyline ();
  44. // ST(0) is class name, ST(1) is first point
  45. RETVAL->points.resize(items-1);
  46. for (unsigned int i = 1; i < items; i++) {
  47. from_SV_check(ST(i), &RETVAL->points[i-1]);
  48. }
  49. OUTPUT:
  50. RETVAL
  51. void
  52. Polyline::append(...)
  53. CODE:
  54. for (unsigned int i = 1; i < items; i++) {
  55. Point p;
  56. from_SV_check(ST(i), &p);
  57. THIS->points.push_back(p);
  58. }
  59. void
  60. Polyline::append_polyline(polyline)
  61. Polyline* polyline;
  62. CODE:
  63. for (Points::const_iterator it = polyline->points.begin(); it != polyline->points.end(); ++it) {
  64. THIS->points.push_back((*it));
  65. }
  66. void
  67. Polyline::rotate(angle, center_sv)
  68. double angle;
  69. SV* center_sv;
  70. CODE:
  71. Point center;
  72. from_SV_check(center_sv, &center);
  73. THIS->rotate(angle, center);
  74. Polygons
  75. Polyline::grow(delta, joinType = ClipperLib::jtSquare, miterLimit = 3)
  76. const float delta
  77. ClipperLib::JoinType joinType
  78. double miterLimit
  79. CODE:
  80. RETVAL = offset(*THIS, delta, joinType, miterLimit);
  81. OUTPUT:
  82. RETVAL
  83. %}
  84. };