Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BoostPolygonApi.h
Go to the documentation of this file.
1 
10 #ifndef _LIMBO_GEOMETRY_API_BOOSTPOLYGONAPI_H
11 #define _LIMBO_GEOMETRY_API_BOOSTPOLYGONAPI_H
12 
14 
16 namespace limbo
17 {
19 namespace geometry
20 {
21 
23 template <typename T>
24 struct point_traits<boost::polygon::point_data<T> >
25 {
27  typedef T coordinate_type;
28  typedef boost::polygon::point_data<T> point_type;
30 
35  static coordinate_type get(const point_type& point, orientation_2d const& orient)
36  {
37  if (orient == HORIZONTAL) return point.x();
38  else if (orient == VERTICAL) return point.y();
39  else assert(0);
40  }
45  static void set(point_type& point, orientation_2d const& orient, coordinate_type const& value)
46  {
47  if (orient == HORIZONTAL) return point.set(boost::polygon::HORIZONTAL, value);
48  else if (orient == VERTICAL) return point.set(boost::polygon::VERTICAL, value);
49  else assert(0);
50  }
55  static point_type construct(coordinate_type const& x, coordinate_type const& y)
56  {
57  return point_type(x, y);
58  }
59 };
60 
62 template <typename T>
63 struct rectangle_traits<boost::polygon::rectangle_data<T> >
64 {
66  typedef T coordinate_type;
67  typedef boost::polygon::rectangle_data<T> rectangle_type;
69 
74  static coordinate_type get(const rectangle_type& rect, direction_2d const& dir)
75  {
76  switch (dir)
77  {
78  case LEFT: return boost::polygon::xl(rect);
79  case BOTTOM: return boost::polygon::yl(rect);
80  case RIGHT: return boost::polygon::xh(rect);
81  case TOP: return boost::polygon::yh(rect);
82  default: assert(0);
83  }
84  }
89  static void set(rectangle_type& rect, direction_2d const& dir, coordinate_type const& value)
90  {
91  switch (dir)
92  {
93  case LEFT: boost::polygon::xl(rect, value); break;
94  case BOTTOM: boost::polygon::yl(rect, value); break;
95  case RIGHT: boost::polygon::xh(rect, value); break;
96  case TOP: boost::polygon::yh(rect, value); break;
97  default: assert(0);
98  }
99  }
103  static rectangle_type construct(coordinate_type const& xl, coordinate_type const& yl,
104  coordinate_type const& xh, coordinate_type const& yh)
105  {
106  return rectangle_type(xl, yl, xh, yh);
107  }
108 };
109 
110 } // namespace geometry
111 } // namespace limbo
112 
113 #endif
Boost.Geometry.
Definition: GdsObjects.h:724
direction_2d
direction type for rectangles
Definition: Geometry.h:72
Contains utilities for geometric types, such as type traits, area calculator. I'm trying to make thes...
static rectangle_type construct(coordinate_type const &xl, coordinate_type const &yl, coordinate_type const &xh, coordinate_type const &yh)
construct rectangle from coordinates
type traits for rectangle
Definition: Geometry.h:199
static void set(point_type &point, orientation_2d const &orient, coordinate_type const &value)
set coordinate for point
namespace for Limbo
Definition: GraphUtility.h:22
static point_type construct(coordinate_type const &x, coordinate_type const &y)
construct point from coordinates
type traits for point
Definition: Geometry.h:168
static void set(rectangle_type &rect, direction_2d const &dir, coordinate_type const &value)
set coordinate for rectangle
a class denoting orientation of lines
Definition: Geometry.h:92