PrusaSlicer-NonPlainar/xs/xsp/Line.xsp

65 lines
1.4 KiB
Plaintext
Raw Normal View History

%module{Slic3r::XS};
%{
#include <myinit.h>
#include "Line.hpp"
#include "Polyline.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::Line} class Line {
~Line();
Clone<Line> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_AV(); %};
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
Ref<Point> a()
%code{% RETVAL=&THIS->a; %};
Ref<Point> b()
%code{% RETVAL=&THIS->b; %};
void reverse();
2013-07-16 15:13:01 +00:00
void scale(double factor);
void translate(double x, double y);
double length();
double atan2_();
double direction();
Point* midpoint();
Clone<Point> point_at(double distance);
2013-11-21 13:15:38 +00:00
Polyline* as_polyline()
%code{% RETVAL = new Polyline(*THIS); %};
%{
Line*
Line::new(...)
CODE:
RETVAL = new Line ();
// ST(0) is class name, ST(1) and ST(2) are endpoints
RETVAL->a.from_SV_check( ST(1) );
RETVAL->b.from_SV_check( ST(2) );
OUTPUT:
RETVAL
2013-07-16 15:13:01 +00:00
void
Line::rotate(angle, center_sv)
double angle;
SV* center_sv;
CODE:
Point center;
center.from_SV_check(center_sv);
THIS->rotate(angle, center);
2013-11-06 18:38:10 +00:00
bool
Line::coincides_with(line_sv)
SV* line_sv;
CODE:
Line line;
line.from_SV_check(line_sv);
RETVAL = THIS->coincides_with(line);
2013-11-06 18:38:10 +00:00
OUTPUT:
RETVAL
%}
};