Changeset 2207:75a29ac69c19 in lemon-0.x for lemon
- Timestamp:
- 09/07/06 15:27:16 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2933
- Location:
- lemon
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
lemon/Makefile.am
r2202 r2207 42 42 lemon/dfs.h \ 43 43 lemon/dijkstra.h \ 44 lemon/dim2.h \ 44 45 lemon/dimacs.h \ 45 46 lemon/edge_set.h \ … … 93 94 lemon/topology.h \ 94 95 lemon/ugraph_adaptor.h \ 95 lemon/unionfind.h \ 96 lemon/xy.h 96 lemon/unionfind.h 97 97 98 98 bits_HEADERS += \ -
lemon/bits/bezier.h
r2178 r2207 28 28 ///\author Alpar Juttner 29 29 30 #include<lemon/ xy.h>30 #include<lemon/dim2.h> 31 31 32 32 namespace lemon { 33 namespace dim2 { 33 34 34 35 class BezierBase { 35 36 public: 36 typedef xy<double> xy;37 typedef Point<double> Point; 37 38 protected: 38 static xy conv(xy x,xyy,double t) {return (1-t)*x+t*y;}39 static Point conv(Point x,Point y,double t) {return (1-t)*x+t*y;} 39 40 }; 40 41 … … 42 43 { 43 44 public: 44 xyp1,p2;45 Point p1,p2; 45 46 46 47 Bezier1() {} 47 Bezier1( xy _p1, xy_p2) :p1(_p1), p2(_p2) {}48 Bezier1(Point _p1, Point _p2) :p1(_p1), p2(_p2) {} 48 49 49 xyoperator()(double t) const50 Point operator()(double t) const 50 51 { 51 52 // return conv(conv(p1,p2,t),conv(p2,p3,t),t); … … 64 65 Bezier1 revert() const { return Bezier1(p2,p1);} 65 66 Bezier1 operator()(double a,double b) const { return before(b).after(a/b); } 66 xygrad() const { return p2-p1; }67 xynorm() const { return rot90(p2-p1); }68 xygrad(double) const { return grad(); }69 xynorm(double t) const { return rot90(grad(t)); }67 Point grad() const { return p2-p1; } 68 Point norm() const { return rot90(p2-p1); } 69 Point grad(double) const { return grad(); } 70 Point norm(double t) const { return rot90(grad(t)); } 70 71 }; 71 72 … … 73 74 { 74 75 public: 75 xyp1,p2,p3;76 Point p1,p2,p3; 76 77 77 78 Bezier2() {} 78 Bezier2( xy _p1, xy _p2, xy_p3) :p1(_p1), p2(_p2), p3(_p3) {}79 Bezier2(Point _p1, Point _p2, Point _p3) :p1(_p1), p2(_p2), p3(_p3) {} 79 80 Bezier2(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,.5)), p3(b.p2) {} 80 xyoperator()(double t) const81 Point operator()(double t) const 81 82 { 82 83 // return conv(conv(p1,p2,t),conv(p2,p3,t),t); … … 85 86 Bezier2 before(double t) const 86 87 { 87 xyq(conv(p1,p2,t));88 xyr(conv(p2,p3,t));88 Point q(conv(p1,p2,t)); 89 Point r(conv(p2,p3,t)); 89 90 return Bezier2(p1,q,conv(q,r,t)); 90 91 } … … 92 93 Bezier2 after(double t) const 93 94 { 94 xyq(conv(p1,p2,t));95 xyr(conv(p2,p3,t));95 Point q(conv(p1,p2,t)); 96 Point r(conv(p2,p3,t)); 96 97 return Bezier2(conv(q,r,t),r,p3); 97 98 } … … 100 101 Bezier1 grad() const { return Bezier1(2.0*(p2-p1),2.0*(p3-p2)); } 101 102 Bezier1 norm() const { return Bezier1(2.0*rot90(p2-p1),2.0*rot90(p3-p2)); } 102 xygrad(double t) const { return grad()(t); }103 xynorm(double t) const { return rot90(grad(t)); }103 Point grad(double t) const { return grad()(t); } 104 Point norm(double t) const { return rot90(grad(t)); } 104 105 }; 105 106 … … 107 108 { 108 109 public: 109 xyp1,p2,p3,p4;110 Point p1,p2,p3,p4; 110 111 111 112 Bezier3() {} 112 Bezier3(xy _p1, xy _p2, xy _p3, xy _p4) :p1(_p1), p2(_p2), p3(_p3), p4(_p4) {} 113 Bezier3(Point _p1, Point _p2, Point _p3, Point _p4) 114 : p1(_p1), p2(_p2), p3(_p3), p4(_p4) {} 113 115 Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)), 114 116 p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {} … … 116 118 p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {} 117 119 118 xyoperator()(double t) const120 Point operator()(double t) const 119 121 { 120 122 // return Bezier2(conv(p1,p2,t),conv(p2,p3,t),conv(p3,p4,t))(t); … … 124 126 Bezier3 before(double t) const 125 127 { 126 xyp(conv(p1,p2,t));127 xyq(conv(p2,p3,t));128 xyr(conv(p3,p4,t));129 xya(conv(p,q,t));130 xyb(conv(q,r,t));131 xyc(conv(a,b,t));128 Point p(conv(p1,p2,t)); 129 Point q(conv(p2,p3,t)); 130 Point r(conv(p3,p4,t)); 131 Point a(conv(p,q,t)); 132 Point b(conv(q,r,t)); 133 Point c(conv(a,b,t)); 132 134 return Bezier3(p1,p,a,c); 133 135 } … … 135 137 Bezier3 after(double t) const 136 138 { 137 xyp(conv(p1,p2,t));138 xyq(conv(p2,p3,t));139 xyr(conv(p3,p4,t));140 xya(conv(p,q,t));141 xyb(conv(q,r,t));142 xyc(conv(a,b,t));139 Point p(conv(p1,p2,t)); 140 Point q(conv(p2,p3,t)); 141 Point r(conv(p3,p4,t)); 142 Point a(conv(p,q,t)); 143 Point b(conv(q,r,t)); 144 Point c(conv(a,b,t)); 143 145 return Bezier3(c,b,r,p4); 144 146 } … … 149 151 3.0*rot90(p3-p2), 150 152 3.0*rot90(p4-p3)); } 151 xygrad(double t) const { return grad()(t); }152 xynorm(double t) const { return rot90(grad(t)); }153 Point grad(double t) const { return grad()(t); } 154 Point norm(double t) const { return rot90(grad(t)); } 153 155 154 156 template<class R,class F,class S,class D> 155 157 R recSplit(F &_f,const S &_s,D _d) const 156 158 { 157 const xya=(p1+p2)/2;158 const xyb=(p2+p3)/2;159 const xyc=(p3+p4)/2;160 const xyd=(a+b)/2;161 const xye=(b+c)/2;162 const xyf=(d+e)/2;159 const Point a=(p1+p2)/2; 160 const Point b=(p2+p3)/2; 161 const Point c=(p3+p4)/2; 162 const Point d=(a+b)/2; 163 const Point e=(b+c)/2; 164 const Point f=(d+e)/2; 163 165 R f1=_f(Bezier3(p1,a,d,e),_d); 164 166 R f2=_f(Bezier3(e,d,c,p4),_d); … … 168 170 }; 169 171 170 } //END OF NAMESPACE LEMON 172 173 } //END OF NAMESPACE dim2 174 } //END OF NAMESPACE lemon 171 175 172 176 #endif // LEMON_BEZIER_H -
lemon/dim2.h
r2157 r2207 17 17 */ 18 18 19 #ifndef LEMON_ XY_H20 #define LEMON_ XY_H19 #ifndef LEMON_DIM2_H 20 #define LEMON_DIM2_H 21 21 22 22 #include <iostream> … … 27 27 ///\brief A simple two dimensional vector and a bounding box implementation 28 28 /// 29 /// The class \ref lemon:: xy "xy" implements29 /// The class \ref lemon::dim2::Point "dim2::Point" implements 30 30 ///a two dimensional vector with the usual 31 31 /// operations. 32 32 /// 33 /// The class \ref lemon::BoundingBox "BoundingBox" can be used to determine 34 /// the rectangular bounding box of a set of \ref lemon::xy "xy"'s. 33 /// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox" 34 /// can be used to determine 35 /// the rectangular bounding box of a set of 36 /// \ref lemon::dim2::Point "dim2::Point"'s. 35 37 /// 36 38 ///\author Attila Bernath … … 38 40 39 41 namespace lemon { 42 43 ///Tools for handling two dimensional coordinates 44 45 ///This namespace is a storage of several 46 ///tools for handling two dimensional coordinates 47 namespace dim2 { 40 48 41 49 /// \addtogroup misc … … 48 56 /// operators. 49 57 /// 50 ///\note As you might have noticed, this class does not follow the51 ///\ref naming_conv "LEMON Coding Style" (it should be called \c Xy52 ///according to it). There is a stupid Hungarian proverb, "A kivétel53 ///erõsíti a szabályt" ("An exception54 ///reinforces a rule", which is55 ///actually a mistranslation of the Latin proverb "Exceptio probat regulam").56 ///This class is an example for that.57 ///\author Attila Bernath58 58 template<typename T> 59 class xy{59 class Point { 60 60 61 61 public: … … 69 69 70 70 ///Default constructor 71 xy() {}71 Point() {} 72 72 73 73 ///Construct an instance from coordinates 74 xy(T a, T b) : x(a), y(b) { }74 Point(T a, T b) : x(a), y(b) { } 75 75 76 76 77 77 ///Conversion constructor 78 template<class TT> xy(const xy<TT> &p) : x(p.x), y(p.y) {}78 template<class TT> Point(const Point<TT> &p) : x(p.x), y(p.y) {} 79 79 80 80 ///Give back the square of the norm of the vector … … 84 84 85 85 ///Increment the left hand side by u 86 xy<T>& operator +=(const xy<T>& u) {86 Point<T>& operator +=(const Point<T>& u) { 87 87 x += u.x; 88 88 y += u.y; … … 91 91 92 92 ///Decrement the left hand side by u 93 xy<T>& operator -=(const xy<T>& u) {93 Point<T>& operator -=(const Point<T>& u) { 94 94 x -= u.x; 95 95 y -= u.y; … … 98 98 99 99 ///Multiply the left hand side with a scalar 100 xy<T>& operator *=(const T &u) {100 Point<T>& operator *=(const T &u) { 101 101 x *= u; 102 102 y *= u; … … 105 105 106 106 ///Divide the left hand side by a scalar 107 xy<T>& operator /=(const T &u) {107 Point<T>& operator /=(const T &u) { 108 108 x /= u; 109 109 y /= u; … … 112 112 113 113 ///Return the scalar product of two vectors 114 T operator *(const xy<T>& u) const {114 T operator *(const Point<T>& u) const { 115 115 return x*u.x+y*u.y; 116 116 } 117 117 118 118 ///Return the sum of two vectors 119 xy<T> operator+(const xy<T> &u) const {120 xy<T> b=*this;119 Point<T> operator+(const Point<T> &u) const { 120 Point<T> b=*this; 121 121 return b+=u; 122 122 } 123 123 124 124 ///Return the neg of the vectors 125 xy<T> operator-() const {126 xy<T> b=*this;125 Point<T> operator-() const { 126 Point<T> b=*this; 127 127 b.x=-b.x; b.y=-b.y; 128 128 return b; … … 130 130 131 131 ///Return the difference of two vectors 132 xy<T> operator-(const xy<T> &u) const {133 xy<T> b=*this;132 Point<T> operator-(const Point<T> &u) const { 133 Point<T> b=*this; 134 134 return b-=u; 135 135 } 136 136 137 137 ///Return a vector multiplied by a scalar 138 xy<T> operator*(const T &u) const {139 xy<T> b=*this;138 Point<T> operator*(const T &u) const { 139 Point<T> b=*this; 140 140 return b*=u; 141 141 } 142 142 143 143 ///Return a vector divided by a scalar 144 xy<T> operator/(const T &u) const {145 xy<T> b=*this;144 Point<T> operator/(const T &u) const { 145 Point<T> b=*this; 146 146 return b/=u; 147 147 } 148 148 149 149 ///Test equality 150 bool operator==(const xy<T> &u) const {150 bool operator==(const Point<T> &u) const { 151 151 return (x==u.x) && (y==u.y); 152 152 } 153 153 154 154 ///Test inequality 155 bool operator!=( xyu) const {155 bool operator!=(Point u) const { 156 156 return (x!=u.x) || (y!=u.y); 157 157 } … … 159 159 }; 160 160 161 ///Return an xy162 163 ///Return an xy164 ///\relates xy161 ///Return an Point 162 163 ///Return an Point 164 ///\relates Point 165 165 template <typename T> 166 inline xy<T> make_xy(const T& x, const T& y) {167 return xy<T>(x, y);166 inline Point<T> make_Point(const T& x, const T& y) { 167 return Point<T>(x, y); 168 168 } 169 169 … … 171 171 172 172 ///Return a vector multiplied by a scalar 173 ///\relates xy174 template<typename T> xy<T> operator*(const T &u,const xy<T> &x) {173 ///\relates Point 174 template<typename T> Point<T> operator*(const T &u,const Point<T> &x) { 175 175 return x*u; 176 176 } … … 179 179 180 180 ///Read a plainvector from a stream 181 ///\relates xy181 ///\relates Point 182 182 /// 183 183 template<typename T> 184 inline std::istream& operator>>(std::istream &is, xy<T> &z) {184 inline std::istream& operator>>(std::istream &is, Point<T> &z) { 185 185 char c; 186 186 if (is >> c) { … … 207 207 208 208 ///Write a plainvector to a stream 209 ///\relates xy209 ///\relates Point 210 210 /// 211 211 template<typename T> 212 inline std::ostream& operator<<(std::ostream &os, const xy<T>& z)212 inline std::ostream& operator<<(std::ostream &os, const Point<T>& z) 213 213 { 214 214 os << "(" << z.x << ", " << z.y << ")"; … … 219 219 220 220 ///Returns its parameter rotated by 90 degrees in positive direction. 221 ///\relates xy221 ///\relates Point 222 222 /// 223 223 template<typename T> 224 inline xy<T> rot90(const xy<T> &z)225 { 226 return xy<T>(-z.y,z.x);224 inline Point<T> rot90(const Point<T> &z) 225 { 226 return Point<T>(-z.y,z.x); 227 227 } 228 228 … … 230 230 231 231 ///Returns its parameter rotated by 180 degrees. 232 ///\relates xy232 ///\relates Point 233 233 /// 234 234 template<typename T> 235 inline xy<T> rot180(const xy<T> &z)236 { 237 return xy<T>(-z.x,-z.y);235 inline Point<T> rot180(const Point<T> &z) 236 { 237 return Point<T>(-z.x,-z.y); 238 238 } 239 239 … … 241 241 242 242 ///Returns its parameter rotated by 90 degrees in negative direction. 243 ///\relates xy243 ///\relates Point 244 244 /// 245 245 template<typename T> 246 inline xy<T> rot270(const xy<T> &z)247 { 248 return xy<T>(z.y,-z.x);246 inline Point<T> rot270(const Point<T> &z) 247 { 248 return Point<T>(z.y,-z.x); 249 249 } 250 250 … … 258 258 template<typename T> 259 259 class BoundingBox { 260 xy<T> bottom_left, top_right;260 Point<T> bottom_left, top_right; 261 261 bool _empty; 262 262 public: … … 266 266 267 267 ///Construct an instance from one point 268 BoundingBox( xy<T> a) { bottom_left=top_right=a; _empty = false; }268 BoundingBox(Point<T> a) { bottom_left=top_right=a; _empty = false; } 269 269 270 270 ///Were any points added? … … 282 282 ///Give back the bottom left corner. 283 283 ///If the bounding box is empty, then the return value is not defined. 284 xy<T> bottomLeft() const {284 Point<T> bottomLeft() const { 285 285 return bottom_left; 286 286 } … … 290 290 ///Set the bottom left corner. 291 291 ///It should only bee used for non-empty box. 292 void bottomLeft( xy<T> p) {292 void bottomLeft(Point<T> p) { 293 293 bottom_left = p; 294 294 } … … 298 298 ///Give back the top right corner. 299 299 ///If the bounding box is empty, then the return value is not defined. 300 xy<T> topRight() const {300 Point<T> topRight() const { 301 301 return top_right; 302 302 } … … 306 306 ///Set the top right corner. 307 307 ///It should only bee used for non-empty box. 308 void topRight( xy<T> p) {308 void topRight(Point<T> p) { 309 309 top_right = p; 310 310 } … … 314 314 ///Give back the bottom right corner. 315 315 ///If the bounding box is empty, then the return value is not defined. 316 xy<T> bottomRight() const {317 return xy<T>(top_right.x,bottom_left.y);316 Point<T> bottomRight() const { 317 return Point<T>(top_right.x,bottom_left.y); 318 318 } 319 319 … … 322 322 ///Set the bottom right corner. 323 323 ///It should only bee used for non-empty box. 324 void bottomRight( xy<T> p) {324 void bottomRight(Point<T> p) { 325 325 top_right.x = p.x; 326 326 bottom_left.y = p.y; … … 331 331 ///Give back the top left corner. 332 332 ///If the bounding box is empty, then the return value is not defined. 333 xy<T> topLeft() const {334 return xy<T>(bottom_left.x,top_right.y);333 Point<T> topLeft() const { 334 return Point<T>(bottom_left.x,top_right.y); 335 335 } 336 336 … … 339 339 ///Set the top left corner. 340 340 ///It should only bee used for non-empty box. 341 void topLeft( xy<T> p) {341 void topLeft(Point<T> p) { 342 342 top_right.y = p.y; 343 343 bottom_left.x = p.x; … … 425 425 426 426 ///Checks whether a point is inside a bounding box 427 bool inside(const xy<T>& u){427 bool inside(const Point<T>& u){ 428 428 if (_empty) 429 429 return false; … … 435 435 436 436 ///Increments a bounding box with a point 437 BoundingBox& add(const xy<T>& u){437 BoundingBox& add(const Point<T>& u){ 438 438 if (_empty){ 439 439 bottom_left=top_right=u; … … 450 450 451 451 // ///Sums a bounding box and a point 452 // BoundingBox operator +(const xy<T>& u){452 // BoundingBox operator +(const Point<T>& u){ 453 453 // BoundingBox b = *this; 454 454 // return b += u; … … 486 486 487 487 488 ///Map of x-coordinates of a n xy<>-map488 ///Map of x-coordinates of a dim2::Point<>-map 489 489 490 490 ///\ingroup maps … … 551 551 } 552 552 553 ///Map of y-coordinates of a n xy<>-map553 ///Map of y-coordinates of a dim2::Point<>-map 554 554 555 555 ///\ingroup maps … … 617 617 618 618 619 ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map620 621 ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map619 ///Map of the \ref Point::normSquare() "normSquare()" of an \ref Point "Point"-map 620 621 ///Map of the \ref Point::normSquare() "normSquare()" of an \ref Point "Point"-map 622 622 ///\ingroup maps 623 623 /// … … 649 649 /// @} 650 650 651 651 } //namespce dim2 652 652 653 } //namespace lemon 653 654 654 #endif //LEMON_ XY_H655 #endif //LEMON_DIM2_H -
lemon/eps.cc
r2013 r2207 70 70 } 71 71 72 EpsDrawer::EpsDrawer(std::ostream &os, xy<double> s) : local_stream(false),72 EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> s) : local_stream(false), 73 73 out(os) 74 74 { … … 76 76 } 77 77 78 EpsDrawer::EpsDrawer(std::ostream &os, xy<double> a, xy<double> b) :78 EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b) : 79 79 local_stream(false), 80 80 out(os) … … 98 98 } 99 99 100 EpsDrawer::EpsDrawer(const std::string &name, xy<double> s) :100 EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> s) : 101 101 local_stream(true), 102 102 out(*new std::ofstream(name.c_str())) … … 105 105 } 106 106 107 EpsDrawer::EpsDrawer(const std::string &name, xy<double> a, xy<double> b) :107 EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b) : 108 108 local_stream(true), 109 109 out(*new std::ofstream(name.c_str())) -
lemon/eps.h
r2174 r2207 25 25 #include<sstream> 26 26 #include<lemon/color.h> 27 #include<lemon/ xy.h>27 #include<lemon/dim2.h> 28 28 29 29 ///\ingroup eps_io … … 101 101 ///\c s determines the upper 102 102 ///right corner of the bounding box. The lower left corner is (0,0). 103 EpsDrawer(std::ostream &os, xy<double> s);103 EpsDrawer(std::ostream &os,dim2::Point<double> s); 104 104 ///\e 105 105 … … 109 109 /// determine the lower left and the upper right corners of 110 110 ///the bounding box, respectively. 111 EpsDrawer(std::ostream &os, xy<double> a, xy<double> b);111 EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b); 112 112 ///\e 113 113 … … 131 131 ///\c s determines the upper 132 132 ///right corner of the bounding box. The lower left corner is (0,0). 133 EpsDrawer(const std::string &name, xy<double> s);133 EpsDrawer(const std::string &name,dim2::Point<double> s); 134 134 ///\e 135 135 … … 139 139 /// determine the lower left and the upper right corners of 140 140 ///the bounding box, respectively. 141 EpsDrawer(const std::string &name, xy<double> a, xy<double> b);141 EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b); 142 142 143 143 // template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b) … … 169 169 170 170 ///Draw a line 171 template<class T> EpsDrawer &line( xy<T> p1,xy<T> p2)171 template<class T> EpsDrawer &line(dim2::Point<T> p1,dim2::Point<T> p2) 172 172 { 173 173 return line(p1.x,p1.y,p2.x,p2.y); 174 174 } 175 175 ///Draw a line from the current point 176 template<class T> EpsDrawer &lineTo( xy<T> p)176 template<class T> EpsDrawer &lineTo(dim2::Point<T> p) 177 177 { 178 178 return lineTo(p.x,p.y); 179 179 } 180 180 ///Move the current point 181 template<class T> EpsDrawer &moveTo( xy<T> p)181 template<class T> EpsDrawer &moveTo(dim2::Point<T> p) 182 182 { 183 183 return moveTo(p.x,p.y); 184 184 } 185 185 ///Draw a circle 186 template<class T> EpsDrawer &circle( xy<T> p, double r)186 template<class T> EpsDrawer &circle(dim2::Point<T> p, double r) 187 187 { 188 188 return circle(p.x,p.y,r); … … 297 297 ///\param brd Color of the node border. The default color is black 298 298 template<class T> 299 EpsDrawer &node(NodeShapes t, xy<T> pos, double r,299 EpsDrawer &node(NodeShapes t, dim2::Point<T> pos, double r, 300 300 Color col=WHITE, Color brd=BLACK) 301 301 { … … 306 306 EpsDrawer &translate(double x,double y); 307 307 ///Translate the coordinate system 308 template<class T> EpsDrawer &translate( xy<T> p)308 template<class T> EpsDrawer &translate(dim2::Point<T> p) 309 309 { 310 310 return translate(p.x,p.y); … … 317 317 EpsDrawer &scale(double s) { return scale(s,s); } 318 318 ///Scale the coordinate system 319 template<class T> EpsDrawer &scale( xy<T> p)319 template<class T> EpsDrawer &scale(dim2::Point<T> p) 320 320 { 321 321 return scale(p.x,p.y); … … 337 337 ///Print a coordinate at the current point 338 338 template<class T> 339 EpsDrawer &operator<<( xy<T> p)339 EpsDrawer &operator<<(dim2::Point<T> p) 340 340 { 341 341 out << "((" << p.x << ',' << p.y <<")) show\n"; -
lemon/graph_to_eps.h
r2178 r2207 36 36 37 37 #include<lemon/bits/invalid.h> 38 #include<lemon/ xy.h>38 #include<lemon/dim2.h> 39 39 #include<lemon/maps.h> 40 40 #include<lemon/color.h> … … 82 82 std::ostream& os; 83 83 84 typedef ConstMap<typename Graph::Node, xy<double> > CoordsMapType;84 typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType; 85 85 CoordsMapType _coords; 86 86 ConstMap<typename Graph::Node,double > _nodeSizes; … … 147 147 bool _pros=false) : 148 148 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), 150 150 _nodeColors(WHITE), _edgeColors(BLACK), 151 151 _edgeWidths(1.0), _edgeWidthScale(0.003), … … 314 314 } 315 315 template<class TT> 316 static std::string psOut(const xy<TT> &p)316 static std::string psOut(const dim2::Point<TT> &p) 317 317 { 318 318 std::ostringstream os; … … 338 338 339 339 ///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. 341 342 template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) { 342 343 dontPrint=true; … … 670 671 671 672 protected: 672 bool isInsideNode( xy<double> p, double r,int t)673 bool isInsideNode(dim2::Point<double> p, double r,int t) 673 674 { 674 675 switch(t) { … … 737 738 double diag_len = 1; 738 739 if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) { 739 BoundingBox<double> bb;740 dim2::BoundingBox<double> bb; 740 741 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); 741 742 if (bb.empty()) { 742 bb = BoundingBox<double>(xy<double>(0,0));743 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 743 744 } 744 745 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); … … 748 749 } 749 750 750 BoundingBox<double> bb;751 dim2::BoundingBox<double> bb; 751 752 for(NodeIt n(g);n!=INVALID;++n) { 752 753 double ns=_nodeSizes[n]*_nodeScale; 753 xy<double> p(ns,ns);754 dim2::Point<double> p(ns,ns); 754 755 switch(_nodeShapes[n]) { 755 756 case CIRCLE: … … 761 762 case MALE: 762 763 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]); 764 765 break; 765 766 case FEMALE: 766 767 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]); 768 769 break; 769 770 } 770 771 } 771 772 if (bb.empty()) { 772 bb = BoundingBox<double>(xy<double>(0,0));773 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 773 774 } 774 775 … … 871 872 (A4WIDTH-2*A4BORDER)/bb.width()); 872 873 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" 874 876 << sc << " dup scale\n" 875 877 << -bb.left() << ' ' << -bb.bottom() << " translate\n"; … … 880 882 (A4WIDTH-2*A4BORDER)/bb.height()); 881 883 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" 883 886 << sc << " dup scale\n90 rotate\n" 884 887 << -bb.left() << ' ' << -bb.top() << " translate\n"; … … 905 908 sw-=_parEdgeDist; 906 909 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)]); 908 912 double l=std::sqrt(dvec.normSquare()); 909 913 ///\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)])+ 915 919 // dvec*(double(_nodeSizes[g.source(*i)])/ 916 920 // (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)])); 917 921 918 m= xy<double>(mycoords[g.source(*i)])+922 m=dim2::Point<double>(mycoords[g.source(*i)])+ 919 923 d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0; 920 924 921 925 for(typename std::vector<Edge>::iterator e=i;e!=j;++e) { 922 926 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; 924 928 if(_drawArrows) { 925 929 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)]; 928 932 double rn=_nodeSizes[g.target(*e)]*_nodeScale; 929 933 node_shape=_nodeShapes[g.target(*e)]; 930 Bezier3 bez(s,mm,mm,t);934 dim2::Bezier3 bez(s,mm,mm,t); 931 935 double t1=0,t2=1; 932 936 for(int i=0;i<INTERPOL_PREC;++i) 933 937 if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2; 934 938 else t1=(t1+t2)/2; 935 xy<double> apoint=bez((t1+t2)/2);939 dim2::Point<double> apoint=bez((t1+t2)/2); 936 940 rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale; 937 941 rn*=rn; … … 940 944 if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2; 941 945 else t2=(t1+t2)/2; 942 xy<double> linend=bez((t1+t2)/2);946 dim2::Point<double> linend=bez((t1+t2)/2); 943 947 bez=bez.before((t1+t2)/2); 944 948 // rn=_nodeSizes[g.source(*e)]*_nodeScale; … … 957 961 << bez.p3.x << ' ' << bez.p3.y << ' ' 958 962 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n"; 959 xy<double> dd(rot90(linend-apoint));963 dim2::Point<double> dd(rot90(linend-apoint)); 960 964 dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/ 961 965 std::sqrt(dd.normSquare()); … … 983 987 &&g.source(e)!=g.target(e)) 984 988 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)]); 986 990 double rn=_nodeSizes[g.target(e)]*_nodeScale; 987 991 int node_shape=_nodeShapes[g.target(e)]; -
lemon/grid_ugraph.h
r2151 r2207 27 27 #include <lemon/bits/graph_extender.h> 28 28 29 #include <lemon/ xy.h>29 #include <lemon/dim2.h> 30 30 31 31 ///\ingroup graphs … … 382 382 typedef ExtendedGridUGraphBase Parent; 383 383 384 /// \brief Map to get the indices of the nodes as xy<int>.385 /// 386 /// Map to get the indices of the nodes as xy<int>.384 /// \brief Map to get the indices of the nodes as dim2::Point<int>. 385 /// 386 /// Map to get the indices of the nodes as dim2::Point<int>. 387 387 class IndexMap { 388 388 public: … … 390 390 typedef GridUGraph::Node Key; 391 391 /// \brief The value type of the map 392 typedef xy<int> Value;392 typedef dim2::Point<int> Value; 393 393 394 394 /// \brief Constructor … … 401 401 /// The subscript operator. 402 402 Value operator[](Key key) const { 403 return xy<int>(graph.row(key), graph.col(key));403 return dim2::Point<int>(graph.row(key), graph.col(key)); 404 404 } 405 405 -
lemon/hypercube_graph.h
r2111 r2207 276 276 /// const int DIM = 3; 277 277 /// HyperCubeGraph graph(DIM); 278 /// xy<double> base[DIM];278 /// dim2::Point<double> base[DIM]; 279 279 /// for (int k = 0; k < DIM; ++k) { 280 280 /// base[k].x = rand() / (RAND_MAX + 1.0); 281 281 /// base[k].y = rand() / (RAND_MAX + 1.0); 282 282 /// } 283 /// HyperCubeGraph::HyperMap< xy<double> >284 /// pos(graph, base, base + DIM, xy<double>(0.0, 0.0));283 /// HyperCubeGraph::HyperMap<dim2::Point<double> > 284 /// pos(graph, base, base + DIM, dim2::Point<double>(0.0, 0.0)); 285 285 ///\endcode 286 286 /// -
lemon/lemon_reader.h
r2153 r2207 39 39 #include <lemon/bits/item_reader.h> 40 40 41 #include <lemon/ xy.h>41 #include <lemon/dim2.h> 42 42 43 43 #include <lemon/concept_check.h> … … 184 184 185 185 template <typename Map> 186 struct Ref< XMap<Map> > {187 typedef XMap<Map> Type;186 struct Ref<dim2::XMap<Map> > { 187 typedef dim2::XMap<Map> Type; 188 188 }; 189 189 template <typename Map> 190 struct Arg< XMap<Map> > {191 typedef const XMap<Map>& Type;190 struct Arg<dim2::XMap<Map> > { 191 typedef const dim2::XMap<Map>& Type; 192 192 }; 193 193 194 194 template <typename Map> 195 struct Ref< YMap<Map> > {196 typedef YMap<Map> Type;195 struct Ref<dim2::YMap<Map> > { 196 typedef dim2::YMap<Map> Type; 197 197 }; 198 198 template <typename Map> 199 struct Arg< YMap<Map> > {200 typedef const YMap<Map>& Type;199 struct Arg<dim2::YMap<Map> > { 200 typedef const dim2::YMap<Map>& Type; 201 201 }; 202 202 -
lemon/lemon_writer.h
r2101 r2207 38 38 #include <lemon/bits/utility.h> 39 39 #include <lemon/maps.h> 40 #include <lemon/ xy.h>40 #include <lemon/dim2.h> 41 41 42 42 #include <lemon/concept_check.h> … … 174 174 175 175 template <typename Map> 176 struct Ref< XMap<Map> > {177 typedef XMap<Map> Type;176 struct Ref<dim2::XMap<Map> > { 177 typedef dim2::XMap<Map> Type; 178 178 }; 179 179 template <typename Map> 180 struct Ref< ConstXMap<Map> > {181 typedef ConstXMap<Map> Type;180 struct Ref<dim2::ConstXMap<Map> > { 181 typedef dim2::ConstXMap<Map> Type; 182 182 }; 183 183 184 184 template <typename Map> 185 struct Ref< YMap<Map> > {186 typedef YMap<Map> Type;185 struct Ref<dim2::YMap<Map> > { 186 typedef dim2::YMap<Map> Type; 187 187 }; 188 188 template <typename Map> 189 struct Ref< ConstYMap<Map> > {190 typedef ConstYMap<Map> Type;189 struct Ref<dim2::ConstYMap<Map> > { 190 typedef dim2::ConstYMap<Map> Type; 191 191 }; 192 192 -
lemon/polynomial.h
r2199 r2207 77 77 ///The following examples shows the usage of the template parameter \c R. 78 78 ///\code 79 /// Polynomial< xy<double> > line(1);80 /// line[0]= xy<double>(12,25);81 /// line[1]= xy<double>(2,7);79 /// Polynomial<dim2::Point<double> > line(1); 80 /// line[0]=dim2::Point<double>(12,25); 81 /// line[1]=dim2::Point<double>(2,7); 82 82 /// ... 83 /// xy<double> d = line.subst<xy<double> >(23.2);83 /// dim2::Point<double> d = line.subst<dim2::Point<double> >(23.2); 84 84 ///\endcode 85 85 ///
Note: See TracChangeset
for help on using the changeset viewer.