Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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:
55  EdgeLeg() : m_xp(0.0, 0.0), m_topDown(false), m_copyEdge(nullptr) { }
56 
57  EdgeLeg(edge e, int number, DPoint p1, DPoint p2) :
58  m_xp(DPoint(0.0,0.0)), m_topDown(false), m_copyEdge(e), m_p1(p1), m_p2(p2), m_number(number)
59  { }
60 
61  DPoint& start() { return m_p1; }
62  DPoint& end() { return m_p2; }
63  int& number() { return m_number; }
64  edge& copyEdge() { return m_copyEdge; }
65 
72  bool m_topDown;
73 
77 
78 private:
81  int m_number;
82 };
83 
84 }
85 
87 
96 {
97 public:
99 
103  enum class Options {
105  DegOneCrossings = 0x0001,
107  GenToAss = 0x0002,
110  CrossFlip = 0x0004,
112  FlipUML = 0x0010,
115  Loop = 0x0008,
116  };
117 
118 private:
119  friend int operator | (int, TopologyModule::Options);
121 
122 public:
123 
125  : m_options(Options::DegOneCrossings | Options::GenToAss | Options::CrossFlip | Options::Loop | Options::FlipUML) {}
126 
127  virtual ~TopologyModule() {}
128 
129  void setOptions(int i) { m_options = i; }
131  m_options = m_options | o;
132  }
133 
135 
150  bool setEmbeddingFromGraph(
151  PlanRep &PG,
152  GraphAttributes &GA,
153  adjEntry &adjExternal,
154  bool setExternal = true,
155  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,
187  const double& x2, const double& y2);
188  //compute and return the angle defined by p-q,p-r
189  double angle(DPoint p, DPoint q, DPoint r);
190  //we have to save the position of the inserted crossing vertices
191  //in order to compute the external face
193 
194  //we save a list of EdgeLegs for all original edges in
195  //AG
197 
198  //option settings as bits
200 
201 };//TopologyModule
202 
203 inline int operator & (int i, TopologyModule::Options b) {
204  return i & static_cast<int>(b);
205 }
206 
208  return static_cast<int>(a) | static_cast<int>(b);
209 }
210 
211 inline int operator | (int i, TopologyModule::Options b) {
212  return i | static_cast<int>(b);
213 }
214 
215 } // end namespace ogdf
int operator&(int i, TopologyModule::Options b)
EdgeArray< List< topology_module::EdgeLeg * > > m_eLegs
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:472
#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.
Real points.
Definition: geometry.h:219
DPoint m_p2
"Starting" and "End" point of the EdgeLeg
void addOption(TopologyModule::Options o)
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:423
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:291
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:167
Encapsulates a pointer to a list element.
Definition: List.h:41
int operator|(TopologyModule::Options a, TopologyModule::Options b)
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:78
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:60