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_VCGEN_INCLUDED
17 #define AGG_CONV_ADAPTOR_VCGEN_INCLUDED
19 #include "agg_basics.h"
23 //------------------------------------------------------------null_markers
27 void add_vertex(double, double, unsigned) {}
30 void rewind(unsigned) {}
31 unsigned vertex(double*, double*) { return path_cmd_stop
; }
35 //------------------------------------------------------conv_adaptor_vcgen
36 template<class VertexSource
,
38 class Markers
=null_markers
> class conv_adaptor_vcgen
48 conv_adaptor_vcgen(VertexSource
& source
) :
52 void attach(VertexSource
& source
) { m_source
= &source
; }
54 Generator
& generator() { return m_generator
; }
55 const Generator
& generator() const { return m_generator
; }
57 Markers
& markers() { return m_markers
; }
58 const Markers
& markers() const { return m_markers
; }
60 void rewind(unsigned path_id
)
62 m_source
->rewind(path_id
);
66 unsigned vertex(double* x
, double* y
);
70 conv_adaptor_vcgen(const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&);
71 const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&
72 operator = (const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&);
74 VertexSource
* m_source
;
75 Generator m_generator
;
87 //------------------------------------------------------------------------
88 template<class VertexSource
, class Generator
, class Markers
>
89 unsigned conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>::vertex(double* x
, double* y
)
91 unsigned cmd
= path_cmd_stop
;
98 m_markers
.remove_all();
99 m_last_cmd
= m_source
->vertex(&m_start_x
, &m_start_y
);
100 m_status
= accumulate
;
103 if(is_stop(m_last_cmd
)) return path_cmd_stop
;
105 m_generator
.remove_all();
106 m_generator
.add_vertex(m_start_x
, m_start_y
, path_cmd_move_to
);
107 m_markers
.add_vertex(m_start_x
, m_start_y
, path_cmd_move_to
);
111 cmd
= m_source
->vertex(x
, y
);
121 m_generator
.add_vertex(*x
, *y
, cmd
);
122 m_markers
.add_vertex(*x
, *y
, path_cmd_line_to
);
128 m_last_cmd
= path_cmd_stop
;
133 m_generator
.add_vertex(*x
, *y
, cmd
);
138 m_generator
.rewind(0);
142 cmd
= m_generator
.vertex(x
, y
);
145 m_status
= accumulate
;