Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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