Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
PolylineDrawing.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
37
38namespace ogdf {
39namespace internal {
40namespace gcm {
41namespace graph {
42
43template<typename Kernel_, typename Graph>
45 : public GeometricDrawing<Kernel_, Graph> { //TODO a polyline drawing is not really a geometric drawing :-/
46public:
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
56private:
58 datastructure::EdgeVector<Polyline, Graph> edge_shape;
59
60public:
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 {
86 double xmin = std::numeric_limits<double>::infinity();
87 double ymin = std::numeric_limits<double>::infinity();
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
NodeElement * node
The type of nodes.
Definition Graph_d.h:64
EdgeElement * edge
The type of edges.
Definition Graph_d.h:68
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.