Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

TopologyModule.h
Go to the documentation of this file.
1 
36 #pragma once
37 
38 #include <ogdf/planarity/PlanRep.h>
41 
42 namespace ogdf {
43 
44 namespace topology_module {
45 
47 
52 class EdgeLeg
53 {
54 public:
56  : m_xp(0.0, 0.0)
57  , m_topDown(false)
58  , m_copyEdge(nullptr)
59  , m_number(0) { }
60 
61  EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
62  : m_xp(DPoint(0.0,0.0))
63  , m_topDown(false)
64  , m_copyEdge(e)
65  , m_p1(p1)
66  , m_p2(p2)
67  , m_number(number) { }
68 
69  DPoint& start() { return m_p1; }
70  DPoint& end() { return m_p2; }
71  int& number() { return m_number; }
72  edge& copyEdge() { return m_copyEdge; }
73 
80  bool m_topDown;
81 
85 
86 private:
89  int m_number;
90 };
91 
92 }
93 
95 
104 {
105 public:
107 
111  enum class Options {
113  DegOneCrossings = 0x0001,
115  GenToAss = 0x0002,
118  CrossFlip = 0x0004,
120  FlipUML = 0x0010,
123  Loop = 0x0008,
124  };
125 
126 private:
127  friend int operator | (int, TopologyModule::Options);
129 
130 public:
131 
133  : m_options(Options::DegOneCrossings | Options::GenToAss | Options::CrossFlip | Options::Loop | Options::FlipUML) {}
134 
135  virtual ~TopologyModule() {}
136 
137  void setOptions(int i) { m_options = i; }
139  m_options = m_options | o;
140  }
141 
143 
158  bool setEmbeddingFromGraph(
159  PlanRep &PG,
160  GraphAttributes &GA,
161  adjEntry &adjExternal,
162  bool setExternal = true,
163  bool reuseGAEmbedding = false);
164 
166 
172  void sortEdgesFromLayout(Graph &G, GraphAttributes &GA);
173 
174  face getExternalFace(PlanRep &PG, const GraphAttributes &AG);
175 
176  double faceSum(PlanRep &PG, const GraphAttributes &AG, face f);
177 
178 protected:
179  //compute a planarization, i.e. insert crossing vertices,
180  //corresponding to the AG layout
181  void planarizeFromLayout(PlanRep &PG, GraphAttributes &AG);
182  //compute crossing point and return if existing
183  bool hasCrossing(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB, DPoint& xp);
184  //check if node v is a crossing of two edges with a common
185  //endpoint adjacent to v, crossing is removed if flip is set
186  bool checkFlipCrossing(PlanRep &PG,node v, bool flip = true);
187 
188  void postProcess(PlanRep &PG);
189  void handleImprecision(PlanRep &PG);
190  bool skipable(topology_module::EdgeLeg* legA, topology_module::EdgeLeg* legB);
191 
192 private:
193  //compare vectors for sorting
194  int compare_vectors(const double& x1, const double& y1,
195  const double& x2, const double& y2);
196  //compute and return the angle defined by p-q,p-r
197  double angle(DPoint p, DPoint q, DPoint r);
198  //we have to save the position of the inserted crossing vertices
199  //in order to compute the external face
201 
202  //we save a list of EdgeLegs for all original edges in
203  //AG
205 
206  //option settings as bits
208 
209 };
210 
211 inline int operator & (int i, TopologyModule::Options b) {
212  return i & static_cast<int>(b);
213 }
214 
216  return static_cast<int>(a) | static_cast<int>(b);
217 }
218 
219 inline int operator | (int i, TopologyModule::Options b) {
220  return i | static_cast<int>(b);
221 }
222 
223 }
EdgeArray< List< topology_module::EdgeLeg * > > m_eLegs
int operator&(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:64
Declares EdgeComparer class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
int m_number
the order nuumber on the edge, starting at 0
Declaration of a base class for planar representations of graphs and cluster graphs.
Options
The (pre/post)processing options.
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
Constructs embeddings from given layout.
DPoint m_p2
"Starting" and "End" point of the EdgeLeg
void addOption(TopologyModule::Options o)
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
NodeArray< DPoint > m_crossPosition
Stores additional attributes of a graph (like layout information).
Faces in a combinatorial embedding.
Class for the representation of edges.
Definition: Graph_d.h:292
int operator|(int lhs, UMLOpt rhs)
Definition: OrthoRep.h:62
edge m_copyEdge
the edge in the PlanRep copy corresponding to the EdgeLeg
ListIterator< EdgeLeg *> m_eIterator
each edgeLeg holds an entry with a ListIterator pointing to its entry in a <edgeLeg*> List for an ori...
Class for the representation of nodes.
Definition: Graph_d.h:169
Encapsulates a pointer to a list element.
Definition: List.h:42
Helper class for the computation of crossings.
EdgeLeg(edge e, int number, DPoint p1, DPoint p2)
The namespace for all OGDF objects.
bool m_topDown
we store the direction of the crossed EdgeLeg, too if crossingEdgeLeg is horizontally left to right ...
Class for adjacency list elements.
Definition: Graph_d.h:79
DPoint m_xp
to avoid sorting both edgelegs and crossing points, do not store a pair of them, but allow the xp to ...
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:59