Anti-Grain Geometry - AGG (libagg)
2.5
|
00001 //---------------------------------------------------------------------------- 00002 // Anti-Grain Geometry (AGG) - Version 2.5 00003 // A high quality rendering engine for C++ 00004 // Copyright (C) 2002-2006 Maxim Shemanarev 00005 // Contact: mcseem@antigrain.com 00006 // mcseemagg@yahoo.com 00007 // http://antigrain.com 00008 // 00009 // AGG is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // AGG is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with AGG; if not, write to the Free Software 00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00022 // MA 02110-1301, USA. 00023 //---------------------------------------------------------------------------- 00024 00025 #ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED 00026 #define AGG_TRANS_DOUBLE_PATH_INCLUDED 00027 00028 #include "agg_basics.h" 00029 #include "agg_vertex_sequence.h" 00030 00031 namespace agg 00032 { 00033 00034 // See also: agg_trans_double_path.cpp 00035 // 00036 //-------------------------------------------------------trans_double_path 00037 class trans_double_path 00038 { 00039 enum status_e 00040 { 00041 initial, 00042 making_path, 00043 ready 00044 }; 00045 00046 public: 00047 typedef vertex_sequence<vertex_dist, 6> vertex_storage; 00048 00049 trans_double_path(); 00050 00051 //-------------------------------------------------------------------- 00052 void base_length(double v) { m_base_length = v; } 00053 double base_length() const { return m_base_length; } 00054 00055 //-------------------------------------------------------------------- 00056 void base_height(double v) { m_base_height = v; } 00057 double base_height() const { return m_base_height; } 00058 00059 //-------------------------------------------------------------------- 00060 void preserve_x_scale(bool f) { m_preserve_x_scale = f; } 00061 bool preserve_x_scale() const { return m_preserve_x_scale; } 00062 00063 //-------------------------------------------------------------------- 00064 void reset(); 00065 void move_to1(double x, double y); 00066 void line_to1(double x, double y); 00067 void move_to2(double x, double y); 00068 void line_to2(double x, double y); 00069 void finalize_paths(); 00070 00071 //-------------------------------------------------------------------- 00072 template<class VertexSource1, class VertexSource2> 00073 void add_paths(VertexSource1& vs1, VertexSource2& vs2, 00074 unsigned path1_id=0, unsigned path2_id=0) 00075 { 00076 double x; 00077 double y; 00078 00079 unsigned cmd; 00080 00081 vs1.rewind(path1_id); 00082 while(!is_stop(cmd = vs1.vertex(&x, &y))) 00083 { 00084 if(is_move_to(cmd)) 00085 { 00086 move_to1(x, y); 00087 } 00088 else 00089 { 00090 if(is_vertex(cmd)) 00091 { 00092 line_to1(x, y); 00093 } 00094 } 00095 } 00096 00097 vs2.rewind(path2_id); 00098 while(!is_stop(cmd = vs2.vertex(&x, &y))) 00099 { 00100 if(is_move_to(cmd)) 00101 { 00102 move_to2(x, y); 00103 } 00104 else 00105 { 00106 if(is_vertex(cmd)) 00107 { 00108 line_to2(x, y); 00109 } 00110 } 00111 } 00112 finalize_paths(); 00113 } 00114 00115 //-------------------------------------------------------------------- 00116 double total_length1() const; 00117 double total_length2() const; 00118 void transform(double *x, double *y) const; 00119 00120 private: 00121 double finalize_path(vertex_storage& vertices); 00122 void transform1(const vertex_storage& vertices, 00123 double kindex, double kx, 00124 double *x, double* y) const; 00125 00126 vertex_storage m_src_vertices1; 00127 vertex_storage m_src_vertices2; 00128 double m_base_length; 00129 double m_base_height; 00130 double m_kindex1; 00131 double m_kindex2; 00132 status_e m_status1; 00133 status_e m_status2; 00134 bool m_preserve_x_scale; 00135 }; 00136 00137 } 00138 00139 00140 #endif