general.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5  * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6  *
7  * THE BSD LICENSE
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *************************************************************************/
30 
31 #ifndef RTABMAP_FLANN_GENERAL_H_
32 #define RTABMAP_FLANN_GENERAL_H_
33 
34 #include "defines.h"
35 #include <stdexcept>
36 #include <cassert>
37 #include <limits.h>
38 
39 namespace rtflann
40 {
41 
42 class FLANNException : public std::runtime_error
43 {
44 public:
45  FLANNException(const char* message) : std::runtime_error(message) { }
46 
47  FLANNException(const std::string& message) : std::runtime_error(message) { }
48 };
49 
50 
51 template <typename T>
52 struct flann_datatype_value
53 {
54  static const flann_datatype_t value = FLANN_NONE;
55 };
56 
57 template<>
58 struct flann_datatype_value<char>
59 {
60  static const flann_datatype_t value = FLANN_INT8;
61 };
62 
63 template<>
64 struct flann_datatype_value<short>
65 {
66  static const flann_datatype_t value = FLANN_INT16;
67 };
68 
69 template<>
71 {
72  static const flann_datatype_t value = FLANN_INT32;
73 };
74 
75 #ifdef LLONG_MAX
76 template<>
77 struct flann_datatype_value<long long>
78 {
79  static const flann_datatype_t value = FLANN_INT64;
80 };
81 #endif
82 
83 template<>
84 struct flann_datatype_value<unsigned char>
85 {
87 };
88 
89 template<>
90 struct flann_datatype_value<unsigned short>
91 {
93 };
94 
95 template<>
96 struct flann_datatype_value<unsigned int>
97 {
99 };
100 
101 #ifdef ULLONG_MAX
102 template<>
103 struct flann_datatype_value<unsigned long long>
104 {
105  static const flann_datatype_t value = FLANN_UINT64;
106 };
107 #endif
108 
109 
110 template<>
112 {
113  static const flann_datatype_t value = FLANN_FLOAT32;
114 };
115 
116 template<>
117 struct flann_datatype_value<double>
118 {
119  static const flann_datatype_t value = FLANN_FLOAT64;
120 };
121 
122 
123 
124 template <flann_datatype_t datatype>
125 struct flann_datatype_type
126 {
127  typedef void type;
128 };
129 
130 template<>
132 {
133  typedef char type;
134 };
135 
136 template<>
137 struct flann_datatype_type<FLANN_INT16>
138 {
139  typedef short type;
140 };
141 
142 template<>
144 {
145  typedef int type;
146 };
147 
148 #ifdef LLONG_MAX
149 template<>
151 {
152  typedef long long type;
153 };
154 #endif
155 
156 template<>
158 {
159  typedef unsigned char type;
160 };
161 
162 
163 template<>
165 {
166  typedef unsigned short type;
167 };
168 
169 template<>
171 {
172  typedef unsigned int type;
173 };
174 
175 #ifdef ULLONG_MAX
176 template<>
178 {
179  typedef unsigned long long type;
180 };
181 #endif
182 
183 template<>
184 struct flann_datatype_type<FLANN_FLOAT32>
185 {
186  typedef float type;
187 };
188 
189 template<>
191 {
192  typedef double type;
193 };
194 
195 
197 {
198  switch (type) {
199  case FLANN_INT8:
201  case FLANN_INT16:
203  case FLANN_INT32:
205  case FLANN_INT64:
207  case FLANN_UINT8:
209  case FLANN_UINT16:
211  case FLANN_UINT32:
213  case FLANN_UINT64:
215  case FLANN_FLOAT32:
217  case FLANN_FLOAT64:
219  default:
220  return 0;
221  }
222 }
223 
224 }
225 
226 
227 #endif /* RTABMAP_FLANN_GENERAL_H_ */
int
int
rtflann::flann_datatype_type::type
void type
Definition: general.h:155
rtflann::FLANN_FLOAT32
@ FLANN_FLOAT32
Definition: defines.h:142
rtflann::FLANN_FLOAT64
@ FLANN_FLOAT64
Definition: defines.h:143
rtflann::FLANN_INT16
@ FLANN_INT16
Definition: defines.h:135
type
rtflann::FLANN_UINT64
@ FLANN_UINT64
Definition: defines.h:141
rtflann::FLANN_UINT16
@ FLANN_UINT16
Definition: defines.h:139
rtflann::flann_datatype_value::value
static const flann_datatype_t value
Definition: general.h:82
defines.h
rtflann::FLANN_INT32
@ FLANN_INT32
Definition: defines.h:136
rtflann::FLANN_INT8
@ FLANN_INT8
Definition: defines.h:134
rtflann::flann_datatype_type
Definition: general.h:153
rtflann::FLANN_INT64
@ FLANN_INT64
Definition: defines.h:137
rtflann::flann_datatype_size
size_t flann_datatype_size(flann_datatype_t type)
Definition: general.h:224
rtflann::flann_datatype_value
Definition: general.h:80
rtflann::FLANN_NONE
@ FLANN_NONE
Definition: defines.h:133
rtflann::FLANNException::FLANNException
FLANNException(const char *message)
Definition: general.h:101
std
rtflann::FLANN_UINT8
@ FLANN_UINT8
Definition: defines.h:138
float
float
rtflann::FLANN_UINT32
@ FLANN_UINT32
Definition: defines.h:140
rtflann
Definition: all_indices.h:49
rtflann::flann_datatype_t
flann_datatype_t
Definition: defines.h:131


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:10