Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

GridLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/NodeArray.h>
35 #include <ogdf/basic/EdgeArray.h>
36 #include <ogdf/basic/Layout.h>
37 #include <ogdf/basic/geometry.h>
38 
39 namespace ogdf {
40 
47 {
48 public:
50  GridLayout() { }
51 
53  explicit GridLayout(const Graph &G) : m_x(G,0), m_y(G,0), m_bends(G) { }
54 
56  virtual ~GridLayout() { }
57 
58 
60  const NodeArray<int> &x() const { return m_x; }
62  NodeArray<int> &x() { return m_x; }
63 
65  const NodeArray<int> &y() const { return m_y; }
67  NodeArray<int> &y() { return m_y; }
68 
70  const EdgeArray<IPolyline> &bends() const { return m_bends; }
72  EdgeArray<IPolyline> &bends() { return m_bends; }
73 
74 
76  const int &x(node v) const { return m_x[v]; }
78  int &x(node v) { return m_x[v]; }
79 
81  const int &y(node v) const { return m_y[v]; }
83  int &y(node v) { return m_y[v]; }
84 
85 
87  const IPolyline &bends(edge e) const { return m_bends[e]; }
89  IPolyline &bends(edge e) { return m_bends[e]; }
90 
92  IPolyline polyline(edge e) const;
93 
94 
96  void init(const Graph &G) {
97  m_x.init(G,0);
98  m_y.init(G,0);
99  m_bends.init(G);
100  }
101 
103  void init() {
104  m_x.init();
105  m_y.init();
106  m_bends.init();
107  }
108 
110  IPolyline getCompactBends(edge e) const;
111 
113  void compactAllBends();
114 
123  bool checkLayout();
124 
135  void computeBoundingBox(int &xmin, int &xmax, int &ymin, int &ymax);
136 
138  int totalManhattanEdgeLength() const;
139 
140  int maxManhattanEdgeLength() const;
141  int manhattanEdgeLength(edge e) const;
142 
144  double totalEdgeLength() const;
145 
147  int numberOfBends() const;
148 
155  virtual void remap(Layout &drawing);
156 
157  static int manhattanDistance(const IPoint &ip1, const IPoint &ip2);
158  static double euclideanDistance(const IPoint &ip1, const IPoint &ip2);
159 
160 protected:
164 
165 private:
166  static bool isRedundant(IPoint &p1, IPoint &p2, IPoint &p3);
167  static void compact(IPolyline &ip);
168 
170 };
171 
172 }
Representation of a graph&#39;s grid layout.
Definition: GridLayout.h:46
const int & y(node v) const
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:81
NodeArray< int > & x()
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:62
NodeArray< int > m_x
The x-coordinates of nodes.
Definition: GridLayout.h:161
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
const NodeArray< int > & y() const
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:65
NodeArray< int > m_y
The y-coordinates of nodes.
Definition: GridLayout.h:162
EdgeArray< IPolyline > m_bends
The bend points of edges.
Definition: GridLayout.h:163
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
GridLayout()
Creates an instance of a grid layout (associated with no graph).
Definition: GridLayout.h:50
EdgeArray< IPolyline > & bends()
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:72
const int & x(node v) const
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:76
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
NodeArray< int > & y()
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:67
virtual ~GridLayout()
Destruction.
Definition: GridLayout.h:56
Declaration of class Layout.
int & x(node v)
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:78
const EdgeArray< IPolyline > & bends() const
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:70
Declaration and implementation of EdgeArray class.
void init()
Initializes the grid layout for no graph (frees memory).
Definition: GridLayout.h:103
Class for the representation of edges.
Definition: Graph_d.h:292
void init(const Graph &G)
Initializes the grid layout for graph G.
Definition: GridLayout.h:96
Class for the representation of nodes.
Definition: Graph_d.h:169
Declaration and implementation of NodeArray class.
IPolyline & bends(edge e)
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:89
Polylines with PointType points.
Definition: geometry.h:263
int & y(node v)
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:83
GridLayout(const Graph &G)
Creates an instance of a grid layout associated with G.
Definition: GridLayout.h:53
The namespace for all OGDF objects.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment, DPolygon, DRect, DIntersectableRect.
const IPolyline & bends(edge e) const
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:87
const NodeArray< int > & x() const
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:60
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition: Layout.h:46