~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to xs/src/Line.hpp

  • 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
#ifndef slic3r_Line_hpp_
 
2
#define slic3r_Line_hpp_
 
3
 
 
4
#include <myinit.h>
 
5
#include "Point.hpp"
 
6
 
 
7
namespace Slic3r {
 
8
 
 
9
class Line;
 
10
class Polyline;
 
11
 
 
12
class Line
 
13
{
 
14
    public:
 
15
    Point a;
 
16
    Point b;
 
17
    Line() {};
 
18
    explicit Line(Point _a, Point _b): a(_a), b(_b) {};
 
19
    std::string wkt() const;
 
20
    operator Polyline() const;
 
21
    void scale(double factor);
 
22
    void translate(double x, double y);
 
23
    void rotate(double angle, const Point &center);
 
24
    void reverse();
 
25
    double length() const;
 
26
    Point* midpoint() const;
 
27
    void point_at(double distance, Point* point) const;
 
28
    Point point_at(double distance) const;
 
29
    bool coincides_with(const Line &line) const;
 
30
    double distance_to(const Point &point) const;
 
31
    bool parallel_to(double angle) const;
 
32
    bool parallel_to(const Line &line) const;
 
33
    double atan2_() const;
 
34
    double direction() const;
 
35
    Vector vector() const;
 
36
    
 
37
    #ifdef SLIC3RXS
 
38
    void from_SV(SV* line_sv);
 
39
    void from_SV_check(SV* line_sv);
 
40
    SV* to_AV();
 
41
    SV* to_SV_pureperl() const;
 
42
    #endif
 
43
};
 
44
 
 
45
typedef std::vector<Line> Lines;
 
46
 
 
47
}
 
48
 
 
49
// start Boost
 
50
#include <boost/polygon/polygon.hpp>
 
51
namespace boost { namespace polygon {
 
52
    template <>
 
53
    struct geometry_concept<Line> { typedef segment_concept type; };
 
54
 
 
55
    template <>
 
56
    struct segment_traits<Line> {
 
57
        typedef coord_t coordinate_type;
 
58
        typedef Point point_type;
 
59
    
 
60
        static inline point_type get(const Line& line, direction_1d dir) {
 
61
            return dir.to_int() ? line.b : line.a;
 
62
        }
 
63
    };
 
64
} }
 
65
// end Boost
 
66
 
 
67
#endif