xref: /haiku/headers/libs/agg/agg_vcgen_contour.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.2
3 // Copyright (C) 2002-2004 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_CONTOUR_INCLUDED
17 #define AGG_VCGEN_CONTOUR_INCLUDED
18 
19 #include "agg_math_stroke.h"
20 #include "agg_vertex_iterator.h"
21 
22 namespace agg
23 {
24 
25     //----------------------------------------------------------vcgen_contour
26     //
27     // See Implementation agg_vcgen_contour.cpp
28     //
29     class vcgen_contour
30     {
31         enum status_e
32         {
33             initial,
34             ready,
35             outline,
36             out_vertices,
37             end_poly,
38             stop
39         };
40 
41     public:
42         typedef vertex_sequence<vertex_dist, 6> vertex_storage;
43         typedef pod_deque<point_type, 6>        coord_storage;
44 
45         vcgen_contour();
46 
47         void line_join(line_join_e lj) { m_line_join = lj; }
48         void inner_line_join(line_join_e lj) { m_inner_line_join = lj; }
49         void width(double w) { m_width = w * 0.5; }
50         void miter_limit(double ml) { m_miter_limit = ml; }
51         void miter_limit_theta(double t);
52         void inner_miter_limit(double ml) { m_inner_miter_limit = ml; }
53         void approximation_scale(double as) { m_approx_scale = as; }
54         void auto_detect_orientation(bool v) { m_auto_detect = v; }
55 
56         line_join_e line_join() const { return m_line_join; }
57         line_join_e inner_line_join() const { return m_inner_line_join; }
58         double width() const { return m_width * 2.0; }
59         double miter_limit() const { return m_miter_limit; }
60         double inner_miter_limit() const { return m_inner_miter_limit; }
61         double approximation_scale() const { return m_approx_scale; }
62         bool   auto_detect_orientation() const { return m_auto_detect; }
63 
64         // Generator interface
65         void remove_all();
66         void add_vertex(double x, double y, unsigned cmd);
67 
68         // Vertex Source Interface
69         void     rewind(unsigned id);
70         unsigned vertex(double* x, double* y);
71 
72     private:
73         vcgen_contour(const vcgen_contour&);
74         const vcgen_contour& operator = (const vcgen_contour&);
75 
76         vertex_storage m_src_vertices;
77         coord_storage  m_out_vertices;
78         double         m_width;
79         line_join_e    m_line_join;
80         line_join_e    m_inner_line_join;
81         double         m_approx_scale;
82         double         m_abs_width;
83         double         m_signed_width;
84         double         m_miter_limit;
85         double         m_inner_miter_limit;
86         status_e       m_status;
87         unsigned       m_src_vertex;
88         unsigned       m_out_vertex;
89         unsigned       m_closed;
90         unsigned       m_orientation;
91         bool           m_auto_detect;
92     };
93 
94 }
95 
96 #endif
97