xref: /haiku/headers/libs/agg/agg_conv_unclose_polygon.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_CONV_UNCLOSE_POLYGON_INCLUDED
17 #define AGG_CONV_UNCLOSE_POLYGON_INCLUDED
18 
19 #include "agg_basics.h"
20 #include "agg_vertex_iterator.h"
21 
22 namespace agg
23 {
24     //====================================================conv_unclose_polygon
25     template<class VertexSource> class conv_unclose_polygon
26     {
27     public:
28         conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {}
29 
30         void set_source(VertexSource& source) { m_source = &source; }
31 
32         void rewind(unsigned path_id)
33         {
34             m_source->rewind(path_id);
35         }
36 
37         unsigned vertex(double* x, double* y)
38         {
39             unsigned cmd = m_source->vertex(x, y);
40             if(is_end_poly(cmd)) cmd &= ~path_flags_close;
41             return cmd;
42         }
43 
44         typedef conv_unclose_polygon<VertexSource> source_type;
45         typedef vertex_iterator<source_type> iterator;
46         iterator begin(unsigned id) { return iterator(*this, id); }
47         iterator end() { return iterator(path_cmd_stop); }
48 
49     private:
50         conv_unclose_polygon(const conv_unclose_polygon<VertexSource>&);
51         const conv_unclose_polygon<VertexSource>&
52             operator = (const conv_unclose_polygon<VertexSource>&);
53 
54         VertexSource* m_source;
55     };
56 
57 }
58 
59 #endif
60