Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bLibApi.h
Go to the documentation of this file.
1 
11 #ifndef _LIMBO_GEOMETRY_API_BLIBAPI_H
12 #define _LIMBO_GEOMETRY_API_BLIBAPI_H
13 
15 
17 namespace limbo
18 {
20 namespace geometry
21 {
22 
24 template <>
25 struct point_traits<bLib::bPoint>
26 {
28  typedef bLib::bPoint point_type;
29  typedef int coordinate_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 assert(0);
41  }
46  static void set(point_type& point, orientation_2d const& orient, coordinate_type const& value)
47  {
48  if (orient == HORIZONTAL) return point.set(value, point.y());
49  else if (orient == VERTICAL) return point.set(point.x(), value);
50  else assert(0);
51  }
56  static point_type construct(coordinate_type const& x, coordinate_type const& y)
57  {
58  return point_type(x, y);
59  }
60 };
61 
63 template <>
64 struct rectangle_traits<bLib::bBox>
65 {
67  typedef bLib::bBox rectangle_type;
68  typedef int coordinate_type;
70 
75  static coordinate_type get(const rectangle_type& rect, direction_2d const& dir)
76  {
77  switch (dir)
78  {
79  case LEFT: return rect.x1();
80  case BOTTOM: return rect.y1();
81  case RIGHT: return rect.x2();
82  case TOP: return rect.y2();
83  default: assert(0);
84  }
85  }
90  static void set(rectangle_type& rect, direction_2d const& dir, coordinate_type const& value)
91  {
92  switch (dir)
93  {
94  case LEFT: rect.set(value, rect.y1(), rect.x2(), rect.y2()); break;
95  case BOTTOM: rect.set(rect.x1(), value, rect.x2(), rect.y2()); break;
96  case RIGHT: rect.set(rect.x1(), rect.y1(), value, rect.y2()); break;
97  case TOP: rect.set(rect.x1(), rect.y1(), rect.x2(), value); break;
98  default: assert(0);
99  }
100  }
104  static rectangle_type construct(coordinate_type const& xl, coordinate_type const& yl,
105  coordinate_type const& xh, coordinate_type const& yh)
106  {
107  return rectangle_type(xl, yl, xh, yh);
108  }
109 };
110 
111 }}// namespace limbo // namespace geometry
112 
113 #endif
static rectangle_type construct(coordinate_type const &xl, coordinate_type const &yl, coordinate_type const &xh, coordinate_type const &yh)
construct rectangle from coordinates
Definition: bLibApi.h:104
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 void set(point_type &point, orientation_2d const &orient, coordinate_type const &value)
set coordinate for point
Definition: bLibApi.h:46
static void set(rectangle_type &rect, direction_2d const &dir, coordinate_type const &value)
set coordinate for rectangle
Definition: bLibApi.h:90
type traits for rectangle
Definition: Geometry.h:199
namespace for Limbo
Definition: GraphUtility.h:22
type traits for point
Definition: Geometry.h:168
static point_type construct(coordinate_type const &x, coordinate_type const &y)
construct point from coordinates
Definition: bLibApi.h:56
a class denoting orientation of lines
Definition: Geometry.h:92