| http://www.sim.no/ http://www.coin3d.org/

SbBox3d.h
1 #ifndef COIN_SBBOX3D_H
2 #define COIN_SBBOX3D_H
3
4 /**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25 \**************************************************************************/
26
27 #include <stdio.h>
28
29 #include <Inventor/SbVec3d.h>
30
31 class SbBox3f;
32 class SbBox3s;
33 class SbBox3i32;
34
35 class SbDPMatrix;
36
37 class COIN_DLL_API SbBox3d {
38 public:
39 SbBox3d(void) { makeEmpty(); }
40 SbBox3d(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
41 : minpt(xmin, ymin, zmin), maxpt(xmax, ymax, zmax) { }
42 SbBox3d(const SbVec3d & minpoint, const SbVec3d & maxpoint)
43 : minpt(minpoint), maxpt(maxpoint) { }
44 explicit SbBox3d(const SbBox3f & box) { setBounds(box); }
45 explicit SbBox3d(const SbBox3s & box) { setBounds(box); }
46 explicit SbBox3d(const SbBox3i32 & box) { setBounds(box); }
47
48 SbBox3d & setBounds(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
49 { minpt.setValue(xmin, ymin, zmin); maxpt.setValue(xmax, ymax, zmax); return *this; }
50 SbBox3d & setBounds(const SbVec3d & minpoint, const SbVec3d & maxpoint)
51 { minpt = minpoint; maxpt = maxpoint; return *this; }
52 SbBox3d & setBounds(const SbBox3f & box);
53 SbBox3d & setBounds(const SbBox3s & box);
54 SbBox3d & setBounds(const SbBox3i32 & box);
55
56 void getBounds(double & xmin, double & ymin, double & zmin, double & xmax, double & ymax, double & zmax) const
57 { minpt.getValue(xmin, ymin, zmin); maxpt.getValue(xmax, ymax, zmax); }
58 void getBounds(SbVec3d & minpoint, SbVec3d & maxpoint) const
59 { minpoint = minpt; maxpoint = maxpt; }
60
61 const SbVec3d & getMin(void) const { return minpt; }
62 SbVec3d & getMin(void) { return minpt; }
63 const SbVec3d & getMax(void) const { return maxpt; }
64 SbVec3d & getMax(void) { return maxpt; }
65
66 void extendBy(const SbVec3d & pt);
67 void extendBy(const SbBox3d & box);
68 void transform(const SbDPMatrix & matrix);
69 void makeEmpty(void);
70 SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
71 SbBool hasVolume(void) const
72 { return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1]) && (maxpt[2] > minpt[2])); }
73 double getVolume(void) const
74 { double dx = 0.0, dy = 0.0, dz = 0.0; getSize(dx, dy, dz); return (dx * dy * dz); }
75
76 SbBool intersect(const SbVec3d & point) const;
77 SbBool intersect(const SbBox3d & box) const;
78 SbVec3d getClosestPoint(const SbVec3d & point) const;
79 SbBool outside(const SbDPMatrix & mvp, int & cullbits) const;
80
81 SbVec3d getCenter(void) const { return (minpt + maxpt) * 0.5; }
82 void getOrigin(double & origoX, double & origoY, double & origoZ) const
83 { minpt.getValue(origoX, origoY, origoZ); }
84 void getSize(double & sizeX, double & sizeY, double & sizeZ) const
85 { if (isEmpty()) { sizeX = sizeY = sizeZ = 0.0; }
86 else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; sizeZ = maxpt[2] - minpt[2]; } }
87 SbVec3d getSize(void) const {
88 SbVec3d v;
89 this->getSize(v[0], v[1], v[2]);
90 return v;
91 }
92 void getSpan(const SbVec3d & dir, double & dmin, double & dmax) const;
93
94 void print(FILE * file) const;
95
96 protected:
97 SbVec3d minpt, maxpt;
98
99 }; // SbBox3d
100
101 COIN_DLL_API inline int operator == (const SbBox3d & b1, const SbBox3d & b2) {
102 return ((b1.getMin() == b2.getMin()) && (b1.getMax() == b2.getMax()));
103 }
104
105 COIN_DLL_API inline int operator != (const SbBox3d & b1, const SbBox3d & b2) {
106 return !(b1 == b2);
107 }
108
109 #endif // !COIN_SBBOX3D_H
SbBox3d::getOrigin
void getOrigin(double &origoX, double &origoY, double &origoZ) const
Definition: SbBox3d.h:82
SbBox3s
The SbBox3s class is a 3 dimensional box with short integer coordinates.This box class is used by oth...
Definition: SbBox3s.h:34
SbVec3d
The SbVec3d class is a 3 dimensional vector with double precision floating point coordinates.This vector class provides storage for a 3 dimensional double precision floating point vector aswell as simple floating point arithmetic operations.
Definition: SbVec3d.h:39
SbBox3d::setBounds
SbBox3d & setBounds(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: SbBox3d.h:48
SbBox3d::isEmpty
SbBool isEmpty(void) const
Definition: SbBox3d.h:70
SbBox3f
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.This box abstraction class ...
Definition: SbBox3f.h:37
SbBox2d::operator!=
int operator!=(const SbBox2d &b1, const SbBox2d &b2)
Definition: SbBox2d.h:92
SbBox3d::getSize
SbVec3d getSize(void) const
Definition: SbBox3d.h:87
SbBox2d::operator==
int operator==(const SbBox2d &b1, const SbBox2d &b2)
Definition: SbBox2d.h:88
SbBox3d::SbBox3d
SbBox3d(void)
Definition: SbBox3d.h:39
SbBox3d::setBounds
SbBox3d & setBounds(const SbVec3d &minpoint, const SbVec3d &maxpoint)
Definition: SbBox3d.h:50
SbBox3d::SbBox3d
SbBox3d(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: SbBox3d.h:40
SbBox3d::getBounds
void getBounds(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
Definition: SbBox3d.h:56
SbBox3d::getMin
SbVec3d & getMin(void)
Definition: SbBox3d.h:62
SbBox3d::SbBox3d
SbBox3d(const SbVec3d &minpoint, const SbVec3d &maxpoint)
Definition: SbBox3d.h:42
SbBox3d::getBounds
void getBounds(SbVec3d &minpoint, SbVec3d &maxpoint) const
Definition: SbBox3d.h:58
SbBox3d::getSize
void getSize(double &sizeX, double &sizeY, double &sizeZ) const
Definition: SbBox3d.h:84
SbBox3d::getMin
const SbVec3d & getMin(void) const
Definition: SbBox3d.h:61
SbBox3d::getVolume
double getVolume(void) const
Definition: SbBox3d.h:73
SbBox3d
The SbBox3d class is an abstraction for an axis aligned 3 dimensional box.This box abstraction class ...
Definition: SbBox3d.h:37
SbBox3d::hasVolume
SbBool hasVolume(void) const
Definition: SbBox3d.h:71
SbBox3d::getMax
SbVec3d & getMax(void)
Definition: SbBox3d.h:64
SbBox3d::getCenter
SbVec3d getCenter(void) const
Definition: SbBox3d.h:81
SbDPMatrix
The SbDPMatrix class is a 4x4 dimensional representation of a double-precision matrix.This class is like the SbMatrix class, but uses double-precision floating point values for its elements. For more class documentation, see SbMatrix.
Definition: SbDPMatrix.h:38
SbBox3d::getMax
const SbVec3d & getMax(void) const
Definition: SbBox3d.h:63

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.