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