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 | { |
43 | return BVHTools::ArrayOp<Standard_Integer, 4>::Size (Elements); |
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 | { |
53 | const BVH_Vec4i& anIndex = BVHTools::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex); |
54 | |
55 | const BVH_VecNt& aPoint0 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.x()); |
56 | const BVH_VecNt& aPoint1 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.y()); |
57 | const BVH_VecNt& aPoint2 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.z()); |
58 | |
59 | const BVH_VecNt aMinPoint = aPoint0.cwiseMin (aPoint1.cwiseMin (aPoint2)); |
60 | const BVH_VecNt aMaxPoint = aPoint0.cwiseMax (aPoint1.cwiseMax (aPoint2)); |
61 | |
62 | return BVH_Box<T, N> (aMinPoint, aMaxPoint); |
63 | } |
64 | |
65 | // ======================================================================= |
66 | // function : Center |
67 | // purpose : |
68 | // ======================================================================= |
69 | template<class T, int N> |
70 | T BVH_Triangulation<T, N>::Center (const Standard_Integer theIndex, |
71 | const Standard_Integer theAxis) const |
72 | { |
73 | const BVH_Vec4i& anIndex = BVHTools::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex); |
74 | |
75 | const BVH_VecNt& aPoint0 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.x()); |
76 | const BVH_VecNt& aPoint1 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.y()); |
77 | const BVH_VecNt& aPoint2 = BVHTools::ArrayOp<T, N>::Value (Vertices, anIndex.z()); |
78 | |
79 | return ( BVHTools::VecComp<T, N>::Get (aPoint0, theAxis) + |
80 | BVHTools::VecComp<T, N>::Get (aPoint1, theAxis) + |
81 | BVHTools::VecComp<T, N>::Get (aPoint2, theAxis) ) * static_cast<T> (1.0 / 3.0); |
82 | } |
83 | |
84 | // ======================================================================= |
85 | // function : Swap |
86 | // purpose : |
87 | // ======================================================================= |
88 | template<class T, int N> |
89 | void BVH_Triangulation<T, N>::Swap (const Standard_Integer theIndex1, |
90 | const Standard_Integer theIndex2) |
91 | { |
92 | BVH_Vec4i anIndices1 = BVHTools::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex1); |
93 | BVH_Vec4i anIndices2 = BVHTools::ArrayOp<Standard_Integer, 4>::Value (Elements, theIndex2); |
94 | |
95 | BVHTools::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex1) = anIndices2; |
96 | BVHTools::ArrayOp<Standard_Integer, 4>::ChangeValue (Elements, theIndex2) = anIndices1; |
97 | } |