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 //----------------------------------------------------------------------------
18 //----------------------------------------------------------------------------
19 #ifndef AGG_CONV_MARKER_INCLUDED
20 #define AGG_CONV_MARKER_INCLUDED
22 #include "agg_basics.h"
23 #include "agg_trans_affine.h"
24 #include "agg_vertex_iterator.h"
28 //-------------------------------------------------------------conv_marker
29 template<class MarkerLocator
, class MarkerShapes
>
33 conv_marker(MarkerLocator
& ml
, MarkerShapes
& ms
);
35 trans_affine
& transform() { return m_transform
; }
36 const trans_affine
& transform() const { return m_transform
; }
38 void rewind(unsigned id
);
39 unsigned vertex(double* x
, double* y
);
41 typedef conv_marker
<MarkerLocator
, MarkerShapes
> source_type
;
42 typedef vertex_iterator
<source_type
> iterator
;
43 iterator
begin(unsigned id
) { return iterator(*this, id
); }
44 iterator
end() { return iterator(path_cmd_stop
); }
47 conv_marker(const conv_marker
<MarkerLocator
, MarkerShapes
>&);
48 const conv_marker
<MarkerLocator
, MarkerShapes
>&
49 operator = (const conv_marker
<MarkerLocator
, MarkerShapes
>&);
59 MarkerLocator
* m_marker_locator
;
60 MarkerShapes
* m_marker_shapes
;
61 trans_affine m_transform
;
65 unsigned m_num_markers
;
69 //------------------------------------------------------------------------
70 template<class MarkerLocator
, class MarkerShapes
>
71 conv_marker
<MarkerLocator
, MarkerShapes
>::conv_marker(MarkerLocator
& ml
, MarkerShapes
& ms
) :
72 m_marker_locator(&ml
),
81 //------------------------------------------------------------------------
82 template<class MarkerLocator
, class MarkerShapes
>
83 void conv_marker
<MarkerLocator
, MarkerShapes
>::rewind(unsigned)
91 //------------------------------------------------------------------------
92 template<class MarkerLocator
, class MarkerShapes
>
93 unsigned conv_marker
<MarkerLocator
, MarkerShapes
>::vertex(double* x
, double* y
)
95 unsigned cmd
= path_cmd_move_to
;
96 double x1
, y1
, x2
, y2
;
103 if(m_num_markers
== 0)
108 m_marker_locator
->rewind(m_marker
);
114 if(is_stop(m_marker_locator
->vertex(&x1
, &y1
)))
119 if(is_stop(m_marker_locator
->vertex(&x2
, &y2
)))
126 m_mtx
*= trans_affine_rotation(atan2(y2
- y1
, x2
- x1
));
127 m_mtx
*= trans_affine_translation(x1
, y1
);
128 m_marker_shapes
->rewind(m_marker
- 1);
132 cmd
= m_marker_shapes
->vertex(x
, y
);
135 cmd
= path_cmd_move_to
;
139 m_mtx
.transform(x
, y
);