Limbo 3.5.4
Loading...
Searching...
No Matches
bLibApi.h
Go to the documentation of this file.
1
10
11#ifndef _LIMBO_GEOMETRY_API_BLIBAPI_H
12#define _LIMBO_GEOMETRY_API_BLIBAPI_H
13
15
17namespace limbo
18{
20namespace geometry
21{
22
24template <>
25struct 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 }
42
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 }
52
56 static point_type construct(coordinate_type const& x, coordinate_type const& y)
57 {
58 return point_type(x, y);
59 }
60};
61
63template <>
64struct 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 }
86
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 }
101
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
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
namespace for Limbo.Geometry
Definition Geometry.h:21
namespace for Limbo
static coordinate_type get(const point_type &point, orientation_2d const &orient)
get coordinate from point
Definition bLibApi.h:36
static point_type construct(coordinate_type const &x, coordinate_type const &y)
construct point from coordinates
Definition bLibApi.h:56
static void set(point_type &point, orientation_2d const &orient, coordinate_type const &value)
set coordinate for point
Definition bLibApi.h:46
type traits for point
Definition Geometry.h:196
static void set(rectangle_type &rect, direction_2d const &dir, coordinate_type const &value)
set coordinate for rectangle
Definition bLibApi.h:90
static coordinate_type get(const rectangle_type &rect, direction_2d const &dir)
get coordinate from rectangle
Definition bLibApi.h:75
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
type traits for rectangle
Definition Geometry.h:227