139241fe2SDarkWyrm //---------------------------------------------------------------------------- 2*e39da397SStephan Aßmus // Anti-Grain Geometry - Version 2.4 3*e39da397SStephan Aßmus // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) 439241fe2SDarkWyrm // 539241fe2SDarkWyrm // Permission to copy, use, modify, sell and distribute this software 639241fe2SDarkWyrm // is granted provided this copyright notice appears in all copies. 739241fe2SDarkWyrm // This software is provided "as is" without express or implied 839241fe2SDarkWyrm // warranty, and with no claim as to its suitability for any purpose. 939241fe2SDarkWyrm // 1039241fe2SDarkWyrm //---------------------------------------------------------------------------- 1139241fe2SDarkWyrm // Contact: mcseem@antigrain.com 1239241fe2SDarkWyrm // mcseemagg@yahoo.com 1339241fe2SDarkWyrm // http://www.antigrain.com 1439241fe2SDarkWyrm //---------------------------------------------------------------------------- 1539241fe2SDarkWyrm 1639241fe2SDarkWyrm #ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED 1739241fe2SDarkWyrm #define AGG_TRANS_DOUBLE_PATH_INCLUDED 1839241fe2SDarkWyrm 1939241fe2SDarkWyrm #include "agg_basics.h" 2039241fe2SDarkWyrm #include "agg_vertex_sequence.h" 2139241fe2SDarkWyrm 2239241fe2SDarkWyrm namespace agg 2339241fe2SDarkWyrm { 2439241fe2SDarkWyrm 2539241fe2SDarkWyrm // See also: agg_trans_double_path.cpp 2639241fe2SDarkWyrm // 2739241fe2SDarkWyrm //-------------------------------------------------------trans_double_path 2839241fe2SDarkWyrm class trans_double_path 2939241fe2SDarkWyrm { 3039241fe2SDarkWyrm enum status_e 3139241fe2SDarkWyrm { 3239241fe2SDarkWyrm initial, 3339241fe2SDarkWyrm making_path, 3439241fe2SDarkWyrm ready 3539241fe2SDarkWyrm }; 3639241fe2SDarkWyrm 3739241fe2SDarkWyrm public: 3839241fe2SDarkWyrm typedef vertex_sequence<vertex_dist, 6> vertex_storage; 3939241fe2SDarkWyrm 4039241fe2SDarkWyrm trans_double_path(); 4139241fe2SDarkWyrm 4239241fe2SDarkWyrm //-------------------------------------------------------------------- base_length(double v)4339241fe2SDarkWyrm void base_length(double v) { m_base_length = v; } base_length()4439241fe2SDarkWyrm double base_length() const { return m_base_length; } 4539241fe2SDarkWyrm 4639241fe2SDarkWyrm //-------------------------------------------------------------------- base_height(double v)4739241fe2SDarkWyrm void base_height(double v) { m_base_height = v; } base_height()4839241fe2SDarkWyrm double base_height() const { return m_base_height; } 4939241fe2SDarkWyrm 5039241fe2SDarkWyrm //-------------------------------------------------------------------- preserve_x_scale(bool f)5139241fe2SDarkWyrm void preserve_x_scale(bool f) { m_preserve_x_scale = f; } preserve_x_scale()5239241fe2SDarkWyrm bool preserve_x_scale() const { return m_preserve_x_scale; } 5339241fe2SDarkWyrm 5439241fe2SDarkWyrm //-------------------------------------------------------------------- 5539241fe2SDarkWyrm void reset(); 5639241fe2SDarkWyrm void move_to1(double x, double y); 5739241fe2SDarkWyrm void line_to1(double x, double y); 5839241fe2SDarkWyrm void move_to2(double x, double y); 5939241fe2SDarkWyrm void line_to2(double x, double y); 6039241fe2SDarkWyrm void finalize_paths(); 6139241fe2SDarkWyrm 6239241fe2SDarkWyrm //-------------------------------------------------------------------- 6339241fe2SDarkWyrm template<class VertexSource1, class VertexSource2> 6439241fe2SDarkWyrm void add_paths(VertexSource1& vs1, VertexSource2& vs2, 6539241fe2SDarkWyrm unsigned path1_id=0, unsigned path2_id=0) 6639241fe2SDarkWyrm { 6739241fe2SDarkWyrm double x; 6839241fe2SDarkWyrm double y; 6939241fe2SDarkWyrm 7039241fe2SDarkWyrm unsigned cmd; 7139241fe2SDarkWyrm 7239241fe2SDarkWyrm vs1.rewind(path1_id); 7339241fe2SDarkWyrm while(!is_stop(cmd = vs1.vertex(&x, &y))) 7439241fe2SDarkWyrm { 7539241fe2SDarkWyrm if(is_move_to(cmd)) 7639241fe2SDarkWyrm { 7739241fe2SDarkWyrm move_to1(x, y); 7839241fe2SDarkWyrm } 7939241fe2SDarkWyrm else 8039241fe2SDarkWyrm { 8139241fe2SDarkWyrm if(is_vertex(cmd)) 8239241fe2SDarkWyrm { 8339241fe2SDarkWyrm line_to1(x, y); 8439241fe2SDarkWyrm } 8539241fe2SDarkWyrm } 8639241fe2SDarkWyrm } 8739241fe2SDarkWyrm 8839241fe2SDarkWyrm vs2.rewind(path2_id); 8939241fe2SDarkWyrm while(!is_stop(cmd = vs2.vertex(&x, &y))) 9039241fe2SDarkWyrm { 9139241fe2SDarkWyrm if(is_move_to(cmd)) 9239241fe2SDarkWyrm { 9339241fe2SDarkWyrm move_to2(x, y); 9439241fe2SDarkWyrm } 9539241fe2SDarkWyrm else 9639241fe2SDarkWyrm { 9739241fe2SDarkWyrm if(is_vertex(cmd)) 9839241fe2SDarkWyrm { 9939241fe2SDarkWyrm line_to2(x, y); 10039241fe2SDarkWyrm } 10139241fe2SDarkWyrm } 10239241fe2SDarkWyrm } 10339241fe2SDarkWyrm finalize_paths(); 10439241fe2SDarkWyrm } 10539241fe2SDarkWyrm 10639241fe2SDarkWyrm //-------------------------------------------------------------------- 10739241fe2SDarkWyrm double total_length1() const; 10839241fe2SDarkWyrm double total_length2() const; 10939241fe2SDarkWyrm void transform(double *x, double *y) const; 11039241fe2SDarkWyrm 11139241fe2SDarkWyrm private: 11239241fe2SDarkWyrm double finalize_path(vertex_storage& vertices); 11339241fe2SDarkWyrm void transform1(const vertex_storage& vertices, 11439241fe2SDarkWyrm double kindex, double kx, 11539241fe2SDarkWyrm double *x, double* y) const; 11639241fe2SDarkWyrm 11739241fe2SDarkWyrm vertex_storage m_src_vertices1; 11839241fe2SDarkWyrm vertex_storage m_src_vertices2; 11939241fe2SDarkWyrm double m_base_length; 12039241fe2SDarkWyrm double m_base_height; 12139241fe2SDarkWyrm double m_kindex1; 12239241fe2SDarkWyrm double m_kindex2; 12339241fe2SDarkWyrm status_e m_status1; 12439241fe2SDarkWyrm status_e m_status2; 12539241fe2SDarkWyrm bool m_preserve_x_scale; 12639241fe2SDarkWyrm }; 12739241fe2SDarkWyrm 12839241fe2SDarkWyrm } 12939241fe2SDarkWyrm 13039241fe2SDarkWyrm 13139241fe2SDarkWyrm #endif 132