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 //----------------------------------------------------------------------------
18 //----------------------------------------------------------------------------
19 #ifndef AGG_CONV_MARKER_INCLUDED
20 #define AGG_CONV_MARKER_INCLUDED
22 #include "agg_basics.h"
23 #include "agg_trans_affine.h"
27 //-------------------------------------------------------------conv_marker
28 template<class MarkerLocator
, class MarkerShapes
>
32 conv_marker(MarkerLocator
& ml
, MarkerShapes
& ms
);
34 trans_affine
& transform() { return m_transform
; }
35 const trans_affine
& transform() const { return m_transform
; }
37 void rewind(unsigned path_id
);
38 unsigned vertex(double* x
, double* y
);
41 conv_marker(const conv_marker
<MarkerLocator
, MarkerShapes
>&);
42 const conv_marker
<MarkerLocator
, MarkerShapes
>&
43 operator = (const conv_marker
<MarkerLocator
, MarkerShapes
>&);
53 MarkerLocator
* m_marker_locator
;
54 MarkerShapes
* m_marker_shapes
;
55 trans_affine m_transform
;
59 unsigned m_num_markers
;
63 //------------------------------------------------------------------------
64 template<class MarkerLocator
, class MarkerShapes
>
65 conv_marker
<MarkerLocator
, MarkerShapes
>::conv_marker(MarkerLocator
& ml
, MarkerShapes
& ms
) :
66 m_marker_locator(&ml
),
75 //------------------------------------------------------------------------
76 template<class MarkerLocator
, class MarkerShapes
>
77 void conv_marker
<MarkerLocator
, MarkerShapes
>::rewind(unsigned)
85 //------------------------------------------------------------------------
86 template<class MarkerLocator
, class MarkerShapes
>
87 unsigned conv_marker
<MarkerLocator
, MarkerShapes
>::vertex(double* x
, double* y
)
89 unsigned cmd
= path_cmd_move_to
;
90 double x1
, y1
, x2
, y2
;
97 if(m_num_markers
== 0)
102 m_marker_locator
->rewind(m_marker
);
108 if(is_stop(m_marker_locator
->vertex(&x1
, &y1
)))
113 if(is_stop(m_marker_locator
->vertex(&x2
, &y2
)))
120 m_mtx
*= trans_affine_rotation(atan2(y2
- y1
, x2
- x1
));
121 m_mtx
*= trans_affine_translation(x1
, y1
);
122 m_marker_shapes
->rewind(m_marker
- 1);
126 cmd
= m_marker_shapes
->vertex(x
, y
);
129 cmd
= path_cmd_move_to
;
133 m_mtx
.transform(x
, y
);