3c4e78f2 |
1 | // Created on: 2013-12-20 |
2 | // Created by: Denis BOGOLEPOV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
3c4e78f2 |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
d5f74e42 |
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 |
3c4e78f2 |
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 | // ======================================================================= |
17 | // function : BVH_Triangulation |
18 | // purpose : |
19 | // ======================================================================= |
20 | template<class T, int N> |
21 | BVH_Triangulation<T, N>::BVH_Triangulation() |
22 | { |
23 | // |
24 | } |
25 | |
26 | // ======================================================================= |
27 | // function : ~BVH_Triangulation |
28 | // purpose : |
29 | // ======================================================================= |
30 | template<class T, int N> |
31 | BVH_Triangulation<T, N>::~BVH_Triangulation() |
32 | { |
33 | // |
34 | } |
35 | |
36 | // ======================================================================= |
37 | // function : Size |
38 | // purpose : |
39 | // ======================================================================= |
40 | template<class T, int N> |
41 | Standard_Integer BVH_Triangulation<T, N>::Size() const |
42 | { |
3a7a7013 |
43 | return BVH::ArrayOp<Standard_Integer, 4>::Size (Elements); |
3c4e78f2 |
44 | } |
45 | |
46 | // ======================================================================= |
47 | // function : Box |
48 | // purpose : |
49 | // ======================================================================= |
50 | template<class T, int N> |
51 | BVH_Box<T, N> BVH_Triangulation<T, N>::Box (const Standard_Integer theIndex) const |
52 | { |
3a7a7013 |
53 | const BVH_Vec4i& anIndex = BVH::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex); |
3c4e78f2 |
54 | |
3a7a7013 |
55 | const BVH_VecNt& aPoint0 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.x()); |
56 | const BVH_VecNt& aPoint1 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.y()); |
57 | const BVH_VecNt& aPoint2 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.z()); |
3c4e78f2 |
58 | |
3a7a7013 |
59 | BVH_VecNt aMinPoint = aPoint0; |
60 | BVH_VecNt aMaxPoint = aPoint0; |
61 | |
62 | BVH::BoxMinMax<T, N>::CwiseMin (aMinPoint, aPoint1); |
63 | BVH::BoxMinMax<T, N>::CwiseMin (aMinPoint, aPoint2); |
64 | BVH::BoxMinMax<T, N>::CwiseMax (aMaxPoint, aPoint1); |
65 | BVH::BoxMinMax<T, N>::CwiseMax (aMaxPoint, aPoint2); |
3c4e78f2 |
66 | |
67 | return BVH_Box<T, N> (aMinPoint, aMaxPoint); |
68 | } |
69 | |
70 | // ======================================================================= |
71 | // function : Center |
72 | // purpose : |
73 | // ======================================================================= |
74 | template<class T, int N> |
75 | T BVH_Triangulation<T, N>::Center (const Standard_Integer theIndex, |
76 | const Standard_Integer theAxis) const |
77 | { |
3a7a7013 |
78 | const BVH_Vec4i& anIndex = BVH::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex); |
3c4e78f2 |
79 | |
3a7a7013 |
80 | const BVH_VecNt& aPoint0 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.x()); |
81 | const BVH_VecNt& aPoint1 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.y()); |
82 | const BVH_VecNt& aPoint2 = BVH::ArrayOp<T, N>::Value (Vertices, anIndex.z()); |
3c4e78f2 |
83 | |
3a7a7013 |
84 | return ( BVH::VecComp<T, N>::Get (aPoint0, theAxis) + |
85 | BVH::VecComp<T, N>::Get (aPoint1, theAxis) + |
86 | BVH::VecComp<T, N>::Get (aPoint2, theAxis) ) * static_cast<T> (1.0 / 3.0); |
3c4e78f2 |
87 | } |
88 | |
89 | // ======================================================================= |
90 | // function : Swap |
91 | // purpose : |
92 | // ======================================================================= |
93 | template<class T, int N> |
94 | void BVH_Triangulation<T, N>::Swap (const Standard_Integer theIndex1, |
95 | const Standard_Integer theIndex2) |
96 | { |
0ef61b50 |
97 | BVH_Vec4i& anIndices1 = BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex1); |
98 | BVH_Vec4i& anIndices2 = BVH::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex2); |
3c4e78f2 |
99 | |
0ef61b50 |
100 | std::swap (anIndices1, anIndices2); |
3c4e78f2 |
101 | } |