SbBox3f.h Source File

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

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

SbBox3f.h
1 #ifndef COIN_SBBOX3F_H
2 #define COIN_SBBOX3F_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/SbVec3f.h>
30
31 class SbBox3d;
32 class SbBox3i32;
33 class SbBox3s;
34
35 class SbMatrix;
36
37 class COIN_DLL_API SbBox3f {
38 public:
39 SbBox3f(void) { makeEmpty(); }
40 SbBox3f(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
41 : minpt(xmin, ymin, zmin), maxpt(xmax, ymax, zmax) { }
42 SbBox3f(const SbVec3f & minpoint, const SbVec3f & maxpoint)
43 : minpt(minpoint), maxpt(maxpoint) { }
44 explicit SbBox3f(const SbBox3d & box) { setBounds(box); }
45 explicit SbBox3f(const SbBox3s & box) { setBounds(box); }
46 explicit SbBox3f(const SbBox3i32 & box) { setBounds(box); }
47
48 SbBox3f & setBounds(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
49 { minpt.setValue(xmin, ymin, zmin); maxpt.setValue(xmax, ymax, zmax); return *this; }
50 SbBox3f & setBounds(const SbVec3f & minpoint, const SbVec3f & maxpoint)
51 { minpt = minpoint; maxpt = maxpoint; return *this; }
52 SbBox3f & setBounds(const SbBox3d & box);
53 SbBox3f & setBounds(const SbBox3s & box);
54 SbBox3f & setBounds(const SbBox3i32 & box);
55
56 void getBounds(float & xmin, float & ymin, float & zmin, float & xmax, float & ymax, float & zmax) const
57 { minpt.getValue(xmin, ymin, zmin); maxpt.getValue(xmax, ymax, zmax); }
58 void getBounds(SbVec3f & minpoint, SbVec3f & maxpoint) const
59 { minpoint = minpt; maxpoint = maxpt; }
60
61 const SbVec3f & getMin(void) const { return minpt; }
62 SbVec3f & getMin(void) { return minpt; }
63 const SbVec3f & getMax(void) const { return maxpt; }
64 SbVec3f & getMax(void) { return maxpt; }
65
66 void extendBy(const SbVec3f & pt);
67 void extendBy(const SbBox3f & box);
68 void transform(const SbMatrix & 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 float getVolume(void) const
74 { float dx = 0.0f, dy = 0.0f, dz = 0.0f; getSize(dx, dy, dz); return (dx * dy * dz); }
75
76 SbBool intersect(const SbVec3f & pt) const;
77 SbBool intersect(const SbBox3f & box) const;
78 SbVec3f getClosestPoint(const SbVec3f & point) const;
79 SbBool outside(const SbMatrix & mvp, int & cullbits) const;
80
81 SbVec3f getCenter(void) const { return (minpt + maxpt) * 0.5f; }
82 void getOrigin(float & originX, float & originY, float & originZ) const
83 { minpt.getValue(originX, originY, originZ); }
84 void getSize(float & sizeX, float & sizeY, float & sizeZ) const
85 { if (isEmpty()) { sizeX = sizeY = sizeZ = 0; }
86 else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; sizeZ = maxpt[2] - minpt[2]; } }
87
88 SbVec3f getSize(void) const {
89 SbVec3f v;
90 this->getSize(v[0], v[1], v[2]);
91 return v;
92 }
93 void getSpan(const SbVec3f & dir, float & dmin, float & dmax) const;
94
95 void print(FILE * file) const;
96
97 private:
98 SbVec3f minpt, maxpt;
99
100 }; // SbBox3f
101
102 COIN_DLL_API inline int operator == (const SbBox3f & b1, const SbBox3f & b2) {
103 return ((b1.getMin() == b2.getMin()) && (b1.getMax() == b2.getMax()));
104 }
105
106 COIN_DLL_API inline int operator != (const SbBox3f & b1, const SbBox3f & b2) {
107 return !(b1 == b2);
108 }
109
110 #endif // !COIN_SBBOX3F_H
SbBox3f::setBounds
SbBox3f & setBounds(const SbVec3f &minpoint, const SbVec3f &maxpoint)
Definition: SbBox3f.h:50
SbBox3f::getMax
const SbVec3f & getMax(void) const
Definition: SbBox3f.h:63
SbBox3s
The SbBox3s class is a 3 dimensional box with short integer coordinates.This box class is used by oth...
Definition: SbBox3s.h:34
SbBox3f::getMin
SbVec3f & getMin(void)
Definition: SbBox3f.h:62
SbBox3f::getMin
const SbVec3f & getMin(void) const
Definition: SbBox3f.h:61
SbBox3f::getSize
SbVec3f getSize(void) const
Definition: SbBox3f.h:88
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
SbBox3f::getCenter
SbVec3f getCenter(void) const
Definition: SbBox3f.h:81
SbBox2d::operator==
int operator==(const SbBox2d &b1, const SbBox2d &b2)
Definition: SbBox2d.h:88
SbBox3f::SbBox3f
SbBox3f(void)
Definition: SbBox3f.h:39
SbBox3f::SbBox3f
SbBox3f(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
Definition: SbBox3f.h:40
SbBox3f::getVolume
float getVolume(void) const
Definition: SbBox3f.h:73
SbBox3f::setBounds
SbBox3f & setBounds(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
Definition: SbBox3f.h:48
SbBox3f::getBounds
void getBounds(float &xmin, float &ymin, float &zmin, float &xmax, float &ymax, float &zmax) const
Definition: SbBox3f.h:56
SbVec3f
The SbVec3f class is a 3 dimensional vector with floating point coordinates.This vector class is used...
Definition: SbVec3f.h:40
SbBox3f::SbBox3f
SbBox3f(const SbVec3f &minpoint, const SbVec3f &maxpoint)
Definition: SbBox3f.h:42
SbMatrix
The SbMatrix class is a 4x4 dimensional representation of a matrix.SbMatrix is used by many other cla...
Definition: SbMatrix.h:37
SbBox3f::getMax
SbVec3f & getMax(void)
Definition: SbBox3f.h:64
SbBox3f::getOrigin
void getOrigin(float &originX, float &originY, float &originZ) const
Definition: SbBox3f.h:82
SbBox3d
The SbBox3d class is an abstraction for an axis aligned 3 dimensional box.This box abstraction class ...
Definition: SbBox3d.h:37
SbBox3f::isEmpty
SbBool isEmpty(void) const
Definition: SbBox3f.h:70
SbBox3f::getBounds
void getBounds(SbVec3f &minpoint, SbVec3f &maxpoint) const
Definition: SbBox3f.h:58
SbBox3f::hasVolume
SbBool hasVolume(void) const
Definition: SbBox3f.h:71
SbBox3f::getSize
void getSize(float &sizeX, float &sizeY, float &sizeZ) const
Definition: SbBox3f.h:84

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