xref: /haiku/headers/libs/agg/agg_vcgen_contour.h (revision 39241fe22890fb958b6ba32d6ab9526da98be187)
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_basics.h"
20 #include "agg_vertex_sequence.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             add_point,
37             end_poly
38         };
39 
40     public:
41         typedef vertex_sequence<vertex_dist, 6> vertex_storage;
42 
43         vcgen_contour();
44 
45         void width(double w) { m_width = w * 0.5; }
46         void miter_limit(double ml) { m_miter_limit = ml; }
47         void miter_limit_theta(double t);
48         void auto_detect_orientation(bool v) { m_auto_detect = v; }
49 
50         double width() const { return m_width * 2.0; }
51         double miter_limit() const { return m_miter_limit; }
52         bool   auto_detect_orientation() const { return m_auto_detect; }
53 
54         // Generator interface
55         void remove_all();
56         void add_vertex(double x, double y, unsigned cmd);
57 
58         // Vertex Source Interface
59         void     rewind(unsigned id);
60         unsigned vertex(double* x, double* y);
61 
62     private:
63         vcgen_contour(const vcgen_contour&);
64         const vcgen_contour& operator = (const vcgen_contour&);
65 
66         bool calc_miter(const vertex_dist& v0,
67                         const vertex_dist& v1,
68                         const vertex_dist& v2);
69 
70         vertex_storage m_src_vertices;
71         double         m_width;
72         double         m_abs_width;
73         double         m_signed_width;
74         double         m_miter_limit;
75         status_e       m_status;
76         unsigned       m_src_vertex;
77         unsigned       m_closed;
78         unsigned       m_orientation;
79         bool           m_auto_detect;
80         double         m_x1;
81         double         m_y1;
82         double         m_x2;
83         double         m_y2;
84     };
85 
86 }
87 
88 #endif
89