0024739: TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and...
[occt.git] / src / BVH / BVH_Types.hxx
1 // Created on: 2013-12-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _BVH_Types_Header
17 #define _BVH_Types_Header
18
19 // Use this macro to switch between STL and OCCT vector types
20 #define _BVH_USE_STD_VECTOR_
21
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>
28
29 #include <vector>
30
31 namespace BVHTools
32 {
33   //! Allows to fast switching between Eigen and NCollection vectors.
34   template<class T, int N> struct VectorType
35   {
36     // Not implemented
37   };
38
39   template<class T> struct VectorType<T, 1>
40   {
41     typedef T Type;
42   };
43
44   template<class T> struct VectorType<T, 2>
45   {
46     typedef NCollection_Vec2<T> Type;
47   };
48
49   template<class T> struct VectorType<T, 3>
50   {
51     typedef NCollection_Vec3<T> Type;
52   };
53
54   template<class T> struct VectorType<T, 4>
55   {
56     typedef NCollection_Vec4<T> Type;
57   };
58
59   template<class T, int N = 1> struct ArrayType
60   {
61   #ifndef _BVH_USE_STD_VECTOR_
62     typedef NCollection_Vector<typename VectorType<T, N>::Type> Type;
63   #else
64     typedef std::vector<typename VectorType<T, N>::Type> Type;
65   #endif
66   };
67
68   //! Allows to fast switching between Eigen and NCollection matrices.
69   template<class T, int N> struct MatrixType
70   {
71     // Not implemented
72   };
73
74   template<class T> struct MatrixType<T, 4>
75   {
76     typedef NCollection_Mat4<T> Type;
77   };
78 }
79
80 //! 2D vector of integers.
81 typedef BVHTools::VectorType<Standard_Integer, 2>::Type BVH_Vec2i;
82 //! 3D vector of integers.
83 typedef BVHTools::VectorType<Standard_Integer, 3>::Type BVH_Vec3i;
84 //! 4D vector of integers.
85 typedef BVHTools::VectorType<Standard_Integer, 4>::Type BVH_Vec4i;
86
87 //! Array of 2D vectors of integers.
88 typedef BVHTools::ArrayType<Standard_Integer, 2>::Type BVH_Array2i;
89 //! Array of 3D vectors of integers.
90 typedef BVHTools::ArrayType<Standard_Integer, 3>::Type BVH_Array3i;
91 //! Array of 4D vectors of integers.
92 typedef BVHTools::ArrayType<Standard_Integer, 4>::Type BVH_Array4i;
93
94 //! 2D vector of single precision reals.
95 typedef BVHTools::VectorType<Standard_ShortReal, 2>::Type BVH_Vec2f;
96 //! 3D vector of single precision reals.
97 typedef BVHTools::VectorType<Standard_ShortReal, 3>::Type BVH_Vec3f;
98 //! 4D vector of single precision reals.
99 typedef BVHTools::VectorType<Standard_ShortReal, 4>::Type BVH_Vec4f;
100
101 //! Array of 2D vectors of single precision reals.
102 typedef BVHTools::ArrayType<Standard_ShortReal, 2>::Type BVH_Array2f;
103 //! Array of 3D vectors of single precision reals.
104 typedef BVHTools::ArrayType<Standard_ShortReal, 3>::Type BVH_Array3f;
105 //! Array of 4D vectors of single precision reals.
106 typedef BVHTools::ArrayType<Standard_ShortReal, 4>::Type BVH_Array4f;
107
108 //! 2D vector of double precision reals.
109 typedef BVHTools::VectorType<Standard_Real, 2>::Type BVH_Vec2d;
110 //! 3D vector of double precision reals.
111 typedef BVHTools::VectorType<Standard_Real, 3>::Type BVH_Vec3d;
112 //! 4D vector of double precision reals.
113 typedef BVHTools::VectorType<Standard_Real, 4>::Type BVH_Vec4d;
114
115 //! Array of 2D vectors of double precision reals.
116 typedef BVHTools::ArrayType<Standard_Real, 2>::Type BVH_Array2d;
117 //! Array of 3D vectors of double precision reals.
118 typedef BVHTools::ArrayType<Standard_Real, 3>::Type BVH_Array3d;
119 //! Array of 4D vectors of double precision reals.
120 typedef BVHTools::ArrayType<Standard_Real, 4>::Type BVH_Array4d;
121
122 //! 4x4 matrix of single precision reals.
123 typedef BVHTools::MatrixType<Standard_ShortReal, 4>::Type BVH_Mat4f;
124
125 //! 4x4 matrix of double precision reals.
126 typedef BVHTools::MatrixType<Standard_Real, 4>::Type BVH_Mat4d;
127
128 #include <BVH_Types.lxx>
129
130 #endif // _BVH_Types_Header