1//----------------------------------------------------------------------------
2// Anti-Grain Geometry - Version 2.4
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_VCGEN_SMOOTH_POLY1_INCLUDED
17#define AGG_VCGEN_SMOOTH_POLY1_INCLUDED
18
19#include "agg_basics.h"
20#include "agg_vertex_sequence.h"
21
22
23namespace agg
24{
25
26    //======================================================vcgen_smooth_poly1
27    //
28    // See Implementation agg_vcgen_smooth_poly1.cpp
29    // Smooth polygon generator
30    //
31    //------------------------------------------------------------------------
32    class vcgen_smooth_poly1
33    {
34        enum status_e
35        {
36            initial,
37            ready,
38            polygon,
39            ctrl_b,
40            ctrl_e,
41            ctrl1,
42            ctrl2,
43            end_poly,
44            stop
45        };
46
47    public:
48        typedef vertex_sequence<vertex_dist, 6> vertex_storage;
49
50        vcgen_smooth_poly1();
51
52        void   smooth_value(double v) { m_smooth_value = v * 0.5; }
53        double smooth_value() const { return m_smooth_value * 2.0; }
54
55        // Vertex Generator Interface
56        void remove_all();
57        void add_vertex(double x, double y, unsigned cmd);
58
59        // Vertex Source Interface
60        void     rewind(unsigned path_id);
61        unsigned vertex(double* x, double* y);
62
63    private:
64        vcgen_smooth_poly1(const vcgen_smooth_poly1&);
65        const vcgen_smooth_poly1& operator = (const vcgen_smooth_poly1&);
66
67        void calculate(const vertex_dist& v0,
68                       const vertex_dist& v1,
69                       const vertex_dist& v2,
70                       const vertex_dist& v3);
71
72        vertex_storage m_src_vertices;
73        double         m_smooth_value;
74        unsigned       m_closed;
75        status_e       m_status;
76        unsigned       m_src_vertex;
77        double         m_ctrl1_x;
78        double         m_ctrl1_y;
79        double         m_ctrl2_x;
80        double         m_ctrl2_y;
81    };
82
83}
84
85
86#endif
87
88