Polyline.xsp 2.5 KB

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