1 // Created on: 2013-12-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BVH_Types_Header
17 #define _BVH_Types_Header
19 // Use this macro to switch between STL and OCCT vector types
20 #define _BVH_USE_STD_VECTOR_
22 #include <NCollection_Vec2.hxx>
23 #include <NCollection_Vec3.hxx>
24 #include <NCollection_Vec4.hxx>
25 #include <NCollection_Vector.hxx>
26 #include <NCollection_Mat4.hxx>
27 #include <Standard_Type.hxx>
33 //! Allows for fast switching between Eigen and NCollection vectors.
34 template<class T, int N> struct VectorType
39 template<class T> struct VectorType<T, 1>
44 template<class T> struct VectorType<T, 2>
46 typedef NCollection_Vec2<T> Type;
49 template<class T> struct VectorType<T, 3>
51 typedef NCollection_Vec3<T> Type;
54 template<class T> struct VectorType<T, 4>
56 typedef NCollection_Vec4<T> Type;
59 template<class T, int N = 1> struct ArrayType
61 #ifndef _BVH_USE_STD_VECTOR_
62 typedef NCollection_Vector<typename VectorType<T, N>::Type> Type;
64 typedef std::vector<typename VectorType<T, N>::Type> Type;
68 //! Allows to fast switching between Eigen and NCollection matrices.
69 template<class T, int N> struct MatrixType
74 template<class T> struct MatrixType<T, 4>
76 typedef NCollection_Mat4<T> Type;
80 static inline Standard_Integer IntFloor (const T theValue)
82 const Standard_Integer aRes = static_cast<Standard_Integer> (theValue);
84 return aRes - static_cast<Standard_Integer> (aRes > theValue);
88 //! 2D vector of integers.
89 typedef BVH::VectorType<Standard_Integer, 2>::Type BVH_Vec2i;
90 //! 3D vector of integers.
91 typedef BVH::VectorType<Standard_Integer, 3>::Type BVH_Vec3i;
92 //! 4D vector of integers.
93 typedef BVH::VectorType<Standard_Integer, 4>::Type BVH_Vec4i;
95 //! Array of 2D vectors of integers.
96 typedef BVH::ArrayType<Standard_Integer, 2>::Type BVH_Array2i;
97 //! Array of 3D vectors of integers.
98 typedef BVH::ArrayType<Standard_Integer, 3>::Type BVH_Array3i;
99 //! Array of 4D vectors of integers.
100 typedef BVH::ArrayType<Standard_Integer, 4>::Type BVH_Array4i;
102 //! 2D vector of single precision reals.
103 typedef BVH::VectorType<Standard_ShortReal, 2>::Type BVH_Vec2f;
104 //! 3D vector of single precision reals.
105 typedef BVH::VectorType<Standard_ShortReal, 3>::Type BVH_Vec3f;
106 //! 4D vector of single precision reals.
107 typedef BVH::VectorType<Standard_ShortReal, 4>::Type BVH_Vec4f;
109 //! Array of 2D vectors of single precision reals.
110 typedef BVH::ArrayType<Standard_ShortReal, 2>::Type BVH_Array2f;
111 //! Array of 3D vectors of single precision reals.
112 typedef BVH::ArrayType<Standard_ShortReal, 3>::Type BVH_Array3f;
113 //! Array of 4D vectors of single precision reals.
114 typedef BVH::ArrayType<Standard_ShortReal, 4>::Type BVH_Array4f;
116 //! 2D vector of double precision reals.
117 typedef BVH::VectorType<Standard_Real, 2>::Type BVH_Vec2d;
118 //! 3D vector of double precision reals.
119 typedef BVH::VectorType<Standard_Real, 3>::Type BVH_Vec3d;
120 //! 4D vector of double precision reals.
121 typedef BVH::VectorType<Standard_Real, 4>::Type BVH_Vec4d;
123 //! Array of 2D vectors of double precision reals.
124 typedef BVH::ArrayType<Standard_Real, 2>::Type BVH_Array2d;
125 //! Array of 3D vectors of double precision reals.
126 typedef BVH::ArrayType<Standard_Real, 3>::Type BVH_Array3d;
127 //! Array of 4D vectors of double precision reals.
128 typedef BVH::ArrayType<Standard_Real, 4>::Type BVH_Array4d;
130 //! 4x4 matrix of single precision reals.
131 typedef BVH::MatrixType<Standard_ShortReal, 4>::Type BVH_Mat4f;
133 //! 4x4 matrix of double precision reals.
134 typedef BVH::MatrixType<Standard_Real, 4>::Type BVH_Mat4d;
136 #include <BVH_Types.lxx>
138 #endif // _BVH_Types_Header