COIN-OR::LEMON - Graph Library

Changeset 2207:75a29ac69c19 in lemon-0.x for lemon/graph_to_eps.h


Ignore:
Timestamp:
09/07/06 15:27:16 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2933
Message:

xy -> dim2::Point

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_to_eps.h

    r2178 r2207  
    3636
    3737#include<lemon/bits/invalid.h>
    38 #include<lemon/xy.h>
     38#include<lemon/dim2.h>
    3939#include<lemon/maps.h>
    4040#include<lemon/color.h>
     
    8282  std::ostream& os;
    8383 
    84   typedef ConstMap<typename Graph::Node,xy<double> > CoordsMapType;
     84  typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
    8585  CoordsMapType _coords;
    8686  ConstMap<typename Graph::Node,double > _nodeSizes;
     
    147147                          bool _pros=false) :
    148148    g(_g), os(_os),
    149     _coords(xy<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
     149    _coords(dim2::Point<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
    150150    _nodeColors(WHITE), _edgeColors(BLACK),
    151151    _edgeWidths(1.0), _edgeWidthScale(0.003),
     
    314314  }
    315315  template<class TT>
    316   static std::string psOut(const xy<TT> &p)
     316  static std::string psOut(const dim2::Point<TT> &p)
    317317    {
    318318      std::ostringstream os;   
     
    338338
    339339  ///Sets the map of the node coordinates.
    340   ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values.
     340  ///\param x must be a node map with dim2::Point<double> or
     341  ///\ref dim2::Point "dim2::Point<int>" values.
    341342  template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) {
    342343    dontPrint=true;
     
    670671
    671672protected:
    672   bool isInsideNode(xy<double> p, double r,int t)
     673  bool isInsideNode(dim2::Point<double> p, double r,int t)
    673674  {
    674675    switch(t) {
     
    737738    double diag_len = 1;
    738739    if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) {
    739       BoundingBox<double> bb;
     740      dim2::BoundingBox<double> bb;
    740741      for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
    741742      if (bb.empty()) {
    742         bb = BoundingBox<double>(xy<double>(0,0));
     743        bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
    743744      }
    744745      diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
     
    748749    }
    749750   
    750     BoundingBox<double> bb;
     751    dim2::BoundingBox<double> bb;
    751752    for(NodeIt n(g);n!=INVALID;++n) {
    752753      double ns=_nodeSizes[n]*_nodeScale;
    753       xy<double> p(ns,ns);
     754      dim2::Point<double> p(ns,ns);
    754755      switch(_nodeShapes[n]) {
    755756      case CIRCLE:
     
    761762      case MALE:
    762763        bb.add(-p+mycoords[n]);
    763         bb.add(xy<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
     764        bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
    764765        break;
    765766      case FEMALE:
    766767        bb.add(p+mycoords[n]);
    767         bb.add(xy<double>(-ns,-3.01*ns)+mycoords[n]);
     768        bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]);
    768769        break;
    769770      }
    770771    }
    771772    if (bb.empty()) {
    772       bb = BoundingBox<double>(xy<double>(0,0));
     773      bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
    773774    }
    774775   
     
    871872                  (A4WIDTH-2*A4BORDER)/bb.width());
    872873        os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
    873            << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n"
     874           << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER
     875           << " translate\n"
    874876           << sc << " dup scale\n"
    875877           << -bb.left() << ' ' << -bb.bottom() << " translate\n";
     
    880882                  (A4WIDTH-2*A4BORDER)/bb.height());
    881883        os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
    882            << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER  << " translate\n"
     884           << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
     885           << " translate\n"
    883886           << sc << " dup scale\n90 rotate\n"
    884887           << -bb.left() << ' ' << -bb.top() << " translate\n";
     
    905908          sw-=_parEdgeDist;
    906909          sw/=-2.0;
    907           xy<double> dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
     910          dim2::Point<double>
     911            dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
    908912          double l=std::sqrt(dvec.normSquare());
    909913          ///\todo better 'epsilon' would be nice here.
    910           xy<double> d(dvec/std::max(l,EPSILON));
    911           xy<double> m;
    912 //        m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
    913 
    914 //        m=xy<double>(mycoords[g.source(*i)])+
     914          dim2::Point<double> d(dvec/std::max(l,EPSILON));
     915          dim2::Point<double> m;
     916//        m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
     917
     918//        m=dim2::Point<double>(mycoords[g.source(*i)])+
    915919//          dvec*(double(_nodeSizes[g.source(*i)])/
    916920//             (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
    917921
    918           m=xy<double>(mycoords[g.source(*i)])+
     922          m=dim2::Point<double>(mycoords[g.source(*i)])+
    919923            d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
    920924
    921925          for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
    922926            sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
    923             xy<double> mm=m+rot90(d)*sw/.75;
     927            dim2::Point<double> mm=m+rot90(d)*sw/.75;
    924928            if(_drawArrows) {
    925929              int node_shape;
    926               xy<double> s=mycoords[g.source(*e)];
    927               xy<double> t=mycoords[g.target(*e)];
     930              dim2::Point<double> s=mycoords[g.source(*e)];
     931              dim2::Point<double> t=mycoords[g.target(*e)];
    928932              double rn=_nodeSizes[g.target(*e)]*_nodeScale;
    929933              node_shape=_nodeShapes[g.target(*e)];
    930               Bezier3 bez(s,mm,mm,t);
     934              dim2::Bezier3 bez(s,mm,mm,t);
    931935              double t1=0,t2=1;
    932936              for(int i=0;i<INTERPOL_PREC;++i)
    933937                if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
    934938                else t1=(t1+t2)/2;
    935               xy<double> apoint=bez((t1+t2)/2);
     939              dim2::Point<double> apoint=bez((t1+t2)/2);
    936940              rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale;
    937941              rn*=rn;
     
    940944                if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
    941945                else t2=(t1+t2)/2;
    942               xy<double> linend=bez((t1+t2)/2);       
     946              dim2::Point<double> linend=bez((t1+t2)/2);             
    943947              bez=bez.before((t1+t2)/2);
    944948//            rn=_nodeSizes[g.source(*e)]*_nodeScale;
     
    957961                 << bez.p3.x << ' ' << bez.p3.y << ' '
    958962                 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
    959               xy<double> dd(rot90(linend-apoint));
     963              dim2::Point<double> dd(rot90(linend-apoint));
    960964              dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
    961965                std::sqrt(dd.normSquare());
     
    983987           &&g.source(e)!=g.target(e))
    984988          if(_drawArrows) {
    985             xy<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
     989            dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
    986990            double rn=_nodeSizes[g.target(e)]*_nodeScale;
    987991            int node_shape=_nodeShapes[g.target(e)];
Note: See TracChangeset for help on using the changeset viewer.