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
getMin(void)74   const SbVec3f & getMin(void) const {return SbBox3f::getMin(); }
getMax(void)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
87