Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GeogebraExporter.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 
42 namespace tools {
43 
44 template<typename stream = std::ostream>
45 class GeogebraExporter {
46 private:
47  stream& outstream;
48  unsigned int point_counter;
49 
50 public:
51  GeogebraExporter(stream& outstream_) : outstream(outstream_), point_counter(0) {
52  //nothing to do
53  }
54 
55  template<typename type>
56  void add(const geometry::Point_t<type>& point) {
57  outstream << "A" << point_counter << "=" << point << "\n";
58  ++point_counter;
59  }
60 
61  template<typename Polygon>
62  void add(const Polygon& polygon) {
63  unsigned int old_counter = point_counter;
64  for (unsigned int i = 0; i < polygon.size(); ++i) {
65  add(polygon[i]);
66  }
67 
68  outstream << "input = polygon[";
69 
70  for (unsigned int i = old_counter; i < point_counter; ++i) {
71  outstream << "A" << i;
72  if (i + 1 < point_counter) {
73  outstream << ", ";
74  }
75  }
76 
77  outstream << "]\n";
78  }
79 
80  template<typename type>
81  void add(const geometry::LineSegment_t<type>& l) {
82  unsigned int i = point_counter;
83  add(l.source());
84  add(l.target());
85  outstream << "segment[A" << i << ", A" << i + 1 << "]\n";
86  }
87 };
88 }
89 }
90 }
91 }
92 
93 #endif
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Point.h
LineSegment.h