update dev300-m58
[ooovba.git] / agg / inc / agg_conv_clip_polygon.h
blob63e17878ab11167bafff0fc3be0048c39325d9f2
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
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 //----------------------------------------------------------------------------
16 // Polygon clipping converter
17 // There an optimized Liang-Basky algorithm is used.
18 // The algorithm doesn't optimize the degenerate edges, i.e. it will never
19 // break a closed polygon into two or more ones, instead, there will be
20 // degenerate edges coinciding with the respective clipping boundaries.
21 // This is a sub-optimal solution, because that optimization would require
22 // extra, rather expensive math while the rasterizer tolerates it quite well,
23 // without any considerable overhead.
25 //----------------------------------------------------------------------------
26 #ifndef AGG_CONV_CLIP_POLYGON_INCLUDED
27 #define AGG_CONV_CLIP_POLYGON_INCLUDED
29 #include "agg_basics.h"
30 #include "agg_conv_adaptor_vpgen.h"
31 #include "agg_vpgen_clip_polygon.h"
32 #include "agg_vertex_iterator.h"
34 namespace agg
37 //=======================================================conv_clip_polygon
38 template<class VertexSource>
39 struct conv_clip_polygon : public conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon>
41 typedef conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon> base_type;
43 conv_clip_polygon(VertexSource& vs) :
44 conv_adaptor_vpgen<VertexSource, vpgen_clip_polygon>(vs) {}
46 void clip_box(double x1, double y1, double x2, double y2)
48 base_type::vpgen().clip_box(x1, y1, x2, y2);
51 double x1() const { return base_type::vpgen().x1(); }
52 double y1() const { return base_type::vpgen().y1(); }
53 double x2() const { return base_type::vpgen().x2(); }
54 double y2() const { return base_type::vpgen().y2(); }
56 typedef conv_clip_polygon<VertexSource> source_type;
57 typedef vertex_iterator<source_type> iterator;
58 iterator begin(unsigned id) { return iterator(*this, id); }
59 iterator end() { return iterator(path_cmd_stop); }
61 private:
62 conv_clip_polygon(const conv_clip_polygon<VertexSource>&);
63 const conv_clip_polygon<VertexSource>&
64 operator = (const conv_clip_polygon<VertexSource>&);
69 #endif