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

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

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