Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046
00047 #ifndef OGDF_GRID_LAYOUT_H
00048 #define OGDF_GRID_LAYOUT_H
00049
00050
00051 #include <ogdf/basic/NodeArray.h>
00052 #include <ogdf/basic/geometry.h>
00053
00054
00055 namespace ogdf {
00056
00057 class Layout;
00058
00059
00060
00064 class OGDF_EXPORT GridLayout
00065 {
00066 public:
00068 GridLayout() { }
00069
00071 GridLayout(const Graph &G) : m_x(G,0), m_y(G,0), m_bends(G) { }
00072
00073
00074 virtual ~GridLayout() { }
00075
00076
00078 const NodeArray<int> &x() const { return m_x; }
00080 NodeArray<int> &x() { return m_x; }
00081
00083 const NodeArray<int> &y() const { return m_y; }
00085 NodeArray<int> &y() { return m_y; }
00086
00088 const EdgeArray<IPolyline> &bends() const { return m_bends; }
00090 EdgeArray<IPolyline> &bends() { return m_bends; }
00091
00092
00094 const int &x(node v) const { return m_x[v]; }
00096 int &x(node v) { return m_x[v]; }
00097
00099 const int &y(node v) const { return m_y[v]; }
00101 int &y(node v) { return m_y[v]; }
00102
00103
00105 const IPolyline &bends(edge e) const { return m_bends[e]; }
00107 IPolyline &bends(edge e) { return m_bends[e]; }
00108
00110 IPolyline polyline(edge e) const;
00111
00112
00114 void init(const Graph &G) {
00115 m_x.init(G,0);
00116 m_y.init(G,0);
00117 m_bends.init(G);
00118 }
00119
00121 void init() {
00122 m_x.init();
00123 m_y.init();
00124 m_bends.init();
00125 }
00126
00128 IPolyline getCompactBends(edge e) const;
00129
00131 void compactAllBends();
00132
00141 bool checkLayout();
00142
00153 void computeBoundingBox(int &xmin, int &xmax, int &ymin, int &ymax);
00154
00156 int totalManhattanEdgeLength() const;
00157
00158 int maxManhattanEdgeLength() const;
00159 int manhattanEdgeLength(edge e) const;
00160
00162 double totalEdgeLength() const;
00163
00165 int numberOfBends() const;
00166
00173 virtual void remap(Layout &drawing);
00174
00175 static int manhattanDistance(const IPoint &ip1, const IPoint &ip2);
00176 static double euclideanDistance(const IPoint &ip1, const IPoint &ip2);
00177
00178 protected:
00179 NodeArray<int> m_x;
00180 NodeArray<int> m_y;
00181 EdgeArray<IPolyline> m_bends;
00182
00183 private:
00184 static bool isRedundant(IPoint &p1, IPoint &p2, IPoint &p3);
00185 static void compact(IPolyline &ip);
00186
00187
00188 OGDF_MALLOC_NEW_DELETE
00189 };
00190
00191
00192 }
00193
00194 #endif