Limbo 3.5.4
Loading...
Searching...
No Matches
BoostPolygonApi.h
Go to the documentation of this file.
1
9
10#ifndef _LIMBO_GEOMETRY_API_BOOSTPOLYGONAPI_H
11#define _LIMBO_GEOMETRY_API_BOOSTPOLYGONAPI_H
12
13#include <limits>
15
17namespace limbo
18{
20namespace geometry
21{
22
24template <typename T>
25struct point_traits<boost::polygon::point_data<T> >
26{
28 typedef T coordinate_type;
29 typedef boost::polygon::point_data<T> point_type;
31
36 static coordinate_type get(const point_type& point, orientation_2d const& orient)
37 {
38 if (orient == HORIZONTAL) return point.x();
39 else if (orient == VERTICAL) return point.y();
40 else
41 {
42 assert(0);
43 return std::numeric_limits<coordinate_type>::max();
44 }
45 }
46
50 static void set(point_type& point, orientation_2d const& orient, coordinate_type const& value)
51 {
52 if (orient == HORIZONTAL) return point.set(boost::polygon::HORIZONTAL, value);
53 else if (orient == VERTICAL) return point.set(boost::polygon::VERTICAL, value);
54 else
55 {
56 assert(0);
57 }
58 }
59
63 static point_type construct(coordinate_type const& x, coordinate_type const& y)
64 {
65 return point_type(x, y);
66 }
67};
68
70template <typename T>
71struct rectangle_traits<boost::polygon::rectangle_data<T> >
72{
74 typedef T coordinate_type;
75 typedef boost::polygon::rectangle_data<T> rectangle_type;
77
82 static coordinate_type get(const rectangle_type& rect, direction_2d const& dir)
83 {
84 switch (dir)
85 {
86 case LEFT: return boost::polygon::xl(rect);
87 case BOTTOM: return boost::polygon::yl(rect);
88 case RIGHT: return boost::polygon::xh(rect);
89 case TOP: return boost::polygon::yh(rect);
90 default: assert(0); return std::numeric_limits<coordinate_type>::max();
91 }
92 }
93
97 static void set(rectangle_type& rect, direction_2d const& dir, coordinate_type const& value)
98 {
99 switch (dir)
100 {
101 case LEFT: boost::polygon::xl(rect, value); break;
102 case BOTTOM: boost::polygon::yl(rect, value); break;
103 case RIGHT: boost::polygon::xh(rect, value); break;
104 case TOP: boost::polygon::yh(rect, value); break;
105 default: assert(0);
106 }
107 }
108
111 static rectangle_type construct(coordinate_type const& xl, coordinate_type const& yl,
112 coordinate_type const& xh, coordinate_type const& yh)
113 {
114 return rectangle_type(xl, yl, xh, yh);
115 }
116};
117
118} // namespace geometry
119} // namespace limbo
120
121#endif
Contains utilities for geometric types, such as type traits, area calculator. I'm trying to make thes...
a class denoting orientation of lines
Definition Geometry.h:93
Boost.Geometry.
Definition GdsObjects.h:740
namespace for Limbo.Geometry
Definition Geometry.h:21
namespace for Limbo
static void set(point_type &point, orientation_2d const &orient, coordinate_type const &value)
set coordinate for point
static coordinate_type get(const point_type &point, orientation_2d const &orient)
get coordinate from point
static point_type construct(coordinate_type const &x, coordinate_type const &y)
construct point from coordinates
type traits for point
Definition Geometry.h:196
static rectangle_type construct(coordinate_type const &xl, coordinate_type const &yl, coordinate_type const &xh, coordinate_type const &yh)
construct rectangle from coordinates
static coordinate_type get(const rectangle_type &rect, direction_2d const &dir)
get coordinate from rectangle
static void set(rectangle_type &rect, direction_2d const &dir, coordinate_type const &value)
set coordinate for rectangle
type traits for rectangle
Definition Geometry.h:227