Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Converter.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #ifdef OGDF_INCLUDE_CGAL
34 
36 # include <ogdf/basic/Graph.h>
40 
41 # include <map>
42 
43 namespace ogdf {
44 namespace internal {
45 namespace gcm {
46 namespace tools {
47 
48 template<typename kernel>
49 geometry::Point_t<kernel> extract_point(const GraphAttributes& ga, const node node) {
50  return {ga.x(node), ga.y(node)};
51 }
52 
53 template<typename kernel>
54 geometry::LineSegment_t<kernel> extract_segment(const GraphAttributes& ga, const edge& edge) {
55  return {extract_point<kernel>(ga, edge->source()), extract_point<kernel>(ga, edge->target())};
56 }
57 
58 template<typename Graph, typename Polygon>
59 void extract_polygon(const Graph& g, const face& face, Polygon& p) {
60  adjEntry first = face->firstAdj();
61  adjEntry current = first;
62  do {
63  p.push_back(g.get_point(current->theNode()));
64  current = current->faceCycleSucc();
65  OGDF_ASSERT(current != nullptr);
66  } while (current != first);
67 }
68 
69 template<typename kernel, typename Polygon>
70 void extract_polygon(const GraphAttributes& ga, const face& face,
71  NodeArray<unsigned int>& node_to_id, Polygon& p) {
72  adjEntry first = face->firstAdj();
73  adjEntry current = first;
74 
75  do {
76  node_to_id[current->theEdge()->source()] = p.size();
77  p.push_back(extract_point<kernel>(ga, current->theEdge()->source()));
78  current = face->nextFaceEdge(current);
79  } while (current != nullptr);
80 }
81 
82 }
83 }
84 }
85 }
86 
87 #endif
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
Point.h
ogdf::adjEntry
AdjElement * adjEntry
The type of adjacency entries.
Definition: Graph_d.h:71
ogdf::FaceElement::firstAdj
adjEntry firstAdj() const
Returns the first adjacency element in the face.
Definition: CombinatorialEmbedding.h:139
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
LineSegment.h
ogdf::face
FaceElement * face
Definition: CombinatorialEmbedding.h:40
CombinatorialEmbedding.h
Declaration of CombinatorialEmbedding and face.
ogdf::AdjElement::faceCycleSucc
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:205
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::FaceElement::nextFaceEdge
adjEntry nextFaceEdge(adjEntry adj) const
Returns the successor of adj in the list of all adjacency elements in the face.
Definition: CombinatorialEmbedding.h:151