Open
Graph Drawing
Framework

 v.2012.05
 

EdgeComparer.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  
00047 #ifdef _MSC_VER
00048 #pragma once
00049 #endif
00050 
00051 
00052 #ifndef OGDF_EDGECOMPARER_H
00053 #define OGDF_EDGECOMPARER_H
00054 
00055 
00056 
00057 #include <ogdf/planarity/PlanRep.h>
00058 #include <ogdf/basic/GraphAttributes.h>
00059 
00060 namespace ogdf {
00061 
00063 
00074 class OGDF_EXPORT EdgeComparer : public VComparer<adjEntry>
00075 {
00076 public:
00077     //order: clockwise
00078     
00079     EdgeComparer(const GraphAttributes& AG, const PlanRep& PR) : 
00080       m_AG(&AG), m_PR(&PR)
00081     {}
00082 
00084     EdgeComparer(const GraphAttributes &AG) : m_AG(&AG), m_PR(0) {}
00085 
00086     int compare(const adjEntry &e1, const adjEntry &e2) const;
00087 
00089     bool before(const DPoint u, const DPoint v, const DPoint w) const;
00090     
00091 private:
00092     
00094     int orientation(const DPoint u, 
00095                     const DPoint v, 
00096                     const DPoint w) const;
00097 
00099     int compareVectors(const double& x1, 
00100                         const double& y1, 
00101                         const double& x2, 
00102                         const double& y2) const;
00104     double angle(DPoint p, DPoint q, DPoint r) const;
00105 
00106     inline int signOf(const double& x) const
00107     { 
00108         if ( x == 0 ) return 0;
00109         else if (x > 0 ) return 1;
00110              else return -1;
00111     }
00112 
00113 
00114     const GraphAttributes *m_AG;
00115     const PlanRep *m_PR;
00116 };//EdgeComparer
00117 
00118 
00119 }//namespace ogdf
00120 
00121 #endif