Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

TopologyModule.h
Go to the documentation of this file.
1 
36 #pragma once
37 
40 #include <ogdf/planarity/PlanRep.h>
41 
42 namespace ogdf {
43 
44 namespace topology_module {
45 
47 
52 class EdgeLeg {
53 public:
54  EdgeLeg() : m_xp(0.0, 0.0), m_topDown(false), m_copyEdge(nullptr), m_number(0) { }
55 
56  EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
57  : m_xp(DPoint(0.0, 0.0))
58  , m_topDown(false)
59  , m_copyEdge(e)
60  , m_p1(p1)
61  , m_p2(p2)
62  , m_number(number) { }
63 
64  DPoint& start() { return m_p1; }
65 
66  DPoint& end() { return m_p2; }
67 
68  int& number() { return m_number; }
69 
70  edge& copyEdge() { return m_copyEdge; }
71 
78  bool m_topDown;
79 
83 
84 private:
87  int m_number;
88 };
89 
90 }
91 
93 
102 public:
104 
108  enum class Options {
110  DegOneCrossings = 0x0001,
112  GenToAss = 0x0002,
115  CrossFlip = 0x0004,
117  FlipUML = 0x0010,
120  Loop = 0x0008,
121  };
122 
123 private:
124  friend int operator|(int, TopologyModule::Options);
126 
127 public:
129  : m_options(Options::DegOneCrossings | Options::GenToAss | Options::CrossFlip
130  | Options::Loop | Options::FlipUML) { }
131 
132  virtual ~TopologyModule() { }
133 
134  void setOptions(int i) { m_options = i; }
135 
136  void addOption(TopologyModule::Options o) { m_options = m_options | o; }
137 
139 
154  bool setEmbeddingFromGraph(PlanRep& PG, GraphAttributes& GA, adjEntry& adjExternal,
155  bool setExternal = true, bool reuseGAEmbedding = false);
156 
158 
164  void sortEdgesFromLayout(Graph& G, GraphAttributes& GA);
165 
166  face getExternalFace(PlanRep& PG, const GraphAttributes& AG);
167 
168  double faceSum(PlanRep& PG, const GraphAttributes& AG, face f);
169 
170 protected:
171  //compute a planarization, i.e. insert crossing vertices,
172  //corresponding to the AG layout
173  void planarizeFromLayout(PlanRep& PG, GraphAttributes& AG);
174  //compute crossing point and return if existing
175  bool hasCrossing(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB, DPoint& xp);
176  //check if node v is a crossing of two edges with a common
177  //endpoint adjacent to v, crossing is removed if flip is set
178  bool checkFlipCrossing(PlanRep& PG, node v, bool flip = true);
179 
180  void postProcess(PlanRep& PG);
181  void handleImprecision(PlanRep& PG);
182  bool skipable(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB);
183 
184 private:
185  //compare vectors for sorting
186  int compare_vectors(const double& x1, const double& y1, const double& x2, const double& y2);
187  //compute and return the angle defined by p-q,p-r
188  double angle(DPoint p, DPoint q, DPoint r);
189  //we have to save the position of the inserted crossing vertices
190  //in order to compute the external face
192 
193  //we save a list of EdgeLegs for all original edges in
194  //AG
196 
197  //option settings as bits
199 };
200 
201 inline int operator&(int i, TopologyModule::Options b) { return i & static_cast<int>(b); }
202 
204  return static_cast<int>(a) | static_cast<int>(b);
205 }
206 
207 inline int operator|(int i, TopologyModule::Options b) { return i | static_cast<int>(b); }
208 
209 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::topology_module::EdgeLeg::m_p1
DPoint m_p1
Definition: TopologyModule.h:86
ogdf::GenericPoint< double >
ogdf::TopologyModule::TopologyModule
TopologyModule()
Definition: TopologyModule.h:128
ogdf::PlanRep
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:57
ogdf::topology_module::EdgeLeg::end
DPoint & end()
Definition: TopologyModule.h:66
ogdf::operator&
int operator&(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:59
ogdf::topology_module::EdgeLeg::copyEdge
edge & copyEdge()
Definition: TopologyModule.h:70
ogdf::topology_module::EdgeLeg::EdgeLeg
EdgeLeg()
Definition: TopologyModule.h:54
PlanRep.h
Declaration of a base class for planar representations of graphs and cluster graphs.
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::TopologyModule::m_eLegs
EdgeArray< List< topology_module::EdgeLeg * > > m_eLegs
Definition: TopologyModule.h:195
r
int r[]
Definition: hierarchical-ranking.cpp:8
ogdf::TopologyModule::m_options
int m_options
Definition: TopologyModule.h:198
ogdf::TopologyModule::Options
Options
The (pre/post)processing options.
Definition: TopologyModule.h:108
ogdf::topology_module::EdgeLeg::m_copyEdge
edge m_copyEdge
the edge in the PlanRep copy corresponding to the EdgeLeg
Definition: TopologyModule.h:85
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:75
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::topology_module::EdgeLeg::m_number
int m_number
the order nuumber on the edge, starting at 0
Definition: TopologyModule.h:87
ogdf::TopologyModule::~TopologyModule
virtual ~TopologyModule()
Definition: TopologyModule.h:132
ogdf::TopologyModule::addOption
void addOption(TopologyModule::Options o)
Definition: TopologyModule.h:136
ogdf::TopologyModule::setOptions
void setOptions(int i)
Definition: TopologyModule.h:134
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:82
ogdf::topology_module::EdgeLeg::EdgeLeg
EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
Definition: TopologyModule.h:56
ogdf::topology_module::EdgeLeg::number
int & number()
Definition: TopologyModule.h:68
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:101
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::topology_module::EdgeLeg::m_p2
DPoint m_p2
"Starting" and "End" point of the EdgeLeg
Definition: TopologyModule.h:86
ogdf::topology_module::EdgeLeg::start
DPoint & start()
Definition: TopologyModule.h:64
ogdf::TopologyModule::m_crossPosition
NodeArray< DPoint > m_crossPosition
Definition: TopologyModule.h:191
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:78
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::topology_module::EdgeLeg
Helper class for the computation of crossings.
Definition: TopologyModule.h:52
EdgeComparer.h
Declares EdgeComparer class.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::operator|
int operator|(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:55
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::FaceElement
Faces in a combinatorial embedding.
Definition: CombinatorialEmbedding.h:109