mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	
		
			
				
	
	
		
			93 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			93 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
%module{Slic3r::XS};
 | 
						|
 | 
						|
%{
 | 
						|
#include <xsinit.h>
 | 
						|
#include "libslic3r/Line.hpp"
 | 
						|
#include "libslic3r/Polyline.hpp"
 | 
						|
%}
 | 
						|
 | 
						|
%name{Slic3r::Line} class Line {
 | 
						|
    ~Line();
 | 
						|
    Clone<Line> clone()
 | 
						|
        %code{% RETVAL = THIS; %};
 | 
						|
    SV* arrayref()
 | 
						|
        %code{% RETVAL = to_AV(THIS); %};
 | 
						|
    SV* pp()
 | 
						|
        %code{% RETVAL = to_SV_pureperl(THIS); %};
 | 
						|
    Ref<Point> a()
 | 
						|
        %code{% RETVAL=&THIS->a; %};
 | 
						|
    Ref<Point> b()
 | 
						|
        %code{% RETVAL=&THIS->b; %};
 | 
						|
    void reverse();
 | 
						|
    void scale(double factor);
 | 
						|
    void translate(double x, double y);
 | 
						|
    double length();
 | 
						|
    double atan2_();
 | 
						|
    double orientation();
 | 
						|
    double direction();
 | 
						|
    bool parallel_to(double angle);
 | 
						|
    bool parallel_to_line(Line* line)
 | 
						|
        %code{% RETVAL = THIS->parallel_to(*line); %};
 | 
						|
    Clone<Point> midpoint();
 | 
						|
    Clone<Point> point_at(double distance);
 | 
						|
    Clone<Point> intersection_infinite(Line* other)
 | 
						|
        %code{%
 | 
						|
            Point p;
 | 
						|
            bool res = THIS->intersection_infinite(*other, &p);
 | 
						|
            if (!res) CONFESS("Intersection failed");
 | 
						|
            RETVAL = p;
 | 
						|
        %};
 | 
						|
    Clone<Polyline> as_polyline()
 | 
						|
        %code{% RETVAL = Polyline(*THIS); %};
 | 
						|
    Clone<Point> normal();
 | 
						|
    Clone<Point> vector();
 | 
						|
    double ccw(Point* point)
 | 
						|
        %code{% RETVAL = THIS->ccw(*point); %};
 | 
						|
%{
 | 
						|
 | 
						|
Line*
 | 
						|
Line::new(...)
 | 
						|
    CODE:
 | 
						|
        RETVAL = new Line ();
 | 
						|
        // ST(0) is class name, ST(1) and ST(2) are endpoints
 | 
						|
        from_SV_check(ST(1), &RETVAL->a);
 | 
						|
        from_SV_check(ST(2), &RETVAL->b);
 | 
						|
    OUTPUT:
 | 
						|
        RETVAL
 | 
						|
 | 
						|
void
 | 
						|
Line::rotate(angle, center_sv)
 | 
						|
    double  angle;
 | 
						|
    SV*     center_sv;
 | 
						|
    CODE:
 | 
						|
        Point center;
 | 
						|
        from_SV_check(center_sv, ¢er);
 | 
						|
        THIS->rotate(angle, center);
 | 
						|
 | 
						|
bool
 | 
						|
Line::coincides_with(line_sv)
 | 
						|
    SV*     line_sv;
 | 
						|
    CODE:
 | 
						|
        Line line;
 | 
						|
        from_SV_check(line_sv, &line);
 | 
						|
        RETVAL = THIS->coincides_with(line);
 | 
						|
    OUTPUT:
 | 
						|
        RETVAL
 | 
						|
 | 
						|
%}
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
%name{Slic3r::Linef3} class Linef3 {
 | 
						|
    Linef3(Pointf3* a, Pointf3* b)
 | 
						|
        %code{% RETVAL = new Linef3(*a, *b); %};
 | 
						|
    ~Linef3();
 | 
						|
    Clone<Linef3> clone()
 | 
						|
        %code{% RETVAL = THIS; %};
 | 
						|
    Ref<Pointf3> a()
 | 
						|
        %code{% RETVAL = &THIS->a; %};
 | 
						|
    Ref<Pointf3> b()
 | 
						|
        %code{% RETVAL = &THIS->b; %};
 | 
						|
    Clone<Pointf3> intersect_plane(double z);
 | 
						|
    void scale(double factor);
 | 
						|
};
 |