PrusaSlicer-NonPlainar/xs/xsp/Point.xsp

148 lines
4.8 KiB
Text
Raw Normal View History

2013-07-06 15:26:32 +02:00
%module{Slic3r::XS};
%{
#include <xsinit.h>
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Polyline.hpp"
2013-07-06 15:26:32 +02:00
%}
2013-07-15 20:31:43 +02:00
%name{Slic3r::Point} class Point {
Point(int _x = 0, int _y = 0);
2013-07-07 16:51:02 +02:00
~Point();
Clone<Point> clone()
%code{% RETVAL=THIS; %};
2013-07-15 16:04:49 +02:00
void scale(double factor);
void translate(double x, double y);
SV* arrayref()
%code{% RETVAL = to_SV_pureperl(THIS); %};
2013-07-16 17:13:01 +02:00
SV* pp()
%code{% RETVAL = to_SV_pureperl(THIS); %};
int x()
2013-07-15 20:31:43 +02:00
%code{% RETVAL = THIS->x; %};
int y()
2013-07-15 20:31:43 +02:00
%code{% RETVAL = THIS->y; %};
void set_x(int val)
%code{% THIS->x = val; %};
void set_y(int val)
%code{% THIS->y = val; %};
int nearest_point_index(Points points);
Clone<Point> nearest_point(Points points)
%code{% Point p; THIS->nearest_point(points, &p); RETVAL = p; %};
double distance_to(Point* point)
%code{% RETVAL = THIS->distance_to(*point); %};
double distance_to_line(Line* line)
%code{% RETVAL = THIS->distance_to(*line); %};
double perp_distance_to_line(Line* line)
%code{% RETVAL = THIS->perp_distance_to(*line); %};
double ccw(Point* p1, Point* p2)
%code{% RETVAL = THIS->ccw(*p1, *p2); %};
2014-12-21 22:51:45 +01:00
double ccw_angle(Point* p1, Point* p2)
%code{% RETVAL = THIS->ccw_angle(*p1, *p2); %};
2014-05-21 20:08:21 +02:00
Clone<Point> projection_onto_polygon(Polygon* polygon)
%code{% RETVAL = new Point(THIS->projection_onto(*polygon)); %};
Clone<Point> projection_onto_polyline(Polyline* polyline)
%code{% RETVAL = new Point(THIS->projection_onto(*polyline)); %};
Clone<Point> projection_onto_line(Line* line)
%code{% RETVAL = new Point(THIS->projection_onto(*line)); %};
Clone<Point> negative()
%code{% RETVAL = new Point(THIS->negative()); %};
bool coincides_with_epsilon(Point* point)
%code{% RETVAL = THIS->coincides_with_epsilon(*point); %};
2016-11-16 22:09:00 +01:00
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld", THIS->x, THIS->y); RETVAL = buf; %};
2013-07-15 16:04:49 +02:00
2013-07-06 16:39:22 +02:00
%{
2013-07-15 16:04:49 +02:00
void
Point::rotate(angle, center_sv)
double angle;
SV* center_sv;
CODE:
Point center;
from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
2013-07-15 16:04:49 +02:00
bool
Point::coincides_with(point_sv)
SV* point_sv;
2013-07-06 16:39:22 +02:00
CODE:
2013-07-15 16:04:49 +02:00
Point point;
from_SV_check(point_sv, &point);
RETVAL = THIS->coincides_with(point);
2013-07-06 16:39:22 +02:00
OUTPUT:
RETVAL
%}
2013-07-15 16:04:49 +02:00
2013-07-06 15:26:32 +02:00
};
2014-01-07 12:48:09 +01:00
%name{Slic3r::Point3} class Point3 {
Point3(int _x = 0, int _y = 0, int _z = 0);
~Point3();
Clone<Point3> clone()
%code{% RETVAL = THIS; %};
int x()
%code{% RETVAL = THIS->x; %};
int y()
%code{% RETVAL = THIS->y; %};
int z()
%code{% RETVAL = THIS->z; %};
2016-11-16 22:09:00 +01:00
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", THIS->x, THIS->y, THIS->z); RETVAL = buf; %};
};
2014-04-28 01:13:50 +03:00
%name{Slic3r::Pointf} class Pointf {
Pointf(double _x = 0, double _y = 0);
~Pointf();
Clone<Pointf> clone()
%code{% RETVAL = THIS; %};
2014-08-03 00:20:55 +02:00
SV* arrayref()
%code{% RETVAL = to_SV_pureperl(THIS); %};
2014-08-03 00:20:55 +02:00
SV* pp()
%code{% RETVAL = to_SV_pureperl(THIS); %};
2014-04-28 01:13:50 +03:00
double x()
%code{% RETVAL = THIS->x; %};
double y()
%code{% RETVAL = THIS->y; %};
void set_x(double val)
%code{% THIS->x = val; %};
void set_y(double val)
%code{% THIS->y = val; %};
void translate(double x, double y);
2014-08-03 00:20:55 +02:00
void scale(double factor);
void rotate(double angle, Pointf* center)
%code{% THIS->rotate(angle, *center); %};
2014-12-15 01:28:11 +01:00
Clone<Pointf> negative()
%code{% RETVAL = THIS->negative(); %};
Clone<Pointf> vector_to(Pointf* point)
%code{% RETVAL = THIS->vector_to(*point); %};
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf", THIS->x, THIS->y); RETVAL = buf; %};
2014-04-28 01:13:50 +03:00
};
2014-01-07 12:48:09 +01:00
%name{Slic3r::Pointf3} class Pointf3 {
Pointf3(double _x = 0, double _y = 0, double _z = 0);
~Pointf3();
Clone<Pointf3> clone()
%code{% RETVAL = THIS; %};
2014-01-07 12:48:09 +01:00
double x()
%code{% RETVAL = THIS->x; %};
double y()
%code{% RETVAL = THIS->y; %};
double z()
%code{% RETVAL = THIS->z; %};
void set_x(double val)
%code{% THIS->x = val; %};
void set_y(double val)
%code{% THIS->y = val; %};
void set_z(double val)
%code{% THIS->z = val; %};
2014-12-12 23:02:28 +01:00
void translate(double x, double y, double z);
2014-12-16 01:12:37 +01:00
void scale(double factor);
double distance_to(Pointf3* point)
%code{% RETVAL = THIS->distance_to(*point); %};
Clone<Pointf3> negative()
%code{% RETVAL = THIS->negative(); %};
Clone<Pointf3> vector_to(Pointf3* point)
%code{% RETVAL = THIS->vector_to(*point); %};
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf", THIS->x, THIS->y, THIS->z); RETVAL = buf; %};
2014-01-07 12:48:09 +01:00
};