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.
18 template<class T, int N> struct VecComp
23 template<class T> struct VecComp<T, 2>
25 typedef typename BVHTools::VectorType<T, 2>::Type BVH_Vec2t;
27 static T Get (const BVH_Vec2t& theVec,
28 const Standard_Integer theAxis)
30 return theAxis == 0 ? theVec.x() : theVec.y();
34 template<class T> struct VecComp<T, 3>
36 typedef typename BVHTools::VectorType<T, 3>::Type BVH_Vec3t;
38 static T Get (const BVH_Vec3t& theVec,
39 const Standard_Integer theAxis)
41 return theAxis == 0 ? theVec.x() : ( theAxis == 1 ? theVec.y() : theVec.z() );
45 template<class T> struct VecComp<T, 4>
47 typedef typename BVHTools::VectorType<T, 4>::Type BVH_Vec4t;
49 static T Get (const BVH_Vec4t& theVec,
50 const Standard_Integer theAxis)
54 : (theAxis == 1 ? theVec.y() : ( theAxis == 2 ? theVec.z() : theVec.w() ));
58 template<class T, int N = 1> struct ArrayOp
60 typedef typename BVHTools::ArrayType<T, N>::Type BVH_ArrayNt;
63 const typename BVHTools::VectorType<T, N>::Type& Value (const BVH_ArrayNt& theArray,
64 const Standard_Integer theIndex)
66 #ifdef _BVH_USE_STD_VECTOR_
67 return theArray.at (theIndex);
69 return theArray.Value (theIndex);
74 typename BVHTools::VectorType<T, N>::Type& ChangeValue (BVH_ArrayNt& theArray,
75 const Standard_Integer theIndex)
77 #ifdef _BVH_USE_STD_VECTOR_
78 return theArray.at (theIndex);
80 return theArray.ChangeValue (theIndex);
84 static inline void Append (BVH_ArrayNt& theArray,
85 const typename BVHTools::VectorType<T, N>::Type& theElement)
87 #ifdef _BVH_USE_STD_VECTOR_
88 theArray.push_back (theElement);
90 theArray.Append (theElement);
94 static inline Standard_Integer Size (const BVH_ArrayNt& theArray)
96 #ifdef _BVH_USE_STD_VECTOR_
97 return static_cast<Standard_Integer> (theArray.size());
99 return static_cast<Standard_Integer> (theArray.Size());
103 static inline void Clear (BVH_ArrayNt& theArray)
105 #ifdef _BVH_USE_STD_VECTOR_