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"
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
#include "libslic3r/Line.hpp"
|
2014-08-03 17:42:29 +00:00
|
|
|
#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; %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
void scale(double factor)
|
|
|
|
%code{% *THIS *= factor; %};
|
|
|
|
void translate(double x, double y)
|
|
|
|
%code{% *THIS += Point(x, y); %};
|
2013-07-15 14:04:49 +00:00
|
|
|
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-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(0); %};
|
2018-02-12 17:16:10 +00:00
|
|
|
int y()
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(1); %};
|
2018-02-12 17:16:10 +00:00
|
|
|
void set_x(int val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(0) = val; %};
|
2018-02-12 17:16:10 +00:00
|
|
|
void set_y(int val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(1) = 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)
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
%code{% RETVAL = (*point - *THIS).cast<double>().norm(); %};
|
2014-04-24 14:40:10 +00:00
|
|
|
double distance_to_line(Line* line)
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
%code{% RETVAL = line->distance_to(*THIS); %};
|
2015-01-03 14:03:53 +00:00
|
|
|
double perp_distance_to_line(Line* line)
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
%code{% RETVAL = line->perp_distance_to(*THIS); %};
|
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); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
Point* projection_onto_polygon(Polygon* polygon)
|
2014-05-21 18:08:21 +00:00
|
|
|
%code{% RETVAL = new Point(THIS->projection_onto(*polygon)); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
Point* projection_onto_polyline(Polyline* polyline)
|
2014-05-21 18:08:21 +00:00
|
|
|
%code{% RETVAL = new Point(THIS->projection_onto(*polyline)); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
Point* projection_onto_line(Line* line)
|
2014-05-21 18:08:21 +00:00
|
|
|
%code{% RETVAL = new Point(THIS->projection_onto(*line)); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
Point* negative()
|
|
|
|
%code{% RETVAL = new Point(- *THIS); %};
|
2018-08-17 13:53:43 +00:00
|
|
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld", (*THIS)(0), (*THIS)(1)); 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
|
|
|
|
2018-08-21 19:05:24 +00:00
|
|
|
%name{Slic3r::Pointf} class Vec2d {
|
|
|
|
Vec2d(double _x = 0, double _y = 0);
|
|
|
|
~Vec2d();
|
|
|
|
Clone<Vec2d> clone()
|
2014-04-27 22:13:50 +00:00
|
|
|
%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-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(0); %};
|
2014-04-27 22:13:50 +00:00
|
|
|
double y()
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(1); %};
|
2014-12-13 19:41:03 +00:00
|
|
|
void set_x(double val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(0) = val; %};
|
2014-12-13 19:41:03 +00:00
|
|
|
void set_y(double val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(1) = val; %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
void translate(double x, double y)
|
2018-08-21 19:05:24 +00:00
|
|
|
%code{% *THIS += Vec2d(x, y); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
void scale(double factor)
|
|
|
|
%code{% *THIS *= factor; %};
|
2018-08-21 19:05:24 +00:00
|
|
|
void rotate(double angle, Vec2d* center)
|
2018-08-21 18:34:45 +00:00
|
|
|
%code{% *THIS = Eigen::Translation2d(*center) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- *center) * Eigen::Vector2d((*THIS)(0), (*THIS)(1)); %};
|
2018-08-21 19:05:24 +00:00
|
|
|
Vec2d* negative()
|
|
|
|
%code{% RETVAL = new Vec2d(- *THIS); %};
|
|
|
|
Vec2d* vector_to(Vec2d* point)
|
|
|
|
%code{% RETVAL = new Vec2d(*point - *THIS); %};
|
2018-08-17 13:53:43 +00:00
|
|
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf", (*THIS)(0), (*THIS)(1)); RETVAL = buf; %};
|
2014-04-27 22:13:50 +00:00
|
|
|
};
|
|
|
|
|
2018-08-21 15:43:05 +00:00
|
|
|
%name{Slic3r::Pointf3} class Vec3d {
|
|
|
|
Vec3d(double _x = 0, double _y = 0, double _z = 0);
|
|
|
|
~Vec3d();
|
|
|
|
Clone<Vec3d> clone()
|
2014-04-27 17:18:53 +00:00
|
|
|
%code{% RETVAL = THIS; %};
|
2014-01-07 11:48:09 +00:00
|
|
|
double x()
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(0); %};
|
2014-01-07 11:48:09 +00:00
|
|
|
double y()
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(1); %};
|
2014-01-07 11:48:09 +00:00
|
|
|
double z()
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% RETVAL = (*THIS)(2); %};
|
2014-10-21 18:16:45 +00:00
|
|
|
void set_x(double val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(0) = val; %};
|
2014-10-21 18:16:45 +00:00
|
|
|
void set_y(double val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(1) = val; %};
|
2014-10-21 18:16:45 +00:00
|
|
|
void set_z(double val)
|
2018-08-17 13:53:43 +00:00
|
|
|
%code{% (*THIS)(2) = val; %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
void translate(double x, double y, double z)
|
2018-08-21 15:43:05 +00:00
|
|
|
%code{% *THIS += Vec3d(x, y, z); %};
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
void scale(double factor)
|
|
|
|
%code{% *THIS *= factor; %};
|
2018-08-21 15:43:05 +00:00
|
|
|
double distance_to(Vec3d* point)
|
Removed Point::scale(),translate(),coincides_with(),distance_to(),
distance_to_squared(),perp_distance_to(),negative(),vector_to(),
translate(), distance_to() etc,
replaced with the Eigen equivalents.
2018-08-17 12:14:24 +00:00
|
|
|
%code{% RETVAL = (*point - *THIS).norm(); %};
|
2018-08-21 15:43:05 +00:00
|
|
|
Vec3d* negative()
|
|
|
|
%code{% RETVAL = new Vec3d(- *THIS); %};
|
|
|
|
Vec3d* vector_to(Vec3d* point)
|
|
|
|
%code{% RETVAL = new Vec3d(*point - *THIS); %};
|
2018-08-17 13:53:43 +00:00
|
|
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf", (*THIS)(0), (*THIS)(1), (*THIS)(2)); RETVAL = buf; %};
|
2014-01-07 11:48:09 +00:00
|
|
|
};
|