~ubuntu-branches/ubuntu/lucid/agg/lucid-proposed

« back to all changes in this revision

Viewing changes to include/agg_vpgen_clip_polyline.h

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2006-10-22 15:16:27 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 edgy)
  • Revision ID: james.westby@ubuntu.com-20061022151627-wx9inil9o7z40xwc
Tags: 2.4+20060719-3
upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//----------------------------------------------------------------------------
2
 
// Anti-Grain Geometry - Version 2.3
 
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
4
//
5
5
// Permission to copy, use, modify, sell and distribute this software 
32
32
            m_clip_box(0, 0, 1, 1),
33
33
            m_x1(0),
34
34
            m_y1(0),
35
 
            m_f1(0),
36
 
            m_x2(0),
37
 
            m_y2(0),
38
 
            m_f2(0),
39
35
            m_num_vertices(0),
40
 
            m_vertex(0)
 
36
            m_vertex(0),
 
37
            m_move_to(false)
41
38
        {
42
39
        }
43
40
 
50
47
            m_clip_box.normalize();
51
48
        }
52
49
 
53
 
 
54
50
        double x1() const { return m_clip_box.x1; }
55
51
        double y1() const { return m_clip_box.y1; }
56
52
        double x2() const { return m_clip_box.x2; }
65
61
        unsigned vertex(double* x, double* y);
66
62
 
67
63
    private:
68
 
        enum clipping_flags_def
69
 
        {
70
 
            clip_x1 = 1,
71
 
            clip_x2 = 2,
72
 
            clip_y1 = 4,
73
 
            clip_y2 = 8
74
 
        };
75
 
 
76
 
        // Determine the clipping code of the vertex according to the 
77
 
        // Cyrus-Beck line clipping algorithm
78
 
        //--------------------------------------------------------------------
79
 
        unsigned clipping_flags_x(double x)
80
 
        {
81
 
            unsigned f = 0;
82
 
            if(x < m_clip_box.x1) f |= clip_x1;
83
 
            if(x > m_clip_box.x2) f |= clip_x2;
84
 
            return f;
85
 
        }
86
 
 
87
 
        unsigned clipping_flags_y(double y)
88
 
        {
89
 
            unsigned f = 0;
90
 
            if(y < m_clip_box.y1) f |= clip_y1;
91
 
            if(y > m_clip_box.y2) f |= clip_y2;
92
 
            return f;
93
 
        }
94
 
 
95
 
        unsigned clipping_flags(double x, double y)
96
 
        {
97
 
            return clipping_flags_x(x) | clipping_flags_y(y);
98
 
        }
99
 
 
100
 
        bool move_point(double& x, double& y, unsigned& flags);
101
 
        void clip_line_segment();
102
 
 
103
 
    private:
104
64
        rect_d        m_clip_box;
105
65
        double        m_x1;
106
66
        double        m_y1;
107
 
        unsigned      m_f1;
108
 
        double        m_x2;
109
 
        double        m_y2;
110
 
        unsigned      m_f2;
111
67
        double        m_x[2];
112
68
        double        m_y[2];
113
69
        unsigned      m_cmd[2];
114
70
        unsigned      m_num_vertices;
115
71
        unsigned      m_vertex;
 
72
        bool          m_move_to;
116
73
    };
117
74
 
118
75
}