Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
RoutingChannel.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/basic.h>
39
40#include <algorithm>
41
42namespace ogdf {
43
46template<class ATYPE>
48public:
49 // constructor
50 RoutingChannel(const Graph& G, ATYPE sep, double cOver)
51 : m_channel(G), m_separation(sep), m_cOverhang(cOver) { }
52
53 // size of routing channel of side dir of node v
54 const ATYPE& operator()(node v, OrthoDir dir) const {
55 return m_channel[v].rc[static_cast<int>(dir)];
56 }
57
58 ATYPE& operator()(node v, OrthoDir dir) { return m_channel[v].rc[static_cast<int>(dir)]; }
59
60 // returns separation (minimum distance between vertices/edges)
61 ATYPE separation() const { return m_separation; }
62
63 // returns cOverhang (such that overhang = separation * cOverhang)
64 double cOverhang() const { return m_cOverhang; }
65
66 // returns overhang (distance between vertex corners and edges)
67 ATYPE overhang() const { return ATYPE(m_cOverhang * m_separation); }
68
69 void computeRoutingChannels(const OrthoRep& OR, bool align = false) {
70 const Graph& G = OR;
71
72 for (node v : G.nodes) {
73 const OrthoRep::VertexInfoUML* pInfo = OR.cageInfo(v);
74
75 if (pInfo) {
76 const OrthoRep::SideInfoUML& sNorth =
77 pInfo->m_side[static_cast<int>(OrthoDir::North)];
78 const OrthoRep::SideInfoUML& sSouth =
79 pInfo->m_side[static_cast<int>(OrthoDir::South)];
80 const OrthoRep::SideInfoUML& sWest = pInfo->m_side[static_cast<int>(OrthoDir::West)];
81 const OrthoRep::SideInfoUML& sEast = pInfo->m_side[static_cast<int>(OrthoDir::East)];
82
83 (*this)(v, OrthoDir::North) = computeRoutingChannel(sNorth, sSouth, align);
84 (*this)(v, OrthoDir::South) = computeRoutingChannel(sSouth, sNorth, align);
85 (*this)(v, OrthoDir::West) = computeRoutingChannel(sWest, sEast, align);
86 (*this)(v, OrthoDir::East) = computeRoutingChannel(sEast, sWest, align);
87 }
88 }
89 }
90
91private:
92 // computes required size of routing channel at side si with opposite side siOpp
94 bool align = false) {
95 if (si.m_adjGen == nullptr) {
96 int k = si.m_nAttached[0];
97 if (k == 0 || ((k == 1 && siOpp.totalAttached() == 0) && !align)) {
98 return 0;
99 } else {
100 return (k + 1) * m_separation;
101 }
102
103 } else {
104 int m = max(si.m_nAttached[0], si.m_nAttached[1]);
105 if (m == 0) {
106 return 0;
107 } else {
108 return (m + 1) * m_separation;
109 }
110 }
111 }
112
113 struct vInfo {
114 ATYPE rc[4];
115
116 vInfo() { rc[0] = rc[1] = rc[2] = rc[3] = ATYPE(); }
117 };
118
122};
123
124}
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of orthogonal representation of planar graphs.
Basic declarations, included by all source files.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Class for the representation of nodes.
Definition Graph_d.h:241
Orthogonal representation of an embedded graph.
Definition OrthoRep.h:225
const VertexInfoUML * cageInfo(node v) const
Definition OrthoRep.h:321
Maintains input sizes for constructive compaction (size of routing channels, separation,...
ATYPE overhang() const
NodeArray< vInfo > m_channel
int computeRoutingChannel(const OrthoRep::SideInfoUML &si, const OrthoRep::SideInfoUML &siOpp, bool align=false)
ATYPE & operator()(node v, OrthoDir dir)
RoutingChannel(const Graph &G, ATYPE sep, double cOver)
double cOverhang() const
void computeRoutingChannels(const OrthoRep &OR, bool align=false)
ATYPE separation() const
const ATYPE & operator()(node v, OrthoDir dir) const
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
The namespace for all OGDF objects.
OrthoDir
Definition OrthoRep.h:56
Information about a side of a vertex in UML diagrams.
Definition OrthoRep.h:228
Further information about the cages of vertices in UML diagrams.
Definition OrthoRep.h:264