Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
GridLayout.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/Layout.h>
37#include <ogdf/basic/geometry.h>
38
39namespace ogdf {
40
47public:
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
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
112
115
125
136 void computeBoundingBox(int& xmin, int& xmax, int& ymin, int& ymax);
137
140
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
161protected:
165
166private:
167 static bool isRedundant(IPoint& p1, IPoint& p2, IPoint& p3);
168 static void compact(IPolyline& ip);
169
171};
172
173}
Declaration and implementation of EdgeArray class.
Declaration of class Layout.
Declaration and implementation of NodeArray class.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Polylines with PointType points.
Definition geometry.h:253
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Representation of a graph's grid layout.
Definition GridLayout.h:46
const NodeArray< int > & y() const
Returns a reference to the array storing the y-coordinates of nodes.
Definition GridLayout.h:64
const NodeArray< int > & x() const
Returns a reference to the array storing the x-coordinates of nodes.
Definition GridLayout.h:58
int totalManhattanEdgeLength() const
Computes the total manhattan edge length of the grid layout.
GridLayout(const Graph &G)
Creates an instance of a grid layout associated with G.
Definition GridLayout.h:52
int & x(node v)
Returns a reference to the x-coordinate of node v.
Definition GridLayout.h:79
GridLayout()
Creates an instance of a grid layout (associated with no graph).
Definition GridLayout.h:49
void compactAllBends()
Removes all unnecessary bends.
int & y(node v)
Returns a reference to the y-coordinate of node v.
Definition GridLayout.h:85
NodeArray< int > m_x
The x-coordinates of nodes.
Definition GridLayout.h:162
const int & y(node v) const
Returns a reference to the y-coordinate of node v.
Definition GridLayout.h:82
void computeBoundingBox(int &xmin, int &xmax, int &ymin, int &ymax)
Computes the bounding box of the grid layout.
EdgeArray< IPolyline > m_bends
The bend points of edges.
Definition GridLayout.h:164
const EdgeArray< IPolyline > & bends() const
Returns a reference to the array storing the bend points of edges.
Definition GridLayout.h:70
const int & x(node v) const
Returns a reference to the x-coordinate of node v.
Definition GridLayout.h:76
int numberOfBends() const
Computes the total number of bends in the grid layout.
bool checkLayout()
Checks if the grid layout is reasonable.
int maxManhattanEdgeLength() const
virtual ~GridLayout()
Destruction.
Definition GridLayout.h:55
virtual void remap(Layout &drawing)
Transforms the grid layout to a layout.
double totalEdgeLength() const
Computes the total (euclidean) edge length of the grid layout.
static bool isRedundant(IPoint &p1, IPoint &p2, IPoint &p3)
int manhattanEdgeLength(edge e) const
void init()
Initializes the grid layout for no graph (frees memory).
Definition GridLayout.h:104
IPolyline & bends(edge e)
Returns a reference to the bend point list of edge e.
Definition GridLayout.h:91
EdgeArray< IPolyline > & bends()
Returns a reference to the array storing the bend points of edges.
Definition GridLayout.h:73
void init(const Graph &G)
Initializes the grid layout for graph G.
Definition GridLayout.h:97
static int manhattanDistance(const IPoint &ip1, const IPoint &ip2)
static void compact(IPolyline &ip)
const IPolyline & bends(edge e) const
Returns a reference to the bend point list of edge e.
Definition GridLayout.h:88
static double euclideanDistance(const IPoint &ip1, const IPoint &ip2)
IPolyline getCompactBends(edge e) const
Returns the bend point list of edge e without unnecessary bends.
NodeArray< int > m_y
The y-coordinates of nodes.
Definition GridLayout.h:163
NodeArray< int > & y()
Returns a reference to the array storing the y-coordinates of nodes.
Definition GridLayout.h:67
IPolyline polyline(edge e) const
Returns the polyline of edge e (including start and end point!).
NodeArray< int > & x()
Returns a reference to the array storing the x-coordinates of nodes.
Definition GridLayout.h:61
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition Layout.h:46
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:91
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.