Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SbXfBox3f.h
1 #ifndef COIN_SBXFBOX3F_H
2 #define COIN_SBXFBOX3F_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <cstdio>
37 #include <Inventor/SbBox3f.h>
38 #include <Inventor/SbMatrix.h>
39 
40 class COIN_DLL_API SbXfBox3f : public SbBox3f {
41  typedef SbBox3f inherited;
42 
43 public:
44  SbXfBox3f(void);
45  SbXfBox3f(const SbVec3f & boxmin, const SbVec3f & boxmax);
46  SbXfBox3f(const SbBox3f & box);
47  ~SbXfBox3f();
48 
49  void setTransform(const SbMatrix & m);
50  const SbMatrix & getTransform(void) const;
51  const SbMatrix & getInverse(void) const;
52  SbVec3f getCenter(void) const;
53  void extendBy(const SbVec3f & pt);
54  void extendBy(const SbBox3f & bb);
55  void extendBy(const SbXfBox3f & bb);
56  SbBool intersect(const SbVec3f & pt) const;
57  SbBool intersect(const SbBox3f & bb) const;
58  SbBool intersect(const SbXfBox3f & bb) const;
59  void getSpan(const SbVec3f & direction, float & dMin, float & dMax) const;
60  SbBox3f project(void) const;
61  friend COIN_DLL_API int operator ==(const SbXfBox3f & b1, const SbXfBox3f & b2);
62  friend COIN_DLL_API int operator !=(const SbXfBox3f & b1, const SbXfBox3f & b2);
63  // Must override the transform() method from SbBox3f, as the box and
64  // the transform matrix are supposed to be kept separate in
65  // SbXfBox3f. --mortene
66  void transform(const SbMatrix & m);
67  // Overridden from SbBox3f
68  float getVolume(void) const;
69 
70  void print(FILE * file) const;
71 
72 private:
73  // incorrect for SbXfBox3f. Hide them
74  const SbVec3f & getMin(void) const {return SbBox3f::getMin(); }
75  const SbVec3f & getMax(void) const { return SbBox3f::getMax(); }
76 
77  void calcInverse(void) const;
78  void makeInvInvalid(void);
79 
80  SbMatrix matrix, invertedmatrix;
81 };
82 
83 COIN_DLL_API int operator ==(const SbXfBox3f & b1, const SbXfBox3f & b2);
84 COIN_DLL_API int operator !=(const SbXfBox3f & b1, const SbXfBox3f & b2);
85 
86 #endif // !COIN_SBXFBOX3F_H
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition: SbBox3f.h:46
int operator!=(const SbBox3f &b1, const SbBox3f &b2)
Definition: SbBox3f.h:115
float getVolume(void) const
Definition: SbBox3f.h:82
int operator==(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.h:102
void print(FILE *file) const
Definition: SbBox3f.cpp:435
The SbXfBox3f class is a 3 dimensional box with floating point coordinates and an attached transforma...
Definition: SbXfBox3f.h:40
int operator!=(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.h:106
void getSpan(const SbVec3f &dir, float &dmin, float &dmax) const
Definition: SbBox3f.cpp:357
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:51
const SbVec3f & getMax(void) const
Definition: SbBox3f.h:72
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
void extendBy(const SbVec3f &pt)
Definition: SbBox3f.cpp:211
const SbVec3f & getMin(void) const
Definition: SbBox3f.h:70
void transform(const SbMatrix &matrix)
Definition: SbBox3f.cpp:405
SbVec3f getCenter(void) const
Definition: SbBox3f.h:90
SbBool intersect(const SbVec3f &pt) const
Definition: SbBox3f.cpp:251
int operator==(const SbBox3f &b1, const SbBox3f &b2)
Definition: SbBox3f.h:111