0024669: BVH binned builder fails to separate objects with the same center
[occt.git] / src / BVH / BVH_Box.hxx
CommitLineData
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#ifndef _BVH_Box_Header
17#define _BVH_Box_Header
18
19#include <BVH_Types.hxx>
20
21//! Axis aligned bounding box (AABB).
22template<class T, int N>
23class BVH_Box
24{
25public:
26
27 typedef typename BVHTools::VectorType<T, N>::Type BVH_VecNt;
28
29public:
30
31 //! Creates uninitialized bounding box.
32 BVH_Box() : myInitialized (Standard_False) {}
33
34 //! Creates bounding box of given point.
35 BVH_Box (const BVH_VecNt& thePoint)
36 : myMinPoint (thePoint),
37 myMaxPoint (thePoint),
38 myInitialized (Standard_True) {}
39
40 //! Creates copy of another bounding box.
41 BVH_Box (const BVH_Box& theBox)
42 : myMinPoint (theBox.myMinPoint),
43 myMaxPoint (theBox.myMaxPoint),
44 myInitialized (theBox.myInitialized) {}
45
46 //! Creates bounding box from corner points.
47 BVH_Box (const BVH_VecNt& theMinPoint,
48 const BVH_VecNt& theMaxPoint)
49 : myMinPoint (theMinPoint),
50 myMaxPoint (theMaxPoint),
51 myInitialized (Standard_True) {}
52
53public:
54
55 //! Clears bounding box.
56 void Clear();
57
58 //! Is bounding box valid?
59 Standard_Boolean IsValid() const;
60
61 //! Appends new point to the bounding box.
62 void Add (const BVH_VecNt& thePoint);
63
64 //! Combines bounding box with another one.
65 void Combine (const BVH_Box& theVolume);
66
67 //! Returns minimum point of bounding box.
68 const BVH_VecNt& CornerMin() const;
69
70 //! Returns maximum point of bounding box.
71 const BVH_VecNt& CornerMax() const;
72
73 //! Returns minimum point of bounding box.
74 BVH_VecNt& CornerMin();
75
76 //! Returns maximum point of bounding box.
77 BVH_VecNt& CornerMax();
78
79 //! Returns surface area of bounding box.
80 T Area() const;
81
82 //! Returns diagonal of bounding box.
83 BVH_VecNt Size() const;
84
85 //! Returns center of bounding box.
86 BVH_VecNt Center() const;
87
88protected:
89
90 BVH_VecNt myMinPoint; //!< Minimum point of bounding box
91 BVH_VecNt myMaxPoint; //!< Maximum point of bounding box
92 Standard_Boolean myInitialized; //!< Is bounding box valid?
93
94};
95
96#include <BVH_Box.lxx>
97
98#endif // _BVH_Box_Header