00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VERTEX_HPP
00025 #define VERTEX_HPP
00026
00027 #include <iostream>
00028 #include <sstream>
00029
00030 namespace mapnik
00031 {
00032 enum CommandType {
00033 SEG_END =0,
00034 SEG_MOVETO=1,
00035 SEG_LINETO=2,
00036 SEG_CLOSE =3
00037 };
00038
00039 template <typename T,int dim>
00040 struct vertex {
00041 typedef T type;
00042 };
00043
00044 template <typename T>
00045 struct vertex<T,2>
00046 {
00047 typedef T type;
00048 T x;
00049 T y;
00050 unsigned cmd;
00051 vertex()
00052 : x(0),y(0),cmd(SEG_END) {}
00053 vertex(T x,T y,unsigned cmd)
00054 : x(x),y(y),cmd(cmd) {}
00055
00056 template <typename T2>
00057 vertex(const vertex<T2,2>& rhs)
00058 : x(type(rhs.x)),
00059 y(type(rhs.y)),
00060 cmd(rhs.cmd) {}
00061
00062 template <typename T2> vertex<T,2> operator=(const vertex<T2,2>& rhs)
00063 {
00064 if ((void*)this == (void*)&rhs)
00065 {
00066 return *this;
00067 }
00068 x=type(rhs.x);
00069 y=type(rhs.y);
00070 cmd=rhs.cmd;
00071 return *this;
00072 }
00073 };
00074
00075 typedef vertex<double,2> vertex2d;
00076 typedef vertex<int,2> vertex2i;
00077
00078
00079 template <class charT,class traits,class T,int dim>
00080 inline std::basic_ostream<charT,traits>&
00081 operator << (std::basic_ostream<charT,traits>& out,
00082 const vertex<T,dim>& c);
00083
00084 template <class charT,class traits,class T>
00085 inline std::basic_ostream<charT,traits>&
00086 operator << (std::basic_ostream<charT,traits>& out,
00087 const vertex<T,2>& v)
00088 {
00089 std::basic_ostringstream<charT,traits> s;
00090 s.copyfmt(out);
00091 s.width(0);
00092 s<<"vertex2("<<v.x<<","<<v.y<<",cmd="<<v.cmd<<" )";
00093 out << s.str();
00094 return out;
00095 }
00096
00097 template <class charT,class traits,class T>
00098 inline std::basic_ostream<charT,traits>&
00099 operator << (std::basic_ostream<charT,traits>& out,
00100 const vertex<T,3>& v)
00101 {
00102 std::basic_ostringstream<charT,traits> s;
00103 s.copyfmt(out);
00104 s.width(0);
00105 s<<"vertex3("<<v.x<<","<<v.y<<","<<v.z<<",cmd="<<v.cmd<<")";
00106 out << s.str();
00107 return out;
00108 }
00109
00110 }
00111
00112 #endif // VERTEX_HPP