56 #ifndef OPENVOLUMEMESH_VECTOR_HH
57 #define OPENVOLUMEMESH_VECTOR_HH
67 #if defined(__GNUC__) && defined(__SSE__)
68 #include <xmmintrin.h>
74 namespace OpenVolumeMesh {
91 template <
typename Scalar,
int N>
struct VectorDataT
97 #if defined(__GNUC__) && defined(__SSE__)
100 template <>
struct VectorDataT<float, 4>
118 #define TEMPLATE_HEADER template <typename Scalar, int N>
119 #define CLASSNAME VectorT
120 #define DERIVED VectorDataT<Scalar,N>
121 #define unroll(expr) for (int i=0; i<N; ++i) expr(i)
128 #include "VectorT_inc.hh"
131 #undef TEMPLATE_HEADER
140 #if OM_PARTIAL_SPECIALIZATION
143 #define TEMPLATE_HEADER template <typename Scalar>
144 #define CLASSNAME VectorT<Scalar,DIM>
145 #define DERIVED VectorDataT<Scalar,DIM>
149 #define unroll(expr) expr(0) expr(1)
150 #define unroll_comb(expr, op) expr(0) op expr(1)
151 #define unroll_csv(expr) expr(0), expr(1)
152 #include "VectorT_inc.hh"
160 #define unroll(expr) expr(0) expr(1) expr(2)
161 #define unroll_comb(expr, op) expr(0) op expr(1) op expr(2)
162 #define unroll_csv(expr) expr(0), expr(1), expr(2)
163 #include "VectorT_inc.hh"
171 #define unroll(expr) expr(0) expr(1) expr(2) expr(3)
172 #define unroll_comb(expr, op) expr(0) op expr(1) op expr(2) op expr(3)
173 #define unroll_csv(expr) expr(0), expr(1), expr(2), expr(3)
174 #include "VectorT_inc.hh"
181 #undef TEMPLATE_HEADER
193 inline VectorT<float,3>
194 VectorT<float,3>::operator%(
const VectorT<float,3>& _rhs)
const
197 VectorT<float,3>(values_[1]*_rhs.values_[2]-values_[2]*_rhs.values_[1],
198 values_[2]*_rhs.values_[0]-values_[0]*_rhs.values_[2],
199 values_[0]*_rhs.values_[1]-values_[1]*_rhs.values_[0]);
205 inline VectorT<double,3>
206 VectorT<double,3>::operator%(
const VectorT<double,3>& _rhs)
const
209 VectorT<double,3>(values_[1]*_rhs.values_[2]-values_[2]*_rhs.values_[1],
210 values_[2]*_rhs.values_[0]-values_[0]*_rhs.values_[2],
211 values_[0]*_rhs.values_[1]-values_[1]*_rhs.values_[0]);
223 template<
typename Scalar,
int N>
224 inline VectorT<Scalar,N> operator*(Scalar _s,
const VectorT<Scalar,N>& _v) {
225 return VectorT<Scalar,N>(_v) *= _s;
231 template<
typename Scalar,
int N>
233 dot(
const VectorT<Scalar,N>& _v1,
const VectorT<Scalar,N>& _v2) {
240 template<
typename Scalar,
int N>
241 inline VectorT<Scalar,N>
242 cross(
const VectorT<Scalar,N>& _v1,
const VectorT<Scalar,N>& _v2) {
252 typedef VectorT<signed char,1> Vec1c;
254 typedef VectorT<unsigned char,1> Vec1uc;
256 typedef VectorT<signed short int,1> Vec1s;
258 typedef VectorT<unsigned short int,1> Vec1us;
260 typedef VectorT<signed int,1> Vec1i;
262 typedef VectorT<unsigned int,1> Vec1ui;
264 typedef VectorT<float,1> Vec1f;
266 typedef VectorT<double,1> Vec1d;
269 typedef VectorT<signed char,2> Vec2c;
271 typedef VectorT<unsigned char,2> Vec2uc;
273 typedef VectorT<signed short int,2> Vec2s;
275 typedef VectorT<unsigned short int,2> Vec2us;
277 typedef VectorT<signed int,2> Vec2i;
279 typedef VectorT<unsigned int,2> Vec2ui;
281 typedef VectorT<float,2> Vec2f;
283 typedef VectorT<double,2> Vec2d;
286 typedef VectorT<signed char,3> Vec3c;
288 typedef VectorT<unsigned char,3> Vec3uc;
290 typedef VectorT<signed short int,3> Vec3s;
292 typedef VectorT<unsigned short int,3> Vec3us;
294 typedef VectorT<signed int,3> Vec3i;
296 typedef VectorT<unsigned int,3> Vec3ui;
298 typedef VectorT<float,3> Vec3f;
300 typedef VectorT<double,3> Vec3d;
303 typedef VectorT<signed char,4> Vec4c;
305 typedef VectorT<unsigned char,4> Vec4uc;
307 typedef VectorT<signed short int,4> Vec4s;
309 typedef VectorT<unsigned short int,4> Vec4us;
311 typedef VectorT<signed int,4> Vec4i;
313 typedef VectorT<unsigned int,4> Vec4ui;
315 typedef VectorT<float,4> Vec4f;
317 typedef VectorT<double,4> Vec4d;
320 typedef VectorT<signed char,6> Vec6c;
322 typedef VectorT<unsigned char,6> Vec6uc;
324 typedef VectorT<signed short int,6> Vec6s;
326 typedef VectorT<unsigned short int,6> Vec6us;
328 typedef VectorT<signed int,6> Vec6i;
330 typedef VectorT<unsigned int,6> Vec6ui;
332 typedef VectorT<float,6> Vec6f;
334 typedef VectorT<double,6> Vec6d;
340 #endif // OPENVOLUMEMESH_VECTOR_HH defined