Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

RoutingChannel.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 
37 namespace ogdf {
38 
41 template<class ATYPE>
43 public:
44  // constructor
45  RoutingChannel(const Graph& G, ATYPE sep, double cOver)
46  : m_channel(G), m_separation(sep), m_cOverhang(cOver) { }
47 
48  // size of routing channel of side dir of node v
49  const ATYPE& operator()(node v, OrthoDir dir) const {
50  return m_channel[v].rc[static_cast<int>(dir)];
51  }
52 
53  ATYPE& operator()(node v, OrthoDir dir) { return m_channel[v].rc[static_cast<int>(dir)]; }
54 
55  // returns separation (minimum distance between vertices/edges)
56  ATYPE separation() const { return m_separation; }
57 
58  // returns cOverhang (such that overhang = separation * cOverhang)
59  double cOverhang() const { return m_cOverhang; }
60 
61  // returns overhang (distance between vertex corners and edges)
62  ATYPE overhang() const { return ATYPE(m_cOverhang * m_separation); }
63 
64  void computeRoutingChannels(const OrthoRep& OR, bool align = false) {
65  const Graph& G = OR;
66 
67  for (node v : G.nodes) {
68  const OrthoRep::VertexInfoUML* pInfo = OR.cageInfo(v);
69 
70  if (pInfo) {
71  const OrthoRep::SideInfoUML& sNorth =
72  pInfo->m_side[static_cast<int>(OrthoDir::North)];
73  const OrthoRep::SideInfoUML& sSouth =
74  pInfo->m_side[static_cast<int>(OrthoDir::South)];
75  const OrthoRep::SideInfoUML& sWest = pInfo->m_side[static_cast<int>(OrthoDir::West)];
76  const OrthoRep::SideInfoUML& sEast = pInfo->m_side[static_cast<int>(OrthoDir::East)];
77 
78  (*this)(v, OrthoDir::North) = computeRoutingChannel(sNorth, sSouth, align);
79  (*this)(v, OrthoDir::South) = computeRoutingChannel(sSouth, sNorth, align);
80  (*this)(v, OrthoDir::West) = computeRoutingChannel(sWest, sEast, align);
81  (*this)(v, OrthoDir::East) = computeRoutingChannel(sEast, sWest, align);
82  }
83  }
84  }
85 
86 private:
87  // computes required size of routing channel at side si with opposite side siOpp
89  bool align = false) {
90  if (si.m_adjGen == nullptr) {
91  int k = si.m_nAttached[0];
92  if (k == 0 || ((k == 1 && siOpp.totalAttached() == 0) && !align)) {
93  return 0;
94  } else {
95  return (k + 1) * m_separation;
96  }
97 
98  } else {
99  int m = max(si.m_nAttached[0], si.m_nAttached[1]);
100  if (m == 0) {
101  return 0;
102  } else {
103  return (m + 1) * m_separation;
104  }
105  }
106  }
107 
108  struct vInfo {
109  ATYPE rc[4];
110 
111  vInfo() { rc[0] = rc[1] = rc[2] = rc[3] = ATYPE(); }
112  };
113 
116  double m_cOverhang;
117 };
118 
119 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::OrthoRep::VertexInfoUML
Further information about the cages of vertices in UML diagrams.
Definition: OrthoRep.h:258
ogdf::OrthoDir
OrthoDir
Definition: OrthoRep.h:50
ogdf::OrthoDir::West
@ West
ogdf::OrthoRep::SideInfoUML::m_adjGen
adjEntry m_adjGen
Definition: OrthoRep.h:225
ogdf::RoutingChannel::overhang
ATYPE overhang() const
Definition: RoutingChannel.h:62
ogdf::OrthoRep::SideInfoUML
Information about a side of a vertex in UML diagrams.
Definition: OrthoRep.h:222
ogdf::OrthoDir::South
@ South
ogdf::RoutingChannel::cOverhang
double cOverhang() const
Definition: RoutingChannel.h:59
OrthoRep.h
Declaration of orthogonal representation of planar graphs.
ogdf::OrthoRep
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:219
ogdf::RoutingChannel::operator()
const ATYPE & operator()(node v, OrthoDir dir) const
Definition: RoutingChannel.h:49
ogdf::RoutingChannel::m_channel
NodeArray< vInfo > m_channel
Definition: RoutingChannel.h:114
ogdf::RoutingChannel::RoutingChannel
RoutingChannel(const Graph &G, ATYPE sep, double cOver)
Definition: RoutingChannel.h:45
ogdf::RoutingChannel::computeRoutingChannels
void computeRoutingChannels(const OrthoRep &OR, bool align=false)
Definition: RoutingChannel.h:64
ogdf::OrthoRep::cageInfo
const VertexInfoUML * cageInfo(node v) const
Definition: OrthoRep.h:315
ogdf::OrthoRep::SideInfoUML::m_nAttached
int m_nAttached[2]
Definition: OrthoRep.h:230
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::OrthoRep::VertexInfoUML::m_side
SideInfoUML m_side[4]
Definition: OrthoRep.h:261
ogdf::OrthoRep::SideInfoUML::totalAttached
int totalAttached() const
Definition: OrthoRep.h:239
ogdf::RoutingChannel::vInfo::vInfo
vInfo()
Definition: RoutingChannel.h:111
ogdf::OrthoDir::East
@ East
ogdf::RoutingChannel::m_separation
ATYPE m_separation
Definition: RoutingChannel.h:115
ogdf::RoutingChannel::operator()
ATYPE & operator()(node v, OrthoDir dir)
Definition: RoutingChannel.h:53
ogdf::RoutingChannel::m_cOverhang
double m_cOverhang
Definition: RoutingChannel.h:116
ogdf::RoutingChannel::separation
ATYPE separation() const
Definition: RoutingChannel.h:56
ogdf::OrthoDir::North
@ North
ogdf::RoutingChannel::computeRoutingChannel
int computeRoutingChannel(const OrthoRep::SideInfoUML &si, const OrthoRep::SideInfoUML &siOpp, bool align=false)
Definition: RoutingChannel.h:88
ogdf::RoutingChannel::vInfo::rc
ATYPE rc[4]
Definition: RoutingChannel.h:109
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::RoutingChannel::vInfo
Definition: RoutingChannel.h:108
ogdf::RoutingChannel
Maintains input sizes for constructive compaction (size of routing channels, separation,...
Definition: RoutingChannel.h:42