00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef mrpt_utils_types_H
00030 #define mrpt_utils_types_H
00031
00032 #include <vector>
00033 #include <list>
00034 #include <set>
00035 #include <map>
00036 #include <string>
00037 #include <stdexcept>
00038
00039
00040 #include "pstdint.h"
00041
00042 #define __STDC_FORMAT_MACROS
00043 #if HAVE_INTTYPES_H
00044 # include <inttypes.h>
00045 #elif defined(_MSC_VER)
00046 # include <mrpt/utils/msvc_inttypes.h>
00047 #endif
00048
00049
00050 #if MRPT_HAS_SSE2
00051 #include <emmintrin.h>
00052 #include <mmintrin.h>
00053 #endif
00054
00055 namespace mrpt
00056 {
00057 typedef std::vector<int64_t> vector_long;
00058 typedef std::vector<int32_t> vector_int;
00059 typedef std::vector<float> vector_float;
00060 typedef std::vector<double> vector_double;
00061 typedef std::vector<uint16_t> vector_word;
00062 typedef std::vector<uint32_t> vector_uint;
00063 typedef std::vector<std::string> vector_string;
00064 typedef std::vector<bool> vector_bool;
00065 typedef std::vector<uint8_t> vector_byte;
00066 typedef std::vector<size_t> vector_size_t;
00067
00068 namespace utils
00069 {
00070
00071
00072
00073
00074
00075
00076
00077 typedef void (*TFunctor_noRet_1inputs)(const void *);
00078
00079
00080
00081 typedef void (*TFunctor_noRet_2inputs)(const void *,const void *);
00082
00083
00084
00085 typedef void (*TFunctor_noRet_3inputs)(const void *,const void *,const void *);
00086
00087
00088
00089
00090
00091
00092
00093
00094 typedef double (*TFunctor_retDouble_1inputs)(const void *);
00095
00096
00097
00098 typedef double (*TFunctor_retDouble_2inputs)(const void *,const void *);
00099
00100
00101
00102 typedef double (*TFunctor_retDouble_3inputs)(const void *,const void *,const void *);
00103
00104
00105
00106
00107
00108
00109
00110
00111 typedef void (*TFunctor_retVecDbl_inpVecDbl)(const vector_double &in, vector_double &out);
00112
00113
00114
00115 typedef void (*TFunctor_retVecFlt_inpVecFlt)(const vector_float &in, vector_float &out);
00116
00117
00118
00119 typedef void (*TFunctor_retVecInt_inpVecInt)(const vector_int &in, vector_int &out);
00120
00121
00122
00123
00124
00125
00126
00127
00128 typedef void (*TFunctor_retVecDbl_inp2VecDbl)(const vector_double &x,const vector_double &y, vector_double &out);
00129
00130
00131
00132 typedef void (*TFunctor_retVecFlt_inp2VecFlt)(const vector_float &x,const vector_float &y, vector_float &out);
00133
00134
00135
00136 typedef void (*TFunctor_retVecInt_inp2VecInt)(const vector_int &x,const vector_int &y, vector_int &out);
00137
00138
00139
00140
00141
00142
00143
00144
00145 typedef double (*TFunctor_retDbl_inp1VecDbl)(const vector_double &in1);
00146
00147
00148
00149 typedef double (*TFunctor_retDbl_inp2VecDbl)(const vector_double &in1,const vector_double &in2);
00150
00151
00152
00153 typedef double (*TFunctor_retDbl_inp3VecDbl)(const vector_double &in1,const vector_double &in2,const vector_double &in3);
00154
00155
00156
00157
00158 #if defined(_MSC_VER) && (_MSC_VER>=1300)
00159 typedef unsigned long long POINTER_TYPE;
00160 #else
00161 typedef unsigned long POINTER_TYPE;
00162 #endif
00163
00164
00165 struct MRPTDLLIMPEXP TColor
00166 {
00167 TColor(uint8_t r=0,uint8_t g=0,uint8_t b=0, uint8_t alpha=255) : R(r),G(g),B(b),A(alpha) { }
00168 uint8_t R,G,B,A;
00169
00170 operator int(void) const { return (((int)R)<<16) | (((int)G)<<8) | B; }
00171
00172 static TColor red;
00173 static TColor green;
00174 static TColor blue;
00175 static TColor white;
00176 static TColor black;
00177 static TColor gray;
00178 };
00179
00180
00181 struct MRPTDLLIMPEXP TColorf
00182 {
00183 TColorf(float r=0,float g=0,float b=0, float alpha=1.0f) : R(r),G(g),B(b),A(alpha) { }
00184 float R,G,B,A;
00185 };
00186
00187
00188 struct MRPTDLLIMPEXP TPixelCoordf
00189 {
00190 double x,y;
00191
00192
00193 TPixelCoordf() : x(),y() {}
00194
00195
00196 TPixelCoordf(const double _x,const double _y) : x(_x), y(_y) { }
00197 };
00198
00199
00200 struct MRPTDLLIMPEXP TPixelCoord
00201 {
00202 TPixelCoord() : x(0),y(0) { }
00203 TPixelCoord(const int _x,const int _y) : x(_x), y(_y) { }
00204
00205 int x,y;
00206 };
00207
00208 typedef TPixelCoord TImageSize;
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 template <typename T>
00219 struct TParameters : public std::map<std::string,T>
00220 {
00221 TParameters() : std::map<std::string,T> () { }
00222 virtual ~TParameters() { std::map<std::string,T>::clear(); }
00223 bool has(const std::string &s) const {
00224 return std::map<std::string,T>::end()!=std::map<std::string,T>::find(s);
00225 }
00226
00227
00228
00229 T operator[](const std::string &s) const {
00230 typename std::map<std::string,T>::const_iterator it =std::map<std::string,T>::find(s);
00231 if (std::map<std::string,T>::end()==it)
00232 throw std::logic_error(std::string("Parameter '")+s+std::string("' is not present.").c_str());
00233 return it->second;
00234 }
00235
00236 double & operator[](const std::string &s) {
00237 return std::map<std::string,double>::operator[](s);
00238 }
00239 };
00240 }
00241 }
00242
00243 #endif
00244