Open
Graph Drawing
Framework

 v.2010.10
 

EdgeComparer.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  
00057 #ifdef _MSC_VER
00058 #pragma once
00059 #endif
00060 
00061 
00062 #ifndef OGDF_EDGECOMPARER_H
00063 #define OGDF_EDGECOMPARER_H
00064 
00065 
00066 
00067 #include <ogdf/planarity/PlanRep.h>
00068 #include <ogdf/basic/GraphAttributes.h>
00069 
00070 namespace ogdf {
00071 
00073 
00084 class OGDF_EXPORT EdgeComparer : public VComparer<adjEntry>
00085 {
00086 public:
00087     //order: clockwise
00088     
00089     EdgeComparer(const GraphAttributes& AG, const PlanRep& PR) : 
00090       m_AG(&AG), m_PR(&PR)
00091     {}
00092 
00094     EdgeComparer(const GraphAttributes &AG) : m_AG(&AG), m_PR(0) {}
00095 
00096     int compare(const adjEntry &e1, const adjEntry &e2) const;
00097 
00099     bool before(const DPoint u, const DPoint v, const DPoint w) const;
00100     
00101 private:
00102     
00104     int orientation(const DPoint u, 
00105                     const DPoint v, 
00106                     const DPoint w) const;
00107 
00109     int compareVectors(const double& x1, 
00110                         const double& y1, 
00111                         const double& x2, 
00112                         const double& y2) const;
00114     double angle(DPoint p, DPoint q, DPoint r) const;
00115 
00116     inline int signOf(const double& x) const
00117     { 
00118         if ( x == 0 ) return 0;
00119         else if (x > 0 ) return 1;
00120              else return -1;
00121     }
00122 
00123 
00124     const GraphAttributes *m_AG;
00125     const PlanRep *m_PR;
00126 };//EdgeComparer
00127 
00128 
00129 }//namespace ogdf
00130 
00131 #endif