Open
Graph Drawing
Framework

 v.2012.05
 

VisibilityLayout.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  
00041 //***
00042 // Visibility Layout Method. see "Graph Drawing" by Di Battista et al.
00043 //***
00044 
00045 
00046 #ifdef _MSC_VER
00047 #pragma once
00048 #endif
00049 
00050 #ifndef OGDF_VISIBILITY_LAYOUT_H
00051 #define OGDF_VISIBILITY_LAYOUT_H
00052 
00053 #include <ogdf/module/UpwardPlanarizerModule.h>
00054 #include <ogdf/module/LayoutModule.h>
00055 #include <ogdf/basic/ModuleOption.h>
00056 #include <ogdf/basic/GraphAttributes.h>
00057 #include <ogdf/basic/FaceArray.h>
00058 #include <ogdf/upward/UpwardPlanRep.h>
00059 #include <ogdf/upward/SubgraphUpwardPlanarizer.h>
00060 
00061 namespace ogdf {
00062 
00063 
00064 class VisibilityLayout : public LayoutModule
00065 {
00066 public:
00067 
00068     VisibilityLayout() {
00069         m_grid_dist = 1;
00070         // set default module       
00071         m_upPlanarizer.set(new SubgraphUpwardPlanarizer());         
00072     }   
00073 
00074     virtual void call(GraphAttributes &GA);
00075 
00076     void layout(GraphAttributes &GA, const UpwardPlanRep &UPROrig);
00077     
00078     void setUpwardPlanarizer(UpwardPlanarizerModule *upPlanarizer) {
00079         m_upPlanarizer.set(upPlanarizer);
00080     }
00081 
00082     void setMinGridDistance(int dist) {m_grid_dist = dist;}
00083 
00084 
00085 
00086 private:    
00087 
00088     //min grid distance
00089     int m_grid_dist;
00090 
00091     Graph D; // the dual graph of the UPR
00092     node s_D; // super source of D
00093     node t_D; // super sink f D
00094 
00095     //node segment of the visibility representation
00096     struct NodeSegment {
00097         int y; //y coordinate
00098         int x_l; // left x coordinate
00099         int x_r; // right x coordiante
00100     };
00101 
00102     // edge segment of the visibility representation
00103     struct EdgeSegment {
00104         int y_b; // bottom y coordinate
00105         int y_t; // top y coordinate
00106         int x; // x coordiante
00107     };
00108 
00109     //mapping node to node segment of visibility presentation
00110     NodeArray<NodeSegment> nodeToVis;
00111 
00112     //mapping edge to edge segment of visibility presentation
00113     EdgeArray<EdgeSegment> edgeToVis;
00114     
00115     FaceArray<node> faceToNode;
00116     NodeArray<face> leftFace_node;
00117     NodeArray<face> rightFace_node;
00118     EdgeArray<face> leftFace_edge;
00119     EdgeArray<face> rightFace_edge;
00120 
00121     ModuleOption<UpwardPlanarizerModule> m_upPlanarizer; // upward planarizer
00122         
00123     void constructDualGraph(UpwardPlanRep &UPR);
00124 
00125     void constructVisibilityRepresentation(UpwardPlanRep &UPR);
00126 
00127 
00128 };
00129 
00130 
00131 }//namespace
00132 
00133 #endif