Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GridLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/EdgeArray.h>
35 #include <ogdf/basic/Layout.h>
36 #include <ogdf/basic/NodeArray.h>
37 #include <ogdf/basic/geometry.h>
38 
39 namespace ogdf {
40 
47 public:
49  GridLayout() { }
50 
52  explicit GridLayout(const Graph& G) : m_x(G, 0), m_y(G, 0), m_bends(G) { }
53 
55  virtual ~GridLayout() { }
56 
58  const NodeArray<int>& x() const { return m_x; }
59 
61  NodeArray<int>& x() { return m_x; }
62 
64  const NodeArray<int>& y() const { return m_y; }
65 
67  NodeArray<int>& y() { return m_y; }
68 
70  const EdgeArray<IPolyline>& bends() const { return m_bends; }
71 
73  EdgeArray<IPolyline>& bends() { return m_bends; }
74 
76  const int& x(node v) const { return m_x[v]; }
77 
79  int& x(node v) { return m_x[v]; }
80 
82  const int& y(node v) const { return m_y[v]; }
83 
85  int& y(node v) { return m_y[v]; }
86 
88  const IPolyline& bends(edge e) const { return m_bends[e]; }
89 
91  IPolyline& bends(edge e) { return m_bends[e]; }
92 
94  IPolyline polyline(edge e) const;
95 
97  void init(const Graph& G) {
98  m_x.init(G, 0);
99  m_y.init(G, 0);
100  m_bends.init(G);
101  }
102 
104  void init() {
105  m_x.init();
106  m_y.init();
107  m_bends.init();
108  }
109 
111  IPolyline getCompactBends(edge e) const;
112 
114  void compactAllBends();
115 
124  bool checkLayout();
125 
136  void computeBoundingBox(int& xmin, int& xmax, int& ymin, int& ymax);
137 
139  int totalManhattanEdgeLength() const;
140 
141  int maxManhattanEdgeLength() const;
142  int manhattanEdgeLength(edge e) const;
143 
145  double totalEdgeLength() const;
146 
148  int numberOfBends() const;
149 
156  virtual void remap(Layout& drawing);
157 
158  static int manhattanDistance(const IPoint& ip1, const IPoint& ip2);
159  static double euclideanDistance(const IPoint& ip1, const IPoint& ip2);
160 
161 protected:
165 
166 private:
167  static bool isRedundant(IPoint& p1, IPoint& p2, IPoint& p3);
168  static void compact(IPolyline& ip);
169 
171 };
172 
173 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GridLayout::bends
const IPolyline & bends(edge e) const
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:88
ogdf::GridLayout::y
int & y(node v)
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:85
ogdf::GenericPoint< int >
Layout.h
Declaration of class Layout.
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::GenericPolyline
Polylines with PointType points.
Definition: geometry.h:254
ogdf::GridLayout::y
const NodeArray< int > & y() const
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:64
ogdf::GridLayout::x
const NodeArray< int > & x() const
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:58
ogdf::GridLayout::y
const int & y(node v) const
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:82
ogdf::GridLayout::~GridLayout
virtual ~GridLayout()
Destruction.
Definition: GridLayout.h:55
ogdf::GridLayout::bends
EdgeArray< IPolyline > & bends()
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:73
ogdf::Layout
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition: Layout.h:46
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
ogdf::GridLayout::bends
const EdgeArray< IPolyline > & bends() const
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:70
ogdf::GridLayout::bends
IPolyline & bends(edge e)
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:91
EdgeArray.h
Declaration and implementation of EdgeArray class.
ogdf::GridLayout::GridLayout
GridLayout(const Graph &G)
Creates an instance of a grid layout associated with G.
Definition: GridLayout.h:52
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::GridLayout::init
void init(const Graph &G)
Initializes the grid layout for graph G.
Definition: GridLayout.h:97
ogdf::GridLayout::y
NodeArray< int > & y()
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:67
NodeArray.h
Declaration and implementation of NodeArray class.
ogdf::GridLayout::x
NodeArray< int > & x()
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:61
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::GridLayout::x
const int & x(node v) const
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:76
ogdf::GridLayout::m_x
NodeArray< int > m_x
The x-coordinates of nodes.
Definition: GridLayout.h:162
ogdf::GridLayout::x
int & x(node v)
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:79
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::GridLayout
Representation of a graph's grid layout.
Definition: GridLayout.h:46
ogdf::GridLayout::init
void init()
Initializes the grid layout for no graph (frees memory).
Definition: GridLayout.h:104
ogdf::GridLayout::GridLayout
GridLayout()
Creates an instance of a grid layout (associated with no graph).
Definition: GridLayout.h:49
ogdf::GridLayout::m_y
NodeArray< int > m_y
The y-coordinates of nodes.
Definition: GridLayout.h:163
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::GridLayout::m_bends
EdgeArray< IPolyline > m_bends
The bend points of edges.
Definition: GridLayout.h:164
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709