Open
Graph Drawing
Framework

 v.2012.05
 

ParticleInfo.h
Go to the documentation of this file.
00001 /*
00002  * $Revision: 2299 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 
00007  ***************************************************************/
00008  
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046 
00047 #ifndef OGDF_PARTICLE_INFO_H
00048 #define OGDF_PARTICLE_INFO_H
00049 
00050 #include <ogdf/basic/Graph.h>
00051 #include <ogdf/basic/List.h>
00052 
00053 namespace ogdf {
00054 
00055 class OGDF_EXPORT ParticleInfo
00056 {
00057    //Helping data structure for building up the reduced quad tree by NMM.
00058 
00059    //Outputstream for ParticleInfo.
00060    friend ostream &operator<< (ostream & output, const ParticleInfo & A)
00061    {
00062      output <<" node_index "<<A.vertex->index()<<" x_y_coord "<<A.x_y_coord;
00063      if(A.marked == true) 
00064        output<<" marked ";
00065      else 
00066        output<<" unmarked ";
00067      output<<" sublist_ptr ";
00068      if (A.subList_ptr == NULL) 
00069        output<<"NULL";
00070      else 
00071        output<<A.subList_ptr; 
00072      return output;
00073    }
00074 
00075    //inputstream for ParticleInfo
00076    friend istream &operator>> (istream & input,  ParticleInfo & A)
00077    {
00078      input >> A;
00079      return input;
00080    }
00081 
00082    public:
00083    
00084    ParticleInfo()    //constructor
00085       {
00086     vertex = NULL;
00087     x_y_coord = 0;
00088     cross_ref_item = NULL;
00089     copy_item = NULL;
00090     subList_ptr = NULL;
00091     marked = false;
00092     tmp_item = NULL;
00093       }
00094  
00095      ~ParticleInfo(){;}   //destructor
00096           
00097       void set_vertex(node v) {vertex = v;}
00098       void set_x_y_coord(double c) {x_y_coord = c;}
00099       void set_cross_ref_item (ListIterator<ParticleInfo> it) {cross_ref_item = it;}
00100       void set_subList_ptr(List<ParticleInfo>* ptr){subList_ptr = ptr;}
00101       void set_copy_item (ListIterator<ParticleInfo> it) {copy_item = it;}
00102       void mark() {marked = true;}
00103       void unmark() {marked = false;}   
00104       void set_tmp_cross_ref_item(ListIterator<ParticleInfo> it) {tmp_item = it;}
00105 
00106       node get_vertex() const { return vertex; }  
00107       double get_x_y_coord() const {return x_y_coord;}
00108       ListIterator<ParticleInfo> get_cross_ref_item() const{ return cross_ref_item;}
00109       List<ParticleInfo>* get_subList_ptr()const {return subList_ptr;}
00110       ListIterator<ParticleInfo> get_copy_item() const{return copy_item;}
00111       bool is_marked()const{ return marked;} 
00112       ListIterator<ParticleInfo> get_tmp_cross_ref_item() const {return tmp_item;}    
00113 
00114    private:         
00115       node vertex;      //the vertex of G that is associated with this attributes
00116       double x_y_coord; //the x (resp. y) coordinate of the actual position of the vertex
00117       ListIterator<ParticleInfo> cross_ref_item; //the Listiterator of the
00118                                                  //ParticleInfo-Element that 
00119                             //containes the vertex in the List storing the other
00120                                 //coordinates (a cross reference)
00121       List<ParticleInfo>*  subList_ptr; //points to the subList of L_x(L_y) where the
00122                                         //actual entry of ParticleInfo has to be stored
00123       ListIterator<ParticleInfo>  copy_item;  //the item of this entry in the copy List
00124       bool marked; //indicates if this ParticleInfo object is marked or not      
00125       ListIterator<ParticleInfo> tmp_item;  //a temporily item that is used to construct 
00126                                             //the cross references for the copy_Lists 
00127                                             //and the subLists
00128                       
00129        
00130 };
00131 
00132 //Needed for sorting algorithms in ogdf/List and ogdf/Array.
00133 class ParticleInfoComparer {
00134 public:
00135    //Returns -1(1) if height of a <(>) height of b. If they are equal 0 is
00136    //returned.
00137    static int compare(const ParticleInfo& a,const ParticleInfo & b)
00138    {
00139      double p = a.get_x_y_coord();
00140      double q = b.get_x_y_coord();
00141      if(p < q ) return  -1;
00142      else if(p > q ) return 1;
00143      else return 0;
00144    }
00145    OGDF_AUGMENT_STATICCOMPARER(ParticleInfo)
00146 };
00147 }//namespace ogdf
00148 #endif
00149 
00150