~ubuntu-branches/ubuntu/wily/slic3r/wily-proposed

« back to all changes in this revision

Viewing changes to xs/xsp/Polygon.xsp

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module{Slic3r::XS};
 
2
 
 
3
%{
 
4
#include <myinit.h>
 
5
#include "BoundingBox.hpp"
 
6
#include "Polygon.hpp"
 
7
%}
 
8
 
 
9
%name{Slic3r::Polygon} class Polygon {
 
10
    ~Polygon();
 
11
    Clone<Polygon> clone()
 
12
        %code{% RETVAL = THIS; %};
 
13
    SV* arrayref()
 
14
        %code{% RETVAL = THIS->to_AV(); %};
 
15
    SV* pp()
 
16
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
 
17
    void scale(double factor);
 
18
    void translate(double x, double y);
 
19
    void reverse();
 
20
    Lines lines();
 
21
    Polyline* split_at_vertex(Point* point)
 
22
        %code{% RETVAL = new Polyline(); THIS->split_at_vertex(*point, RETVAL); %};
 
23
    Polyline* split_at_index(int index)
 
24
        %code{% RETVAL = new Polyline(); THIS->split_at_index(index, RETVAL); %};
 
25
    Polyline* split_at_first_point()
 
26
        %code{% RETVAL = new Polyline(); THIS->split_at_first_point(RETVAL); %};
 
27
    Points equally_spaced_points(double distance)
 
28
        %code{% THIS->equally_spaced_points(distance, &RETVAL); %};
 
29
    double length();
 
30
    double area();
 
31
    bool is_counter_clockwise();
 
32
    bool is_clockwise();
 
33
    bool make_counter_clockwise();
 
34
    bool make_clockwise();
 
35
    bool is_valid();
 
36
    Clone<Point> first_point();
 
37
    bool contains_point(Point* point)
 
38
        %code{% RETVAL = THIS->contains_point(*point); %};
 
39
    Polygons simplify(double tolerance);
 
40
    Polygons triangulate_convex()
 
41
        %code{% THIS->triangulate_convex(&RETVAL); %};
 
42
    Clone<Point> centroid();
 
43
    BoundingBox* bounding_box()
 
44
        %code{%
 
45
            RETVAL = new BoundingBox();
 
46
            THIS->bounding_box(RETVAL);
 
47
        %};
 
48
%{
 
49
 
 
50
Polygon*
 
51
Polygon::new(...)
 
52
    CODE:
 
53
        RETVAL = new Polygon ();
 
54
        // ST(0) is class name, ST(1) is first point
 
55
        RETVAL->points.resize(items-1);
 
56
        for (unsigned int i = 1; i < items; i++) {
 
57
            RETVAL->points[i-1].from_SV_check( ST(i) );
 
58
        }
 
59
    OUTPUT:
 
60
        RETVAL
 
61
 
 
62
void
 
63
Polygon::rotate(angle, center_sv)
 
64
    double  angle;
 
65
    SV*     center_sv;
 
66
    CODE:
 
67
        Point center;
 
68
        center.from_SV_check(center_sv);
 
69
        THIS->rotate(angle, center);
 
70
 
 
71
%}
 
72
};