Coin Logo http://www.sim.no/
http://www.coin3d.org/

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

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

Generated on Wed Feb 7 2018 for Coin by Doxygen 1.8.14.