Open
Graph Drawing
Framework

 v.2012.05
 

OrthoShaper.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  
00045 #ifdef _MSC_VER
00046 #pragma once
00047 #endif
00048 
00049 
00050 #ifndef OGDF_ORTHO_FORMER_GENERIC_H
00051 #define OGDF_ORTHO_FORMER_GENERIC_H
00052 
00053 
00054 #include <ogdf/orthogonal/OrthoRep.h>
00055 #include <ogdf/planarity/PlanRepUML.h>
00056 
00057 
00058 namespace ogdf {
00059 
00060 const bool angleMaxBound = true;
00061 const bool angleMinBound = false;
00062 
00063 class OGDF_EXPORT OrthoShaper
00064 {
00065 public:
00066 
00067     enum n_type {low, high, inner, outer}; //types of network nodes: 
00068                                            //nodes and faces
00069 
00070     OrthoShaper() {
00071         setDefaultSettings();
00072     };
00073 
00074     ~OrthoShaper() {};
00075 
00076     // Given a planar representation for a UML graph and its planar 
00077     // combinatorial embedding, call() produces an orthogonal 
00078     // representation using Tamassias bend minimization algorithm
00079     // with a flow network where every flow unit defines 90 degree angle
00080     // in traditional mode.
00081 
00082     void call(PlanRepUML &PG,
00083         CombinatorialEmbedding &E,
00084         OrthoRep &OR,
00085         bool fourPlanar = true) throw(AlgorithmFailureException);
00086 
00087     //sets the default settings used in the standard constructor
00088     void setDefaultSettings()
00089     {
00090         m_distributeEdges = true; // true;  //try to distribute edges to all node sides
00091         m_fourPlanar      = true;  //do not allow zero degree angles at high degree
00092         m_allowLowZero    = false; //do allow zero degree at low degree nodes
00093         m_multiAlign      = true;//true;  //start/end side of multi edges match
00094         m_traditional     = true;//true;  //prefer 3/1 flow at degree 2 (false: 2/2)
00095         m_deg4free        = false; //allow free angle assignment at degree four
00096         m_align           = false; //align nodes on same hierarchy level
00097         m_startBoundBendsPerEdge = 0; //don't use bound on bend number per edge
00098     }
00099 
00100     // returns option distributeEdges
00101     bool distributeEdges() { return m_distributeEdges; }
00102     // sets option distributeEdges to b
00103     void distributeEdges(bool b) { m_distributeEdges = b; }
00104 
00105     // returns option multiAlign
00106     bool multiAlign() { return m_multiAlign; }
00107     // sets option multiAlign to b
00108     void multiAlign(bool b) { m_multiAlign = b; }
00109 
00110     // returns option traditional
00111     bool traditional() { return m_traditional; }
00112     // sets option traditional to b
00113     void traditional(bool b) { m_traditional = b; }
00114 
00115     //returns option deg4free
00116     bool fixDegreeFourAngles() { return m_deg4free; }
00117     //sets option deg4free
00118     void fixDegreeFourAngles(bool b) { m_deg4free = b; }
00119 
00120     //alignment of brothers in hierarchies
00121     void align(bool al) {m_align = al;}
00122     bool align() {return m_align;}
00123 
00126     void setBendBound(int i){ OGDF_ASSERT(i >= 0); m_startBoundBendsPerEdge = i;}
00127     int getBendBound(){return m_startBoundBendsPerEdge;}
00128 
00129 private:
00130     bool m_distributeEdges; // distribute edges among all sides if degree > 4
00131     bool m_fourPlanar;      // should the input graph be four planar 
00132                             // (no zero degree)
00133     bool m_allowLowZero;    // allow low degree nodes zero degree
00134                             // (to low for zero...)
00135     bool m_multiAlign;      // multi edges aligned on the same side
00136     bool m_deg4free;        // allow degree four nodes free angle assignment
00137     bool m_traditional;     // do not prefer 180 degree angles,
00138                             // traditional is not tamassia,
00139     // traditional is a kandinsky - ILP - like network with node supply 4,
00140     // not traditional interprets angle flow zero as 180 degree, "flow
00141     // through the node"
00142     bool m_align;           //try to achieve an alignment in hierarchy levels
00143     // A maximum number of bends per edge can be specified in
00144     // m_startBoundBendsPerEdge. If the algorithm is not successful in
00145     // producing a bend minimal representation subject to
00146     // startBoundBendsPerEdge, it successively enhances the bound by
00147     // one trying to compute an orthogonal representation.
00148     //
00149     // Using m_startBoundBendsPerEdge may not produce a bend minimal
00150     // representation in general.
00151     int m_startBoundBendsPerEdge; 
00152 
00153 
00154     //set angle boundary
00155     //warning: sets upper AND lower bounds, therefore may interfere with existing bounds
00156     void setAngleBound(edge netArc, int angle, EdgeArray<int>& lowB,
00157                   EdgeArray<int>& upB, EdgeArray<edge>& aTwin, bool maxBound = true)
00158     {
00159         //vorlaeufig
00160         OGDF_ASSERT(!m_traditional);
00161         if (m_traditional)
00162         {
00163             switch (angle)
00164             {
00165                 case 0:
00166                 case 90:
00167                 case 180:
00168                         break;
00169                 OGDF_NODEFAULT
00170             }//switch
00171         }//trad
00172         else
00173         {
00174             switch (angle)
00175             {
00176                 case 0: if (maxBound)
00177                         {
00178                             upB[netArc] = lowB[netArc] = 2;
00179                             edge e2 = aTwin[netArc];
00180                             if (e2) 
00181                             {
00182                                 upB[e2] = lowB[e2] = 0;
00183                             }
00184                         }
00185                         else
00186                         {
00187                             upB[netArc] = 2; lowB[netArc] = 0;
00188                             edge e2 = aTwin[netArc];
00189                             if (e2) 
00190                             {
00191                                 upB[e2] = 2;
00192                                 lowB[e2] = 0;
00193                             }
00194 
00195                         }
00196                        break;
00197                 case 90:
00198                         if (maxBound)
00199                         {
00200                             lowB[netArc] = 1;
00201                             upB[netArc] = 2;
00202                             edge e2 = aTwin[netArc];
00203                             if (e2) 
00204                             {
00205                                 upB[e2] = lowB[e2] = 0;
00206                             }
00207                         }
00208                         else
00209                         {
00210                             upB[netArc] = 1; 
00211                             lowB[netArc] = 0;
00212                             edge e2 = aTwin[netArc];
00213                             if (e2) 
00214                             {
00215                                 upB[e2] = 2;
00216                                 lowB[e2] = 0;
00217                             }
00218 
00219                         }
00220                         break;
00221                 case 180:
00222                         if (maxBound)
00223                         {
00224                             lowB[netArc] = 0;
00225                             upB[netArc] = 2;
00226                             edge e2 = aTwin[netArc];
00227                             if (e2) 
00228                             {
00229                                 upB[e2] = lowB[e2] = 0;
00230                             }
00231                         }
00232                         else
00233                         {
00234                             upB[netArc] = 0; 
00235                             lowB[netArc] = 0;
00236                             edge e2 = aTwin[netArc];
00237                             if (e2) 
00238                             {
00239                                 upB[e2] = 2;
00240                                 lowB[e2] = 0;
00241                             }
00242 
00243                         }
00244                         break;
00245                 OGDF_NODEFAULT // wrong bound
00246             }//switch       
00247         }//progressive
00248 
00249     }//setAngle
00250 };
00251 
00252 
00253 } // end namespace ogdf
00254 
00255 
00256 #endif