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_VCGEN_VERTEX_SEQUENCE_INCLUDED
17 #define AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED
19 #include "agg_basics.h"
20 #include "agg_vertex_sequence.h"
21 #include "agg_shorten_path.h"
26 //===================================================vcgen_vertex_sequence
27 class vcgen_vertex_sequence
30 typedef vertex_dist_cmd vertex_type
;
31 typedef vertex_sequence
<vertex_type
, 6> vertex_storage
;
33 vcgen_vertex_sequence() :
41 // Vertex Generator Interface
43 void add_vertex(double x
, double y
, unsigned cmd
);
45 // Vertex Source Interface
46 void rewind(unsigned path_id
);
47 unsigned vertex(double* x
, double* y
);
49 void shorten(double s
) { m_shorten
= s
; }
50 double shorten() const { return m_shorten
; }
53 vcgen_vertex_sequence(const vcgen_vertex_sequence
&);
54 const vcgen_vertex_sequence
& operator = (const vcgen_vertex_sequence
&);
56 vertex_storage m_src_vertices
;
58 unsigned m_cur_vertex
;
64 //------------------------------------------------------------------------
65 inline void vcgen_vertex_sequence::remove_all()
68 m_src_vertices
.remove_all();
73 //------------------------------------------------------------------------
74 inline void vcgen_vertex_sequence::add_vertex(double x
, double y
, unsigned cmd
)
79 m_src_vertices
.modify_last(vertex_dist_cmd(x
, y
, cmd
));
85 m_src_vertices
.add(vertex_dist_cmd(x
, y
, cmd
));
89 m_flags
= cmd
& path_flags_mask
;
95 //------------------------------------------------------------------------
96 inline void vcgen_vertex_sequence::rewind(unsigned)
100 m_src_vertices
.close(is_closed(m_flags
));
101 shorten_path(m_src_vertices
, m_shorten
, get_close_flag(m_flags
));
107 //------------------------------------------------------------------------
108 inline unsigned vcgen_vertex_sequence::vertex(double* x
, double* y
)
115 if(m_cur_vertex
== m_src_vertices
.size())
118 return path_cmd_end_poly
| m_flags
;
121 if(m_cur_vertex
> m_src_vertices
.size())
123 return path_cmd_stop
;
126 vertex_type
& v
= m_src_vertices
[m_cur_vertex
++];