src/lemon/graph_to_eps.h
changeset 1417 53c2a0ccc9a4
parent 1367 a490662291b9
equal deleted inserted replaced
19:34aa416a6163 20:b518dc3ed2e5
    16 
    16 
    17 #ifndef LEMON_GRAPH_TO_EPS_H
    17 #ifndef LEMON_GRAPH_TO_EPS_H
    18 #define LEMON_GRAPH_TO_EPS_H
    18 #define LEMON_GRAPH_TO_EPS_H
    19 
    19 
    20 #include <sys/time.h>
    20 #include <sys/time.h>
    21 #include <time.h>
       
    22 
    21 
    23 #include<iostream>
    22 #include<iostream>
    24 #include<fstream>
    23 #include<fstream>
    25 #include<sstream>
    24 #include<sstream>
    26 #include<algorithm>
    25 #include<algorithm>
    27 #include<vector>
    26 #include<vector>
    28 
    27 
       
    28 #include <ctime>
       
    29 #include <cmath>
       
    30 
    29 #include<lemon/invalid.h>
    31 #include<lemon/invalid.h>
    30 #include<lemon/xy.h>
    32 #include<lemon/xy.h>
    31 #include<lemon/maps.h>
    33 #include<lemon/maps.h>
    32 #include<lemon/bezier.h>
    34 #include<lemon/bezier.h>
       
    35 
    33 
    36 
    34 ///\ingroup io_group
    37 ///\ingroup io_group
    35 ///\file
    38 ///\file
    36 ///\brief Simple graph drawer
    39 ///\brief Simple graph drawer
    37 ///
    40 ///
   807 	  for(typename std::vector<Edge>::iterator e=i;e!=j;++e)
   810 	  for(typename std::vector<Edge>::iterator e=i;e!=j;++e)
   808 	    sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist;
   811 	    sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist;
   809 	  sw-=_parEdgeDist;
   812 	  sw-=_parEdgeDist;
   810 	  sw/=-2.0;
   813 	  sw/=-2.0;
   811 	  xy<double> dvec(_coords[g.target(*i)]-_coords[g.source(*i)]);
   814 	  xy<double> dvec(_coords[g.target(*i)]-_coords[g.source(*i)]);
   812 	  double l=sqrt(dvec.normSquare()); 
   815 	  double l=std::sqrt(dvec.normSquare()); 
   813 	  ///\todo better 'epsilon' would be nice here.
   816 	  ///\todo better 'epsilon' would be nice here.
   814 	  xy<double> d(dvec/std::max(l,1e-9));
   817 	  xy<double> d(dvec/std::max(l,1e-9));
   815  	  xy<double> m;
   818  	  xy<double> m;
   816 // 	  m=xy<double>(_coords[g.target(*i)]+_coords[g.source(*i)])/2.0;
   819 // 	  m=xy<double>(_coords[g.target(*i)]+_coords[g.source(*i)])/2.0;
   817 
   820 
   860 		 << bez.p2.x << ' ' << bez.p2.y << ' '
   863 		 << bez.p2.x << ' ' << bez.p2.y << ' '
   861 		 << bez.p3.x << ' ' << bez.p3.y << ' '
   864 		 << bez.p3.x << ' ' << bez.p3.y << ' '
   862 		 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
   865 		 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
   863 	      xy<double> dd(rot90(linend-apoint));
   866 	      xy<double> dd(rot90(linend-apoint));
   864 	      dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
   867 	      dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
   865 		sqrt(dd.normSquare());
   868 		std::sqrt(dd.normSquare());
   866 	      os << "newpath " << psOut(apoint) << " moveto "
   869 	      os << "newpath " << psOut(apoint) << " moveto "
   867 		 << psOut(linend+dd) << " lineto "
   870 		 << psOut(linend+dd) << " lineto "
   868 		 << psOut(linend-dd) << " lineto closepath fill\n";
   871 		 << psOut(linend-dd) << " lineto closepath fill\n";
   869 	    }
   872 	    }
   870 	    else {
   873 	    else {