1//----------------------------------------------------------------------------
2// Anti-Grain Geometry - Version 2.4
3// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4//
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.
9//
10//----------------------------------------------------------------------------
11// Contact: mcseem@antigrain.com
12//          mcseemagg@yahoo.com
13//          http://www.antigrain.com
14//----------------------------------------------------------------------------
15
16#ifndef AGG_CONV_UNCLOSE_POLYGON_INCLUDED
17#define AGG_CONV_UNCLOSE_POLYGON_INCLUDED
18
19#include "agg_basics.h"
20
21namespace agg
22{
23    //====================================================conv_unclose_polygon
24    template<class VertexSource> class conv_unclose_polygon
25    {
26    public:
27        conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {}
28        void attach(VertexSource& source) { m_source = &source; }
29
30        void rewind(unsigned path_id)
31        {
32            m_source->rewind(path_id);
33        }
34
35        unsigned vertex(double* x, double* y)
36        {
37            unsigned cmd = m_source->vertex(x, y);
38            if(is_end_poly(cmd)) cmd &= ~path_flags_close;
39            return cmd;
40        }
41
42    private:
43        conv_unclose_polygon(const conv_unclose_polygon<VertexSource>&);
44        const conv_unclose_polygon<VertexSource>&
45            operator = (const conv_unclose_polygon<VertexSource>&);
46
47        VertexSource* m_source;
48    };
49
50}
51
52#endif
53