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_ADAPTOR_VCGEN_INCLUDED
17 #define AGG_CONV_ADAPTOR_VCGEN_INCLUDED
19 #include "agg_basics.h"
20 #include "agg_vertex_iterator.h"
24 //------------------------------------------------------------null_markers
28 void add_vertex(double, double, unsigned) {}
31 void rewind(unsigned) {}
32 unsigned vertex(double*, double*) { return path_cmd_stop
; }
34 typedef null_markers source_type
;
35 typedef vertex_iterator
<source_type
> iterator
;
36 iterator
begin(unsigned id
) { return iterator(*this, id
); }
37 iterator
end() { return iterator(path_cmd_stop
); }
41 //------------------------------------------------------conv_adaptor_vcgen
42 template<class VertexSource
,
44 class Markers
=null_markers
> class conv_adaptor_vcgen
54 conv_adaptor_vcgen(VertexSource
& source
) :
59 void set_source(VertexSource
& source
) { m_source
= &source
; }
61 Generator
& generator() { return m_generator
; }
62 const Generator
& generator() const { return m_generator
; }
64 Markers
& markers() { return m_markers
; }
65 const Markers
& markers() const { return m_markers
; }
67 void rewind(unsigned id
)
73 unsigned vertex(double* x
, double* y
);
75 typedef conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
> source_type
;
76 typedef vertex_iterator
<source_type
> iterator
;
77 iterator
begin(unsigned id
) { return iterator(*this, id
); }
78 iterator
end() { return iterator(path_cmd_stop
); }
82 conv_adaptor_vcgen(const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&);
83 const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&
84 operator = (const conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>&);
86 VertexSource
* m_source
;
87 Generator m_generator
;
99 //------------------------------------------------------------------------
100 template<class VertexSource
, class Generator
, class Markers
>
101 unsigned conv_adaptor_vcgen
<VertexSource
, Generator
, Markers
>::vertex(double* x
, double* y
)
103 unsigned cmd
= path_cmd_stop
;
110 m_markers
.remove_all();
111 m_last_cmd
= m_source
->vertex(&m_start_x
, &m_start_y
);
112 m_status
= accumulate
;
115 if(is_stop(m_last_cmd
)) return path_cmd_stop
;
117 m_generator
.remove_all();
118 m_generator
.add_vertex(m_start_x
, m_start_y
, path_cmd_move_to
);
119 m_markers
.add_vertex(m_start_x
, m_start_y
, path_cmd_move_to
);
123 cmd
= m_source
->vertex(x
, y
);
133 m_generator
.add_vertex(*x
, *y
, cmd
);
134 m_markers
.add_vertex(*x
, *y
, path_cmd_line_to
);
140 m_last_cmd
= path_cmd_stop
;
145 m_generator
.add_vertex(*x
, *y
, cmd
);
150 m_generator
.rewind(0);
154 cmd
= m_generator
.vertex(x
, y
);
157 m_status
= accumulate
;