%module{Slic3r::XS}; %{ #include #include "Line.hpp" %} %name{Slic3r::Line} class Line { ~Line(); Line* clone() %code{% const char* CLASS = "Slic3r::Line"; RETVAL = new Line(*THIS); %}; SV* arrayref() %code{% RETVAL = THIS->to_AV(); %}; SV* pp() %code{% RETVAL = THIS->to_SV_pureperl(); %}; Point* a() %code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->a); %}; Point* b() %code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->b); %}; void reverse(); void scale(double factor); void translate(double x, double y); double length(); Point* midpoint() %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->midpoint(); %}; Point* point_at(double distance) %code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->point_at(distance); %}; Polyline* as_polyline() %code{% const char* CLASS = "Slic3r::Polyline"; 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 void Line::rotate(angle, center_sv) double angle; SV* center_sv; CODE: Point center; center.from_SV_check(center_sv); THIS->rotate(angle, ¢er); bool Line::coincides_with(line_sv) SV* line_sv; CODE: Line line; line.from_SV_check(line_sv); RETVAL = THIS->coincides_with(&line); OUTPUT: RETVAL %} };