1 //---------------------------------------------------------------------------- 2 // Anti-Grain Geometry - Version 2.2 3 // Copyright (C) 2002-2004 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 // class conv_transform 17 // 18 //---------------------------------------------------------------------------- 19 #ifndef AGG_CONV_TRANSFORM_INCLUDED 20 #define AGG_CONV_TRANSFORM_INCLUDED 21 22 #include "agg_basics.h" 23 #include "agg_trans_affine.h" 24 #include "agg_vertex_iterator.h" 25 26 namespace agg 27 { 28 29 //----------------------------------------------------------conv_transform 30 template<class VertexSource, class Transformer=trans_affine> class conv_transform 31 { 32 public: 33 conv_transform(VertexSource& source, const Transformer& tr) : 34 m_source(&source), m_trans(&tr) {} 35 36 void set_source(VertexSource& source) { m_source = &source; } 37 38 void rewind(unsigned id) 39 { 40 m_source->rewind(id); 41 } 42 43 unsigned vertex(double* x, double* y) 44 { 45 unsigned cmd = m_source->vertex(x, y); 46 if(is_vertex(cmd)) 47 { 48 m_trans->transform(x, y); 49 } 50 return cmd; 51 } 52 53 void transformer(const Transformer& tr) 54 { 55 m_trans = &tr; 56 } 57 58 typedef conv_transform<VertexSource, Transformer> source_type; 59 typedef vertex_iterator<source_type> iterator; 60 iterator begin(unsigned id) { return iterator(*this, id); } 61 iterator end() { return iterator(path_cmd_stop); } 62 63 private: 64 conv_transform(const conv_transform<VertexSource>&); 65 const conv_transform<VertexSource>& 66 operator = (const conv_transform<VertexSource>&); 67 68 VertexSource* m_source; 69 const Transformer* m_trans; 70 }; 71 72 73 } 74 75 #endif 76