Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
Box.h
1 /**************************************************************************\
2  * Copyright (c) Kongsberg Oil & Gas Technologies AS
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32 
33 #ifndef DIME_BOX_H
34 #define DIME_BOX_H
35 
36 #include <dime/Basic.h>
37 #include <dime/util/Linear.h>
38 
39 class DIME_DLL_API dimeBox
40 {
41 public:
42  dimeVec3f min, max;
43 public:
44  dimeBox();
45  dimeBox(const dxfdouble x0, const dxfdouble y0, const dxfdouble z0,
46  const dxfdouble x1, const dxfdouble y1, const dxfdouble z1);
47 
48  void set(const dxfdouble x0, const dxfdouble y0, const dxfdouble z0,
49  const dxfdouble x1, const dxfdouble y1, const dxfdouble z1);
50 
51  void get(dxfdouble &x0, dxfdouble &y0, dxfdouble &z0,
52  dxfdouble &x1, dxfdouble &y1, dxfdouble &z1) const;
53 
54  bool operator & (const dimeBox &box) const;
55 
56  bool pointInside(const dimeVec3f &pt) const;
57 
58  dimeVec3f center() const;
59 
60  void makeEmpty();
61  void grow(const dimeVec3f &pt);
62  dxfdouble size() const;
63  bool hasExtent() const;
64 }; // class dimeBox
65 
66 inline bool
67 dimeBox::pointInside(const dimeVec3f &pt) const
68 {
69  return ! (pt[0] < this->min[0] || pt[0] >= this->max[0] ||
70  pt[1] < this->min[1] || pt[1] >= this->max[1] ||
71  pt[2] < this->min[2] || pt[2] >= this->max[2]);
72 }
73 
74 inline dimeVec3f
75 dimeBox::center() const
76 {
77  return dimeVec3f((min[0]+max[0])*0.5f,
78  (min[1]+max[1])*0.5f,
79  (min[2]+max[2])*0.5f);
80 }
81 
82 #endif // ! DIME_BOX_H
83 
Definition: Box.h:39
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition: Linear.h:61