Open
Graph Drawing
Framework

 v.2010.10
 

ParticleInfo.h

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