Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

CrossingMinimalPosition.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #ifdef OGDF_INCLUDE_CGAL
34 
39 
40 namespace ogdf {
41 namespace internal {
42 namespace gcm {
43 namespace graph {
44 
45 template<typename Kernel, typename Graph>
46 class CrossingMinimalPosition {
47 private:
48  using Point = geometry::Point_t<Kernel>;
49  using Segment = geometry::LineSegment_t<Kernel>;
50  using Polygon = geometry::Polygon_t<Kernel>;
51  using Drawing = graph::GeometricDrawing<Kernel, Graph>;
52  using Node = typename Graph::Node;
53  using Edge = typename Graph::Edge;
54 
55 public:
56  static Point compute(const Drawing& d, const Node& v, const std::vector<Edge>& sample,
57  geometry::Rectangle_t<Kernel>& rect_box) {
58  unsigned int dump_a, dump_b;
59  auto region = CrossingMinimalRegion<Kernel, Graph>::compute(d, v, sample, rect_box, dump_a,
60  dump_b);
61  if (geometry::is_clockwise(region)) {
62  region = geometry::reverse(region);
63  }
64 
65  Point p = d.get_point(v);
66  if (region.size() > 2) {
67  if (!region.is_convex()) {
68  p = geometry::largest_circle_in_polygon(region, 1e-5);
69  } else {
70  p = geometry::centroid(region);
71  }
72  }
73 
74  //round
75  OGDF_ASSERT(rect_box.has_on_bounded_side(p));
76  p = Point(CGAL::to_double(p.x()), CGAL::to_double(p.y()));
77  OGDF_ASSERT(rect_box.has_on_bounded_side(p));
78  return p;
79  }
80 };
81 
82 }
83 }
84 }
85 }
86 
87 #endif
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
CrossingMinimalRegion.h
ogdf::gml::Key::Node
@ Node
ogdf::gml::Key::Edge
@ Edge
CollinearTriple.h
ogdf::reverse
Reverse< T > reverse(T &container)
Provides iterators for container to make it easily iterable in reverse.
Definition: Reverse.h:74
ogdf::gml::Key::Point
@ Point
LargestCircleInPolygon.h
RandomPointInPolygon.h