Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

TopologyModule.h
Go to the documentation of this file.
1 
36 #pragma once
37 
39 #include <ogdf/basic/Graph.h>
40 #include <ogdf/basic/List.h>
41 #include <ogdf/basic/basic.h>
42 #include <ogdf/basic/geometry.h>
43 
44 namespace ogdf {
45 class GraphAttributes;
46 class PlanRep;
47 
48 namespace topology_module {
49 
51 
56 class EdgeLeg {
57 public:
58  EdgeLeg() : m_xp(0.0, 0.0), m_topDown(false), m_copyEdge(nullptr), m_number(0) { }
59 
60  EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
61  : m_xp(DPoint(0.0, 0.0))
62  , m_topDown(false)
63  , m_copyEdge(e)
64  , m_p1(p1)
65  , m_p2(p2)
66  , m_number(number) { }
67 
68  DPoint& start() { return m_p1; }
69 
70  DPoint& end() { return m_p2; }
71 
72  int& number() { return m_number; }
73 
74  edge& copyEdge() { return m_copyEdge; }
75 
82  bool m_topDown;
83 
87 
88 private:
91  int m_number;
92 };
93 
94 }
95 
97 
106 public:
108 
112  enum class Options {
114  DegOneCrossings = 0x0001,
116  GenToAss = 0x0002,
119  CrossFlip = 0x0004,
121  FlipUML = 0x0010,
124  Loop = 0x0008,
125  };
126 
127 private:
128  friend int operator|(int, TopologyModule::Options);
130 
131 public:
133  : m_options(Options::DegOneCrossings | Options::GenToAss | Options::CrossFlip
134  | Options::Loop | Options::FlipUML) { }
135 
136  virtual ~TopologyModule() { }
137 
138  void setOptions(int i) { m_options = i; }
139 
140  void addOption(TopologyModule::Options o) { m_options = m_options | o; }
141 
143 
158  bool setEmbeddingFromGraph(PlanRep& PG, GraphAttributes& GA, adjEntry& adjExternal,
159  bool setExternal = true, bool reuseGAEmbedding = false);
160 
162 
168  void sortEdgesFromLayout(Graph& G, GraphAttributes& GA);
169 
170  face getExternalFace(PlanRep& PG, const GraphAttributes& AG);
171 
172  double faceSum(PlanRep& PG, const GraphAttributes& AG, face f);
173 
174 protected:
175  //compute a planarization, i.e. insert crossing vertices,
176  //corresponding to the AG layout
177  void planarizeFromLayout(PlanRep& PG, GraphAttributes& AG);
178  //compute crossing point and return if existing
179  bool hasCrossing(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB, DPoint& xp);
180  //check if node v is a crossing of two edges with a common
181  //endpoint adjacent to v, crossing is removed if flip is set
182  bool checkFlipCrossing(PlanRep& PG, node v, bool flip = true);
183 
184  void postProcess(PlanRep& PG);
185  void handleImprecision(PlanRep& PG);
186  bool skipable(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB);
187 
188 private:
189  //compare vectors for sorting
190  int compare_vectors(const double& x1, const double& y1, const double& x2, const double& y2);
191  //compute and return the angle defined by p-q,p-r
192  double angle(DPoint p, DPoint q, DPoint r);
193  //we have to save the position of the inserted crossing vertices
194  //in order to compute the external face
196 
197  //we save a list of EdgeLegs for all original edges in
198  //AG
200 
201  //option settings as bits
203 };
204 
205 inline int operator&(int i, TopologyModule::Options b) { return i & static_cast<int>(b); }
206 
208  return static_cast<int>(a) | static_cast<int>(b);
209 }
210 
211 inline int operator|(int i, TopologyModule::Options b) { return i | static_cast<int>(b); }
212 
213 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
Graph.h
Includes declaration of graph class.
ogdf::topology_module::EdgeLeg::m_p1
DPoint m_p1
Definition: TopologyModule.h:90
ogdf::GenericPoint< double >
ogdf::TopologyModule::TopologyModule
TopologyModule()
Definition: TopologyModule.h:132
ogdf::PlanRep
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:69
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::topology_module::EdgeLeg::end
DPoint & end()
Definition: TopologyModule.h:70
ogdf::operator&
int operator&(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:65
ogdf::topology_module::EdgeLeg::copyEdge
edge & copyEdge()
Definition: TopologyModule.h:74
ogdf::topology_module::EdgeLeg::EdgeLeg
EdgeLeg()
Definition: TopologyModule.h:58
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::TopologyModule::m_eLegs
EdgeArray< List< topology_module::EdgeLeg * > > m_eLegs
Definition: TopologyModule.h:199
r
int r[]
Definition: hierarchical-ranking.cpp:13
ogdf::TopologyModule::m_options
int m_options
Definition: TopologyModule.h:202
ogdf::TopologyModule::Options
Options
The (pre/post)processing options.
Definition: TopologyModule.h:112
ogdf::topology_module::EdgeLeg::m_copyEdge
edge m_copyEdge
the edge in the PlanRep copy corresponding to the EdgeLeg
Definition: TopologyModule.h:89
ogdf::topology_module::EdgeLeg::m_xp
DPoint m_xp
to avoid sorting both edgelegs and crossing points, do not store a pair of them, but allow the xp to ...
Definition: TopologyModule.h:79
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::topology_module::EdgeLeg::m_number
int m_number
the order nuumber on the edge, starting at 0
Definition: TopologyModule.h:91
ogdf::TopologyModule::~TopologyModule
virtual ~TopologyModule()
Definition: TopologyModule.h:136
ogdf::TopologyModule::addOption
void addOption(TopologyModule::Options o)
Definition: TopologyModule.h:140
ogdf::TopologyModule::setOptions
void setOptions(int i)
Definition: TopologyModule.h:138
ogdf::topology_module::EdgeLeg::m_eIterator
ListIterator< EdgeLeg * > m_eIterator
each edgeLeg holds an entry with a ListIterator pointing to its entry in a <edgeLeg*> List for an ori...
Definition: TopologyModule.h:86
ogdf::topology_module::EdgeLeg::EdgeLeg
EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
Definition: TopologyModule.h:60
ogdf::topology_module::EdgeLeg::number
int & number()
Definition: TopologyModule.h:72
basic.h
Basic declarations, included by all source files.
CombinatorialEmbedding.h
Declaration of CombinatorialEmbedding and face.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::TopologyModule
Constructs embeddings from given layout.
Definition: TopologyModule.h:105
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::topology_module::EdgeLeg::m_p2
DPoint m_p2
"Starting" and "End" point of the EdgeLeg
Definition: TopologyModule.h:90
List.h
Declaration of doubly linked lists and iterators.
ogdf::topology_module::EdgeLeg::start
DPoint & start()
Definition: TopologyModule.h:68
ogdf::TopologyModule::m_crossPosition
NodeArray< DPoint > m_crossPosition
Definition: TopologyModule.h:195
ogdf::topology_module::EdgeLeg::m_topDown
bool m_topDown
we store the direction of the crossed EdgeLeg, too if crossingEdgeLeg is horizontally left to right
Definition: TopologyModule.h:82
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:51
ogdf::topology_module::EdgeLeg
Helper class for the computation of crossings.
Definition: TopologyModule.h:56
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::operator|
int operator|(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:61
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::FaceElement
Faces in a combinatorial embedding.
Definition: CombinatorialEmbedding.h:118