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
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/basic.h>
36#include <ogdf/basic/geometry.h>
37#include <ogdf/basic/memory.h>
38
39namespace ogdf {
40class Layout;
41
48public:
51
53 explicit GridLayout(const Graph& G) : m_x(G, 0), m_y(G, 0), m_bends(G) { }
54
56 virtual ~GridLayout() { }
57
59 const NodeArray<int>& x() const { return m_x; }
60
62 NodeArray<int>& x() { return m_x; }
63
65 const NodeArray<int>& y() const { return m_y; }
66
68 NodeArray<int>& y() { return m_y; }
69
71 const EdgeArray<IPolyline>& bends() const { return m_bends; }
72
74 EdgeArray<IPolyline>& bends() { return m_bends; }
75
77 const int& x(node v) const { return m_x[v]; }
78
80 int& x(node v) { return m_x[v]; }
81
83 const int& y(node v) const { return m_y[v]; }
84
86 int& y(node v) { return m_y[v]; }
87
89 const IPolyline& bends(edge e) const { return m_bends[e]; }
90
92 IPolyline& bends(edge e) { return m_bends[e]; }
93
96
98 void init(const Graph& G) {
99 m_x.init(G, 0);
100 m_y.init(G, 0);
101 m_bends.init(G);
102 }
103
105 void init() {
106 m_x.init();
107 m_y.init();
108 m_bends.init();
109 }
110
113
116
126
137 void computeBoundingBox(int& xmin, int& xmax, int& ymin, int& ymax);
138
141
144
146 double totalEdgeLength() const;
147
149 int numberOfBends() const;
150
157 virtual void remap(Layout& drawing);
158
159 static int manhattanDistance(const IPoint& ip1, const IPoint& ip2);
160 static double euclideanDistance(const IPoint& ip1, const IPoint& ip2);
161
162protected:
166
167private:
168 static bool isRedundant(IPoint& p1, IPoint& p2, IPoint& p3);
169 static void compact(IPolyline& ip);
170
172};
173
174}
Includes declaration of graph class.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Basic declarations, included by all source files.
Class for the representation of edges.
Definition Graph_d.h:364
Polylines with PointType points.
Definition geometry.h:261
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Representation of a graph's grid layout.
Definition GridLayout.h:47
const NodeArray< int > & y() const
Returns a reference to the array storing the y-coordinates of nodes.
Definition GridLayout.h:65
const NodeArray< int > & x() const
Returns a reference to the array storing the x-coordinates of nodes.
Definition GridLayout.h:59
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:53
int & x(node v)
Returns a reference to the x-coordinate of node v.
Definition GridLayout.h:80
GridLayout()
Creates an instance of a grid layout (associated with no graph).
Definition GridLayout.h:50
void compactAllBends()
Removes all unnecessary bends.
int & y(node v)
Returns a reference to the y-coordinate of node v.
Definition GridLayout.h:86
NodeArray< int > m_x
The x-coordinates of nodes.
Definition GridLayout.h:163
const int & y(node v) const
Returns a reference to the y-coordinate of node v.
Definition GridLayout.h:83
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:165
const EdgeArray< IPolyline > & bends() const
Returns a reference to the array storing the bend points of edges.
Definition GridLayout.h:71
const int & x(node v) const
Returns a reference to the x-coordinate of node v.
Definition GridLayout.h:77
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:56
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:105
IPolyline & bends(edge e)
Returns a reference to the bend point list of edge e.
Definition GridLayout.h:92
EdgeArray< IPolyline > & bends()
Returns a reference to the array storing the bend points of edges.
Definition GridLayout.h:74
void init(const Graph &G)
Initializes the grid layout for graph G.
Definition GridLayout.h:98
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:89
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:164
NodeArray< int > & y()
Returns a reference to the array storing the y-coordinates of nodes.
Definition GridLayout.h:68
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:62
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition Layout.h:49
Class for the representation of nodes.
Definition Graph_d.h:241
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:92
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.