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 // polyline 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 polyline 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. 24 // 25 //---------------------------------------------------------------------------- 26 #ifndef AGG_CONV_CLIP_polyline_INCLUDED 27 #define AGG_CONV_CLIP_polyline_INCLUDED 28 29 #include "agg_basics.h" 30 #include "agg_conv_adaptor_vpgen.h" 31 #include "agg_vpgen_clip_polyline.h" 32 33 namespace agg 34 { 35 36 //=======================================================conv_clip_polyline 37 template<class VertexSource> 38 struct conv_clip_polyline : public conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline> 39 { 40 typedef conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline> base_type; 41 42 conv_clip_polyline(VertexSource& vs) : 43 conv_adaptor_vpgen<VertexSource, vpgen_clip_polyline>(vs) {} 44 45 void clip_box(double x1, double y1, double x2, double y2) 46 { 47 base_type::vpgen().clip_box(x1, y1, x2, y2); 48 } 49 50 double x1() const { return base_type::vpgen().x1(); } 51 double y1() const { return base_type::vpgen().y1(); } 52 double x2() const { return base_type::vpgen().x2(); } 53 double y2() const { return base_type::vpgen().y2(); } 54 55 private: 56 conv_clip_polyline(const conv_clip_polyline<VertexSource>&); 57 const conv_clip_polyline<VertexSource>& 58 operator = (const conv_clip_polyline<VertexSource>&); 59 }; 60 61 } 62 63 #endif 64