Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

PolylineDrawing.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #ifdef OGDF_INCLUDE_CGAL
34 
37 
38 namespace ogdf {
39 namespace internal {
40 namespace gcm {
41 namespace graph {
42 
43 template<typename Kernel_, typename Graph>
44 class PolylineDrawing
45  : public GeometricDrawing<Kernel_, Graph> { //TODO a polyline drawing is not really a geometric drawing :-/
46 public:
47  using Kernel = Kernel_;
48  using Node = node;
49  using Edge = edge;
50 
51  using Point = geometry::Point_t<Kernel>;
52  using LineSegment = geometry::LineSegment_t<Kernel>;
53  using Polyline = geometry::Polyline_t<Kernel>;
54 
55 
56 private:
57  using parent = GeometricDrawing<Kernel, Graph>;
58  datastructure::EdgeVector<Polyline, Graph> edge_shape;
59 
60 public:
61  PolylineDrawing(Graph& g) : GeometricDrawing<Kernel, Graph>(g) { }
62 
63  void clear() {
64  edge_shape.clear();
65  parent::clear();
66  }
67 
68  inline const Polyline& get_polyline(const Edge& e) const { return edge_shape[e]; }
69 
70  inline void set_polyline(const Edge& e, Polyline& p) {
71  OGDF_ASSERT(!p.is_degenerate());
72  OGDF_ASSERT(p.front() == this->get_point(e->source()));
73  OGDF_ASSERT(p.back() == this->get_point(e->target()));
74  edge_shape[e] = p;
75  }
76 
77  inline void set_polyline(const Edge& e, Polyline&& p) {
78  OGDF_ASSERT(!p.is_degenerate());
79  OGDF_ASSERT(p.front() == this->get_point(e->source()));
80  OGDF_ASSERT(p.back() == this->get_point(e->target()));
81 
82  edge_shape[e] = std::move(p);
83  }
84 
85  inline geometry::Bbox bbox() const {
88  double xmax = -xmin;
89  double ymax = -ymin;
90 
91  geometry::Bbox bb(xmin, ymin, xmax, ymax);
92  for (Node v : parent::nodes()) {
93  bb += parent::get_point(v).bbox();
94  }
95 
96  for (Edge e : parent::edges()) {
97  bb += edge_shape[e].bbox();
98  }
99 
100  return bb;
101  }
102 };
103 
104 }
105 }
106 }
107 }
108 
109 #endif
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::matching_blossom::infinity
TWeight infinity()
Helper function to get the maximum value for a given weight type.
Definition: utils.h:46
ogdf::gml::Key::Node
@ Node
ogdf::gml::Key::Edge
@ Edge
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:74
ogdf::gml::Key::Graph
@ Graph
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:70
Polyline.h
GeometricDrawing.h
ogdf::gml::Key::Point
@ Point