1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
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_ADAPTOR_VPGEN_INCLUDED
17 #define AGG_CONV_ADAPTOR_VPGEN_INCLUDED
19 #include "agg_basics.h"
24 //======================================================conv_adaptor_vpgen
25 template<class VertexSource
, class VPGen
> class conv_adaptor_vpgen
28 conv_adaptor_vpgen(VertexSource
& source
) : m_source(&source
) {}
29 void attach(VertexSource
& source
) { m_source
= &source
; }
31 VPGen
& vpgen() { return m_vpgen
; }
32 const VPGen
& vpgen() const { return m_vpgen
; }
34 void rewind(unsigned path_id
);
35 unsigned vertex(double* x
, double* y
);
38 conv_adaptor_vpgen(const conv_adaptor_vpgen
<VertexSource
, VPGen
>&);
39 const conv_adaptor_vpgen
<VertexSource
, VPGen
>&
40 operator = (const conv_adaptor_vpgen
<VertexSource
, VPGen
>&);
42 VertexSource
* m_source
;
46 unsigned m_poly_flags
;
52 //------------------------------------------------------------------------
53 template<class VertexSource
, class VPGen
>
54 void conv_adaptor_vpgen
<VertexSource
, VPGen
>::rewind(unsigned path_id
)
56 m_source
->rewind(path_id
);
65 //------------------------------------------------------------------------
66 template<class VertexSource
, class VPGen
>
67 unsigned conv_adaptor_vpgen
<VertexSource
, VPGen
>::vertex(double* x
, double* y
)
69 unsigned cmd
= path_cmd_stop
;
72 cmd
= m_vpgen
.vertex(x
, y
);
73 if(!is_stop(cmd
)) break;
75 if(m_poly_flags
&& !m_vpgen
.auto_unclose())
91 m_vpgen
.move_to(m_start_x
, m_start_y
);
97 cmd
= m_source
->vertex(&tx
, &ty
);
102 if(m_vpgen
.auto_close() && m_vertices
> 2)
104 m_vpgen
.line_to(m_start_x
, m_start_y
);
105 m_poly_flags
= path_cmd_end_poly
| path_flags_close
;
111 m_vpgen
.move_to(tx
, ty
);
118 m_vpgen
.line_to(tx
, ty
);
127 if(is_closed(cmd
) || m_vpgen
.auto_close())
129 if(m_vpgen
.auto_close()) m_poly_flags
|= path_flags_close
;
132 m_vpgen
.line_to(m_start_x
, m_start_y
);
140 if(m_vpgen
.auto_close() && m_vertices
> 2)
142 m_vpgen
.line_to(m_start_x
, m_start_y
);
143 m_poly_flags
= path_cmd_end_poly
| path_flags_close
;