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

« back to all changes in this revision

Viewing changes to include/agg_trans_double_path.h

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2005-11-29 02:02:41 UTC
  • Revision ID: james.westby@ubuntu.com-20051129020241-pmlxls0x6j2qv3nm
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//----------------------------------------------------------------------------
 
2
// Anti-Grain Geometry - Version 2.3
 
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 
4
//
 
5
// Permission to copy, use, modify, sell and distribute this software 
 
6
// is granted provided this copyright notice appears in all copies. 
 
7
// This software is provided "as is" without express or implied
 
8
// warranty, and with no claim as to its suitability for any purpose.
 
9
//
 
10
//----------------------------------------------------------------------------
 
11
// Contact: mcseem@antigrain.com
 
12
//          mcseemagg@yahoo.com
 
13
//          http://www.antigrain.com
 
14
//----------------------------------------------------------------------------
 
15
 
 
16
#ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED
 
17
#define AGG_TRANS_DOUBLE_PATH_INCLUDED
 
18
 
 
19
#include "agg_basics.h"
 
20
#include "agg_vertex_sequence.h"
 
21
 
 
22
namespace agg
 
23
{
 
24
    
 
25
    // See also: agg_trans_double_path.cpp
 
26
    //
 
27
    //-------------------------------------------------------trans_double_path
 
28
    class trans_double_path
 
29
    {
 
30
        enum status_e
 
31
        {
 
32
            initial,
 
33
            making_path,
 
34
            ready
 
35
        };
 
36
 
 
37
    public:
 
38
        typedef vertex_sequence<vertex_dist, 6> vertex_storage;
 
39
 
 
40
        trans_double_path();
 
41
 
 
42
        //--------------------------------------------------------------------
 
43
        void   base_length(double v)  { m_base_length = v; }
 
44
        double base_length() const { return m_base_length; }
 
45
 
 
46
        //--------------------------------------------------------------------
 
47
        void   base_height(double v)  { m_base_height = v; }
 
48
        double base_height() const { return m_base_height; }
 
49
 
 
50
        //--------------------------------------------------------------------
 
51
        void preserve_x_scale(bool f) { m_preserve_x_scale = f;    }
 
52
        bool preserve_x_scale() const { return m_preserve_x_scale; }
 
53
 
 
54
        //--------------------------------------------------------------------
 
55
        void reset();
 
56
        void move_to1(double x, double y);
 
57
        void line_to1(double x, double y);
 
58
        void move_to2(double x, double y);
 
59
        void line_to2(double x, double y);
 
60
        void finalize_paths();
 
61
 
 
62
        //--------------------------------------------------------------------
 
63
        template<class VertexSource1, class VertexSource2> 
 
64
        void add_paths(VertexSource1& vs1, VertexSource2& vs2, 
 
65
                       unsigned path1_id=0, unsigned path2_id=0)
 
66
        {
 
67
            double x;
 
68
            double y;
 
69
 
 
70
            unsigned cmd;
 
71
 
 
72
            vs1.rewind(path1_id);
 
73
            while(!is_stop(cmd = vs1.vertex(&x, &y)))
 
74
            {
 
75
                if(is_move_to(cmd)) 
 
76
                {
 
77
                    move_to1(x, y);
 
78
                }
 
79
                else 
 
80
                {
 
81
                    if(is_vertex(cmd))
 
82
                    {
 
83
                        line_to1(x, y);
 
84
                    }
 
85
                }
 
86
            }
 
87
 
 
88
            vs2.rewind(path2_id);
 
89
            while(!is_stop(cmd = vs2.vertex(&x, &y)))
 
90
            {
 
91
                if(is_move_to(cmd)) 
 
92
                {
 
93
                    move_to2(x, y);
 
94
                }
 
95
                else 
 
96
                {
 
97
                    if(is_vertex(cmd))
 
98
                    {
 
99
                        line_to2(x, y);
 
100
                    }
 
101
                }
 
102
            }
 
103
            finalize_paths();
 
104
        }
 
105
 
 
106
        //--------------------------------------------------------------------
 
107
        double total_length1() const;
 
108
        double total_length2() const;
 
109
        void transform(double *x, double *y) const;
 
110
 
 
111
    private:
 
112
        double finalize_path(vertex_storage& vertices);
 
113
        void transform1(const vertex_storage& vertices, 
 
114
                        double kindex, double kx,
 
115
                        double *x, double* y) const;
 
116
 
 
117
        vertex_storage m_src_vertices1;
 
118
        vertex_storage m_src_vertices2;
 
119
        double         m_base_length;
 
120
        double         m_base_height;
 
121
        double         m_kindex1;
 
122
        double         m_kindex2;
 
123
        status_e       m_status1;
 
124
        status_e       m_status2;
 
125
        bool           m_preserve_x_scale;
 
126
    };
 
127
 
 
128
}
 
129
 
 
130
 
 
131
#endif