1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry (AGG) - Version 2.5
3 // A high quality rendering engine for C++
4 // Copyright (C) 2002-2006 Maxim Shemanarev
5 // Contact: mcseem@antigrain.com
6 //          mcseemagg@yahoo.com
7 //          http://antigrain.com
8 //
9 // AGG is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // AGG is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with AGG; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 // MA 02110-1301, USA.
23 //----------------------------------------------------------------------------
24 //
25 // polyline clipping converter
26 // There an optimized Liang-Basky algorithm is used.
27 // The algorithm doesn't optimize the degenerate edges, i.e. it will never
28 // break a closed polyline into two or more ones, instead, there will be
29 // degenerate edges coinciding with the respective clipping boundaries.
30 // This is a sub-optimal solution, because that optimization would require
31 // extra, rather expensive math while the rasterizer tolerates it quite well,
32 // without any considerable overhead.
33 //
34 //----------------------------------------------------------------------------
35 #ifndef AGG_CONV_CLIP_polyline_INCLUDED
36 #define AGG_CONV_CLIP_polyline_INCLUDED
37 
38 #include "agg_basics.h"
39 #include "agg_conv_adaptor_vpgen.h"
40 #include "agg_vpgen_clip_polyline.h"
41 
42 namespace agg
43 {
44 
45     //=======================================================conv_clip_polyline
46     template<class VertexSource>
47     struct conv_clip_polyline : public conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>
48     {
49         typedef conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline> base_type;
50 
conv_clip_polylineconv_clip_polyline51         conv_clip_polyline(VertexSource& vs) :
52             conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>(vs) {}
53 
clip_boxconv_clip_polyline54         void clip_box(double x1, double y1, double x2, double y2)
55         {
56             base_type::vpgen().clip_box(x1, y1, x2, y2);
57         }
58 
x1conv_clip_polyline59         double x1() const { return base_type::vpgen().x1(); }
y1conv_clip_polyline60         double y1() const { return base_type::vpgen().y1(); }
x2conv_clip_polyline61         double x2() const { return base_type::vpgen().x2(); }
y2conv_clip_polyline62         double y2() const { return base_type::vpgen().y2(); }
63 
64     private:
65         conv_clip_polyline(const conv_clip_polyline<VertexSource>&);
66         const conv_clip_polyline<VertexSource>&
67             operator = (const conv_clip_polyline<VertexSource>&);
68     };
69 
70 }
71 
72 #endif
73