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 #include <Standard_ShortReal.hxx>
18 // =======================================================================
21 // =======================================================================
22 template<class T, int N>
23 void BVH_Box<T, N>::Clear()
25 myIsInited = Standard_False;
28 // =======================================================================
31 // =======================================================================
32 template<class T, int N>
33 Standard_Boolean BVH_Box<T, N>::IsValid() const
38 // =======================================================================
41 // =======================================================================
42 template<class T, int N>
43 void BVH_Box<T, N>::Add (const BVH_VecNt& thePoint)
47 myMinPoint = thePoint;
48 myMaxPoint = thePoint;
50 myIsInited = Standard_True;
54 myMinPoint = myMinPoint.cwiseMin (thePoint);
55 myMaxPoint = myMaxPoint.cwiseMax (thePoint);
59 // =======================================================================
62 // =======================================================================
63 template<class T, int N>
64 void BVH_Box<T, N>::Combine (const BVH_Box& theBox)
66 if (theBox.myIsInited)
70 myMinPoint = theBox.myMinPoint;
71 myMaxPoint = theBox.myMaxPoint;
73 myIsInited = Standard_True;
77 BVH::BoxMinMax<T, N>::CwiseMin (myMinPoint, theBox.myMinPoint);
78 BVH::BoxMinMax<T, N>::CwiseMax (myMaxPoint, theBox.myMaxPoint);
83 // =======================================================================
86 // =======================================================================
87 template<class T, int N>
88 T BVH_Box<T, N>::Area() const
90 return !myIsInited ? static_cast<T> (0.0) :
91 BVH::SurfaceCalculator<T, N>::Area (myMaxPoint - myMinPoint);
94 // =======================================================================
95 // function : CornerMin
97 // =======================================================================
98 template<class T, int N>
99 const typename BVH_Box<T, N>::BVH_VecNt& BVH_Box<T, N>::CornerMin() const
104 // =======================================================================
105 // function : CornerMax
107 // =======================================================================
108 template<class T, int N>
109 const typename BVH_Box<T, N>::BVH_VecNt& BVH_Box<T, N>::CornerMax() const
114 // =======================================================================
115 // function : CornerMin
117 // =======================================================================
118 template<class T, int N>
119 typename BVH_Box<T, N>::BVH_VecNt& BVH_Box<T, N>::CornerMin()
124 // =======================================================================
125 // function : CornerMax
127 // =======================================================================
128 template<class T, int N>
129 typename BVH_Box<T, N>::BVH_VecNt& BVH_Box<T, N>::CornerMax()
134 // =======================================================================
137 // =======================================================================
138 template<class T, int N>
139 typename BVH_Box<T, N>::BVH_VecNt BVH_Box<T, N>::Size() const
141 return myMaxPoint - myMinPoint;
144 // =======================================================================
147 // =======================================================================
148 template<class T, int N>
149 typename BVH_Box<T, N>::BVH_VecNt BVH_Box<T, N>::Center() const
151 return (myMinPoint + myMaxPoint) * static_cast<T> (0.5);
154 // =======================================================================
157 // =======================================================================
158 template<class T, int N>
159 T BVH_Box<T, N>::Center (const Standard_Integer theAxis) const
161 return BVH::CenterAxis<T, N>::Center (*this, theAxis);