Open
Graph Drawing
Framework

 v.2012.05
 

QuadTreeNodeNM.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  
00042 #ifdef _MSC_VER
00043 #pragma once
00044 #endif
00045 
00046 #ifndef OGDF_QUAD_TREE_NODE_NM_H
00047 #define OGDF_QUAD_TREE_NODE_NM_H
00048 
00049 
00050 #include <ogdf/basic/Graph.h>
00051 #include <ogdf/basic/List.h>
00052 #include <ogdf/basic/geometry.h>
00053 #include <ogdf/internal/energybased/ParticleInfo.h>
00054 #include <complex>
00055 
00056 
00057 using std::complex;
00058 
00059 namespace ogdf {
00060 
00061 class QuadTreeNodeNM
00062 {
00063    //Helping data structure that stores the information needed to represent 
00064    //a node of the reduced quad tree in the New Multipole Method (NMM).
00065 
00066    //Outputstream for QuadTreeNodeNM.
00067    friend ostream &operator<< (ostream &,const QuadTreeNodeNM &);
00068    
00069    //Inputstream for QuadTreeNodeNM.
00070    friend istream &operator>> (istream &,QuadTreeNodeNM &);
00071            
00072    public:
00073       
00074       QuadTreeNodeNM();     //constructor
00075       ~QuadTreeNodeNM();    //destructor
00076       
00077       void set_Sm_level(int l) { Sm_level = l;}
00078       void set_Sm_downleftcorner(DPoint dlc) {Sm_downleftcorner = dlc;}
00079       void set_Sm_boxlength(double l) {Sm_boxlength = l;}    
00080       void set_x_List_ptr(List<ParticleInfo>* x_ptr) {L_x_ptr = x_ptr;}
00081       void set_y_List_ptr(List<ParticleInfo>* y_ptr) {L_y_ptr = y_ptr;}
00082       void set_particlenumber_in_subtree(int p){ subtreeparticlenumber = p;}
00083       void set_Sm_center(complex<double> c) {Sm_center = c;}
00084       void set_contained_nodes(List<node>&  L) {contained_nodes = L;} 
00085       void pushBack_contained_nodes(node v) {contained_nodes.pushBack(v);}
00086       node pop_contained_nodes() {return contained_nodes.popFrontRet();}            
00087       bool contained_nodes_empty() {return contained_nodes.empty();}
00088  
00089       void set_I(List<QuadTreeNodeNM*>& l) {I = l;}  
00090       void set_D1(List<QuadTreeNodeNM*>& l)  {D1 = l;}  
00091       void set_D2(List<QuadTreeNodeNM*>& l)  {D2 = l;}  
00092       void set_M(List<QuadTreeNodeNM*>& l)  {M = l;}  
00093 
00094       //LE[i] is set to local[i] for i = 0 to precision and space for LE is reserved.
00095       void set_locale_exp(Array<complex<double> > &local,int precision)
00096         {
00097       int i;
00098       LE = new complex<double> [precision+1];
00099       for (i = 0 ; i<= precision; i++)
00100         LE[i] = local[i]; 
00101     }
00102  
00103       //ME[i] is set to multi[i] for i = 0 to precision and space for LE is reserved.
00104       void set_multipole_exp(Array<complex<double> > &multi,int precision)
00105         {
00106       int i;
00107       ME = new complex<double> [precision+1];
00108       for (i = 0 ; i<= precision; i++)
00109         ME[i] = multi[i]; 
00110     }
00111 
00112        //ME[i] is set to multi[i] for i = 0 to precision and no space for LE is reserved.
00113       void replace_multipole_exp(Array<complex<double> > &multi,int precision)
00114         {
00115       int i;
00116       for (i = 0 ; i<= precision; i++)
00117         ME[i] = multi[i]; 
00118     }
00119 
00120       void set_father_ptr (QuadTreeNodeNM* f) { father_ptr = f;}
00121       void set_child_lt_ptr(QuadTreeNodeNM* c) {child_lt_ptr = c;}   
00122       void set_child_rt_ptr(QuadTreeNodeNM* c) {child_rt_ptr = c;}   
00123       void set_child_lb_ptr(QuadTreeNodeNM* c) {child_lb_ptr = c;}   
00124       void set_child_rb_ptr(QuadTreeNodeNM* c) {child_rb_ptr = c;}  
00125      
00126       bool is_root() {if(father_ptr == NULL) return true; else return false;}   
00127       bool is_leaf(){if ((child_lt_ptr == NULL) &&(child_rt_ptr == NULL) &&(child_lb_ptr
00128                             == NULL) && (child_rb_ptr == NULL)) 
00129                       return true; else return false;}     
00130       bool child_lt_exists() { if (child_lt_ptr != NULL) return true; else return false;}
00131       bool child_rt_exists() { if (child_rt_ptr != NULL) return true; else return false;}
00132       bool child_lb_exists() { if (child_lb_ptr != NULL) return true; else return false;}
00133       bool child_rb_exists() { if (child_rb_ptr != NULL) return true; else return false;}
00134 
00135       int get_Sm_level () const {return Sm_level;}
00136       DPoint get_Sm_downleftcorner () const {return Sm_downleftcorner;}
00137       double get_Sm_boxlength () const {return Sm_boxlength; }  
00138       List<ParticleInfo>*  get_x_List_ptr()  {return L_x_ptr;}
00139       List<ParticleInfo>*  get_y_List_ptr()  {return L_y_ptr;}
00140       int get_particlenumber_in_subtree()const { return subtreeparticlenumber;}
00141       complex<double> get_Sm_center() const {return Sm_center;}
00142       complex<double>* get_local_exp () const {return LE;}
00143       complex<double>* get_multipole_exp () const {return ME;}
00144       void get_contained_nodes(List<node>& L) const {L =  contained_nodes;}
00145       void get_I (List <QuadTreeNodeNM*>& l){l = I;}
00146       void get_D1 (List <QuadTreeNodeNM*>& l){l = D1;}
00147       void get_D2 (List <QuadTreeNodeNM*>& l){l = D2;}
00148       void get_M (List <QuadTreeNodeNM*>& l){l = M;}
00149 
00150       QuadTreeNodeNM* get_father_ptr ()   const {return father_ptr;}
00151       QuadTreeNodeNM* get_child_lt_ptr () const {return child_lt_ptr;}
00152       QuadTreeNodeNM* get_child_rt_ptr () const {return child_rt_ptr;}
00153       QuadTreeNodeNM* get_child_lb_ptr () const {return child_lb_ptr;}
00154       QuadTreeNodeNM* get_child_rb_ptr () const {return child_rb_ptr;}
00155    
00156    private:         
00157   
00158     int  Sm_level;                     //level of the small cell
00159     DPoint Sm_downleftcorner;          //coords of the down left corner of the small cell
00160     double Sm_boxlength;               //length of small cell
00161     List<ParticleInfo>* L_x_ptr;       //points to the lists that contain each Particle 
00162                                        //of G with its x(y)coordinate in increasing order
00163     List<ParticleInfo>* L_y_ptr;       //and a cross reference to the list_item in the
00164                                        //list  with the other coordinate
00165     int subtreeparticlenumber;         //the number of particles in the subtree rooted
00166                                        //at this node
00167     complex<double>  Sm_center;        //center of the small cell    
00168     complex<double>* ME;               //Multipole Expansion terms 
00169     complex<double>* LE;               //Locale Expansion terms
00170     List <node>  contained_nodes;      //list of nodes of G that are contained in this
00171                                        //QuadTreeNode  (emty if it is not a leave of
00172                                        //the ModQuadTree
00173     List <QuadTreeNodeNM*> I;          //the list of min. ill sep. nodes in DIM2
00174     List <QuadTreeNodeNM*> D1,D2;      //list of neighbouring(=D1) and not adjacent(=D2)
00175                                        //leaves for direct force calculation in DIM2
00176     List<QuadTreeNodeNM*>  M;          //list of nodes with multipole force contribution
00177                                        //like in DIM2
00178     QuadTreeNodeNM*  father_ptr;   //points to the father node
00179     QuadTreeNodeNM*  child_lt_ptr; //points to left top child
00180     QuadTreeNodeNM*  child_rt_ptr; //points to right bottom child
00181     QuadTreeNodeNM*  child_lb_ptr; //points to left bottom child
00182     QuadTreeNodeNM*  child_rb_ptr; //points to right bottom child
00183  };
00184 }//namespace ogdf
00185 #endif
00186 
00187