PrusaSlicer-NonPlainar/xs/xsp/Polyline.xsp

92 lines
2.4 KiB
Plaintext
Raw Normal View History

%module{Slic3r::XS};
%{
#include <myinit.h>
2014-05-26 15:13:24 +00:00
#include "BoundingBox.hpp"
2013-11-20 10:35:58 +00:00
#include "ClipperUtils.hpp"
#include "Polyline.hpp"
%}
%name{Slic3r::Polyline} class Polyline {
~Polyline();
Clone<Polyline> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
void scale(double factor);
void translate(double x, double y);
void pop_back()
%code{% THIS->points.pop_back(); %};
void reverse();
2013-09-13 13:19:15 +00:00
Lines lines();
Clone<Point> first_point();
Clone<Point> last_point();
Points equally_spaced_points(double distance)
%code{% THIS->equally_spaced_points(distance, &RETVAL); %};
double length();
bool is_valid();
void clip_end(double distance);
void clip_start(double distance);
void extend_end(double distance);
void extend_start(double distance);
void simplify(double tolerance);
void split_at(Point* point, Polyline* p1, Polyline* p2)
%code{% THIS->split_at(*point, p1, p2); %};
%{
Polyline*
Polyline::new(...)
CODE:
RETVAL = new Polyline ();
// ST(0) is class name, ST(1) is first point
RETVAL->points.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
RETVAL->points[i-1].from_SV_check( ST(i) );
}
OUTPUT:
RETVAL
void
Polyline::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
Point p;
2013-07-16 15:13:01 +00:00
p.from_SV_check( ST(i) );
THIS->points.push_back(p);
}
void
Polyline::append_polyline(polyline)
Polyline* polyline;
CODE:
for (Points::const_iterator it = polyline->points.begin(); it != polyline->points.end(); ++it) {
THIS->points.push_back((*it));
}
void
Polyline::rotate(angle, center_sv)
double angle;
SV* center_sv;
CODE:
Point center;
center.from_SV_check(center_sv);
THIS->rotate(angle, center);
2013-11-20 10:35:58 +00:00
Polygons
Polyline::grow(delta, scale = CLIPPER_OFFSET_SCALE, joinType = ClipperLib::jtSquare, miterLimit = 3)
const float delta
double scale
ClipperLib::JoinType joinType
double miterLimit
CODE:
Polylines polylines;
polylines.push_back(*THIS);
offset(polylines, RETVAL, delta, scale, joinType, miterLimit);
OUTPUT:
RETVAL
%}
};