1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
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.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 #ifndef AGG_CONV_CLOSE_POLYGON_INCLUDED
17 #define AGG_CONV_CLOSE_POLYGON_INCLUDED
19 #include "agg_basics.h"
20 #include "agg_vertex_iterator.h"
25 //======================================================conv_close_polygon
26 template<class VertexSource
> class conv_close_polygon
29 conv_close_polygon(VertexSource
& vs
) : m_source(&vs
) {}
31 void set_source(VertexSource
& source
) { m_source
= &source
; }
33 void rewind(unsigned path_id
);
34 unsigned vertex(double* x
, double* y
);
36 typedef conv_close_polygon
<VertexSource
> source_type
;
37 typedef vertex_iterator
<source_type
> iterator
;
38 iterator
begin(unsigned id
) { return iterator(*this, id
); }
39 iterator
end() { return iterator(path_cmd_stop
); }
42 conv_close_polygon(const conv_close_polygon
<VertexSource
>&);
43 const conv_close_polygon
<VertexSource
>&
44 operator = (const conv_close_polygon
<VertexSource
>&);
46 VertexSource
* m_source
;
56 //------------------------------------------------------------------------
57 template<class VertexSource
>
58 void conv_close_polygon
<VertexSource
>::rewind(unsigned path_id
)
60 m_source
->rewind(path_id
);
67 //------------------------------------------------------------------------
68 template<class VertexSource
>
69 unsigned conv_close_polygon
<VertexSource
>::vertex(double* x
, double* y
)
71 unsigned cmd
= path_cmd_stop
;
78 cmd
= m_cmd
[m_vertex
];
83 cmd
= m_source
->vertex(x
, y
);
87 cmd
|= path_flags_close
;
95 m_cmd
[0] = path_cmd_end_poly
| path_flags_close
;
96 m_cmd
[1] = path_cmd_stop
;
110 m_cmd
[0] = path_cmd_end_poly
| path_flags_close
;