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_CONVEX_HULL_H 00047 #define OGDF_CONVEX_HULL_H 00048 00049 #include <ogdf/basic/GraphAttributes.h> 00050 #include <ogdf/basic/geometry.h> 00051 #include <ogdf/internal/energybased/MultilevelGraph.h> 00052 #include <vector> 00053 00054 namespace ogdf { 00055 00056 // all returned Polygons are clockwise (cw) 00057 class OGDF_EXPORT ConvexHull { 00058 private: 00059 bool sameDirection(const DPoint &start, const DPoint &end, const DPoint &s, const DPoint &e) const; 00060 00061 // calculates a convex hull very quickly but only works with cross-free Polygons! 00062 DPolygon conv(const DPolygon &poly) const; 00063 00064 // Calculates the Part of the convex hull that is left of line start-end 00065 // /a points should only contain points that really are left of the line. 00066 void leftHull(std::vector<DPoint> points, DPoint &start, DPoint &end, DPolygon &hullPoly) const; 00067 00068 00069 public: 00070 ConvexHull(); 00071 ~ConvexHull(); 00072 00073 DPoint calcNormal(const DPoint &start, const DPoint &end) const; 00074 double leftOfLine(const DPoint &normal, const DPoint &point, const DPoint &pointOnLine) const; 00075 00076 DPolygon call(std::vector<DPoint> points) const; 00077 DPolygon call(GraphAttributes &GA) const; 00078 DPolygon call(MultilevelGraph &MLG) const; 00079 00080 }; 00081 00082 } // namespace ogdf 00083 00084 #endif