[Lemon-commits] [lemon_svn] alpar: r2092 - in hugo/trunk: gui lemon test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:50:05 CET 2006


Author: alpar
Date: Tue Jul 26 16:31:29 2005
New Revision: 2092

Modified:
   hugo/trunk/gui/xml.h
   hugo/trunk/lemon/graph_to_eps.h
   hugo/trunk/lemon/xy.h
   hugo/trunk/test/xy_test.cc

Log:
BoundingBox<T>::operator+=() -> BoundingBox<T>::add() -> 

Modified: hugo/trunk/gui/xml.h
==============================================================================
--- hugo/trunk/gui/xml.h	(original)
+++ hugo/trunk/gui/xml.h	Tue Jul 26 16:31:29 2005
@@ -341,88 +341,88 @@
   //////////////////////////////////////////////////////////////////////
 
   template<class A>
-  void out(XmlWriter &i,const std::auto_ptr<A> &v)
+  void out(XmlWriter &x,const std::auto_ptr<A> &v)
   {
-    i(*v);
+    x(*v);
   }
 
   template<class A>
-  void in(XmlReader &i,std::auto_ptr<A> &v)
+  void in(XmlReader &x,std::auto_ptr<A> &v)
   {
     v=new A;
-    i(*v);
+    x(*v);
   }
 
   //////////////////////////////
 
   template<class A,class B>
-  void out(XmlWriter &i,const std::pair<A,B> &v)
+  void out(XmlWriter &x,const std::pair<A,B> &v)
   {
-    i("first",v.first);
-    i("second",v.second);
+    x("first",v.first);
+    x("second",v.second);
   }
 
   template<class A,class B>
-  void in(XmlReader &i,std::pair<A,B> &v)
+  void in(XmlReader &x,std::pair<A,B> &v)
   {
-    i("first",v.first);
-    i("second",v.second);
+    x("first",v.first);
+    x("second",v.second);
   }
 
   //////////////////////////////
 
   template<class T>
-  void out(XmlWriter &i,const std::list<T> &v)
+  void out(XmlWriter &x,const std::list<T> &v)
   {
     for(typename std::list<T>::const_iterator it=v.begin();
-	it!=v.end();++it) i("item",*it);
+	it!=v.end();++it) x("item",*it);
   }
 
   template<class T>
-  void in(XmlReader &i,std::list<T> &v)
+  void in(XmlReader &x,std::list<T> &v)
   {
-    while(i.nextTag()=="item")
+    while(x.nextTag()=="item")
       {
 	v.push_back(T());
-	i("item",v.back());
+	x("item",v.back());
       }
   }
 
   //////////////////////////////
 
   template<class T>
-  void out(XmlWriter &i,const std::vector<T> &v)
+  void out(XmlWriter &x,const std::vector<T> &v)
   {
     for(typename std::vector<T>::const_iterator it=v.begin();
-	it!=v.end();++it) i("item",*it);
+	it!=v.end();++it) x("item",*it);
   }
 
   template<class T>
-  void in(XmlReader &i,std::vector<T> &v)
+  void in(XmlReader &x,std::vector<T> &v)
   {
-    while(i.nextTag()=="item")
+    while(x.nextTag()=="item")
       {
 	v.push_back(T());
-	i("item",v.back());      
+	x("item",v.back());      
       }
   }
 
   //////////////////////////////
 
   template<class K,class V>
-  void out(XmlWriter &i,const std::map<K,V> &v)
+  void out(XmlWriter &x,const std::map<K,V> &v)
   {
     for(typename std::map<K,V>::const_iterator it=v.begin();
-	it!=v.end();++it) i("item",*it);
+	it!=v.end();++it) x("item",*it);
   }
 
   template<class K,class V>
-  void in(XmlReader &i,std::map<K,V> &v)
+  void in(XmlReader &x,std::map<K,V> &v)
   {
-    while(i.nextTag()=="item")
+    while(x.nextTag()=="item")
       {
 	typename std::map<K,V>::value_type it;
-	i("item",it);
+	x("item",it);
 	v.insert(it);
       }
   }
@@ -430,40 +430,40 @@
   //////////////////////////////
 
   template<class T>
-  void out(XmlWriter &i,const lemon::xy<T> &v)
+  void out(XmlWriter &x,const lemon::xy<T> &v)
   {
-    //   i("x",v.x);
-    //   i("y",v.y);
-    { XmlWriter::LineTag t(i,"x"); i(v.x); }
-    { XmlWriter::ContTag t(i,"y"); i(v.y); }
+    //   x("x",v.x);
+    //   x("y",v.y);
+    { XmlWriter::LineTag t(x,"x"); x(v.x); }
+    { XmlWriter::ContTag t(x,"y"); x(v.y); }
   }
 
   template<class T>
-  void in(XmlReader &i,lemon::xy<T> &v)
+  void in(XmlReader &x,lemon::xy<T> &v)
   {
-    i("x",v.x);
-    i("y",v.y);
+    x("x",v.x);
+    x("y",v.y);
   }
 
   //////////////////////////////
 
   template<class T>
-  void out(XmlWriter &i,const lemon::BoundingBox<T> &v)
+  void out(XmlWriter &x,const lemon::BoundingBox<T> &v)
   {
     if(!v.empty()) {
-      i("point",v.bottomLeft());
-      if(v.bottomLeft()!=v.topRight()) i("point",v.topRight());
+      x("point",v.bottomLeft());
+      if(v.bottomLeft()!=v.topRight()) x("point",v.topRight());
     }
   }
 
   template<class T>
-  void in(XmlReader &i,lemon::BoundingBox<T> &v)
+  void in(XmlReader &x,lemon::BoundingBox<T> &v)
   {
     v.clear();
-    while(i.nextTag()=="point") {
+    while(x.nextTag()=="point") {
       lemon::xy<T> co;
-      i("point",co);
-      v+=co;
+      x("point",co);
+      v.add(co);
     }
   }
   

Modified: hugo/trunk/lemon/graph_to_eps.h
==============================================================================
--- hugo/trunk/lemon/graph_to_eps.h	(original)
+++ hugo/trunk/lemon/graph_to_eps.h	Tue Jul 26 16:31:29 2005
@@ -719,8 +719,8 @@
     for(NodeIt n(g);n!=INVALID;++n) {
       double ns=_nodeSizes[n]*_nodeScale;
       xy<double> p(ns,ns);
-      bb+=p+_coords[n];
-      bb+=-p+_coords[n];
+      bb.add(p+_coords[n]);
+      bb.add(-p+_coords[n]);
     }
     if (bb.empty()) {
       bb = BoundingBox<double>(xy<double>(0,0));

Modified: hugo/trunk/lemon/xy.h
==============================================================================
--- hugo/trunk/lemon/xy.h	(original)
+++ hugo/trunk/lemon/xy.h	Tue Jul 26 16:31:29 2005
@@ -306,7 +306,7 @@
       }
   
       ///Increments a bounding box with a point
-      BoundingBox& operator +=(const xy<T>& u){
+      BoundingBox& add(const xy<T>& u){
         if (_empty){
           bottom_left=top_right=u;
           _empty = false;
@@ -320,17 +320,17 @@
         return *this;
       }
   
-      ///Sums a bounding box and a point
-      BoundingBox operator +(const xy<T>& u){
-        BoundingBox b = *this;
-        return b += u;
-      }
+//       ///Sums a bounding box and a point
+//       BoundingBox operator +(const xy<T>& u){
+//         BoundingBox b = *this;
+//         return b += u;
+//       }
 
       ///Increments a bounding box with an other bounding box
-      BoundingBox& operator +=(const BoundingBox &u){
+      BoundingBox& add(const BoundingBox &u){
         if ( !u.empty() ){
-          *this += u.bottomLeft();
-          *this += u.topRight();
+          this->add(u.bottomLeft());
+	  this->add(u.topRight());
         }
         return *this;
       }
@@ -338,7 +338,20 @@
       ///Sums two bounding boxes
       BoundingBox operator +(const BoundingBox& u){
         BoundingBox b = *this;
-        return b += u;
+        return b.add(u);
+      }
+
+
+      ///Intersection of two bounding boxes
+      BoundingBox operator &(const BoundingBox& u){
+        BoundingBox b;
+	b.bottom_left.x=std::max(this->bottom_left.x,u.bottom_left.x);
+	b.bottom_left.y=std::max(this->bottom_left.y,u.bottom_left.y);
+	b.top_right.x=std::min(this->top_right.x,u.top_right.x);
+	b.top_right.y=std::min(this->top_right.y,u.top_right.y);
+	b._empty = this->_empty || u._empty ||
+	  b.bottom_left.x>top_right.x && b.bottom_left.y>top_right.y;
+        return b;
       }
 
     };//class Boundingbox

Modified: hugo/trunk/test/xy_test.cc
==============================================================================
--- hugo/trunk/test/xy_test.cc	(original)
+++ hugo/trunk/test/xy_test.cc	Tue Jul 26 16:31:29 2005
@@ -51,9 +51,9 @@
 	BB doboz1;
 	check(doboz1.empty(), "It should be empty.");
 	
-	doboz1 += a;
+	doboz1.add(a);
 	check(!doboz1.empty(), "It should not be empty.");
-	doboz1 += b;
+	doboz1.add(b);
 
 	check(doboz1.bottomLeft().x==1 && 
 	      doboz1.bottomLeft().y==2 &&
@@ -74,7 +74,7 @@
 	check(!doboz2.empty(),
 	      "It should not be empty. Constructed from 1 point.");
 
-	doboz2 += doboz1;
+	doboz2.add(doboz1);
 	check(doboz2.inside(seged),
 	      "It should be inside. Incremented a box with an other.");
 }



More information about the Lemon-commits mailing list