-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqvmTraits.h
116 lines (104 loc) · 2.82 KB
/
qvmTraits.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* stair-step-detector
* Copyright (c) 2021 Peter Nebe (mail@peter-nebe.dev)
*
* This file is part of stair-step-detector.
*
* stair-step-detector is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* stair-step-detector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with stair-step-detector. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef QVMTRAITS_H_
#define QVMTRAITS_H_
#include "types.h" // Point_
#include "librealsense2/hpp/rs_frame.hpp" // rs2::vertex
#include "boost/qvm/vec_traits_defaults.hpp"
#include "boost/qvm/deduce_vec.hpp"
namespace boost { namespace qvm
{
/*
* stairs::Point_
*/
template<int Dim>
struct vec_traits<stairs::Point_<Dim>> : vec_traits_defaults<stairs::Point_<Dim>, stairs::Coordinate_t, Dim>
{
template<int I>
static stairs::Coordinate_t &write_element(stairs::Point_<Dim>&);
};
template<> template<>
inline stairs::Coordinate_t &vec_traits<stairs::Point2>::write_element<0>(stairs::Point2 &p)
{
return p.x;
}
template<> template<>
inline stairs::Coordinate_t &vec_traits<stairs::Point2>::write_element<1>(stairs::Point2 &p)
{
return p.y;
}
template<> template<>
inline stairs::Coordinate_t &vec_traits<stairs::Point3>::write_element<0>(stairs::Point3 &p)
{
return p.x;
}
template<> template<>
inline stairs::Coordinate_t &vec_traits<stairs::Point3>::write_element<1>(stairs::Point3 &p)
{
return p.y;
}
template<> template<>
inline stairs::Coordinate_t &vec_traits<stairs::Point3>::write_element<2>(stairs::Point3 &p)
{
return p.z;
}
/*
* rs2::vertex
*/
template<>
struct vec_traits<rs2::vertex> : vec_traits_defaults<rs2::vertex, float, 3>
{
template<int I>
static float &write_element(rs2::vertex&);
};
template<>
inline float &vec_traits<rs2::vertex>::write_element<0>(rs2::vertex &v)
{
return v.x;
}
template<>
inline float &vec_traits<rs2::vertex>::write_element<1>(rs2::vertex &v)
{
return v.y;
}
template<>
inline float &vec_traits<rs2::vertex>::write_element<2>(rs2::vertex &v)
{
return v.z;
}
template<class, int, int> struct mat;
}} // namespace boost::qvm
namespace stairs
{
template<int Dim>
using Matrix_ = boost::qvm::mat<Coordinate_t, Dim, Dim>;
}
namespace boost { namespace qvm
{
/*
* specify result type of matrix-vector operations
*/
template<typename PointType, int Dim>
struct deduce_vec2<stairs::Matrix_<Dim>, PointType, Dim>
{
typedef stairs::Point_<Dim> type;
};
}} // namespace boost::qvm
#endif // QVMTRAITS_H_