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) 1998-2007 by Systems in Motion. All rights reserved.
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 Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, 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
30class SbBox3i32;
31class SbBox3f;
32class SbBox3d;
33
34class COIN_DLL_API SbBox3s {
35public:
36 SbBox3s(void);
37 SbBox3s(short xmin, short ymin, short zmin, short xmax, short ymax, short zmax);
38 SbBox3s(const SbVec3s & minvec, const SbVec3s & maxvec);
39 explicit SbBox3s(const SbBox3i32 & box) { setBounds(box); }
40 explicit SbBox3s(const SbBox3f & box) { setBounds(box); }
41 explicit SbBox3s(const SbBox3d & box) { setBounds(box); }
42 ~SbBox3s(void);
43
44 void setBounds(short xmin, short ymin, short zmin, short xmax, short ymax, short zmax);
45 void setBounds(const SbVec3s & minvec, const SbVec3s & maxvec);
46 SbBox3s & setBounds(const SbBox3i32 & box);
47 SbBox3s & setBounds(const SbBox3f & box);
48 SbBox3s & setBounds(const SbBox3d & box);
49
50 const SbVec3s & getMin(void) const;
51 SbVec3s & getMin(void) { return minpt; }
52 const SbVec3s & getMax(void) const;
53 SbVec3s & getMax(void) { return maxpt; }
54
55 void extendBy(const SbVec3s & point);
56 void extendBy(const SbBox3s & box);
57 void makeEmpty(void);
58 SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
59 SbBool hasVolume(void) const
60 { return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1]) && (maxpt[2] > minpt[2])); }
61 int getVolume(void) const
62 { short dx = 0, dy = 0, dz = 0; getSize(dx, dy, dz); return (dx * dy * dz); }
63
64 SbBool intersect(const SbVec3s & point) const;
65 SbBool intersect(const SbBox3s & box) const;
66 void getBounds(short & xmin, short & ymin,
67 short & zmin, short & xmax,
68 short & ymax, short & zmax) const;
69 void getBounds(SbVec3s & minvec, SbVec3s & maxvec) const;
70
71 SbVec3f getCenter(void) const
72 { return SbVec3f((minpt[0]+maxpt[0])*0.5f, (minpt[1]+maxpt[1])*0.5f, (minpt[2]+maxpt[2])*0.5f); }
73 void getOrigin(short & originX, short & originY, short & originZ) const;
74 void getSize(short & sizeX, short & sizeY, short & sizeZ) const;
75
76 friend COIN_DLL_API int operator ==(const SbBox3s & b1, const SbBox3s & b2);
77 friend COIN_DLL_API int operator !=(const SbBox3s & b1, const SbBox3s & b2);
78
79private:
80 SbVec3s minpt, maxpt;
81
82 short width(void) const;
83 short height(void) const;
84 short depth(void) const;
85 SbBool hasArea(void) const;
86};
87
88COIN_DLL_API int operator ==(const SbBox3s & b1, const SbBox3s & b2);
89COIN_DLL_API int operator !=(const SbBox3s & b1, const SbBox3s & b2);
90
91#endif // !COIN_SBBOX3S_H
The SbBox3d class is an abstraction for an axis aligned 3 dimensional box.
Definition SbBox3d.h:37
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition SbBox3f.h:37
Definition SbBox3i32.h:35
The SbBox3s class is a 3 dimensional box with short integer coordinates.
Definition SbBox3s.h:34
SbBox3s(const SbBox3d &box)
Definition SbBox3s.h:41
SbBool isEmpty(void) const
Definition SbBox3s.h:58
SbBox3s(const SbBox3f &box)
Definition SbBox3s.h:40
SbBox3s(const SbBox3i32 &box)
Definition SbBox3s.h:39
SbBool hasVolume(void) const
Definition SbBox3s.h:59
int getVolume(void) const
Definition SbBox3s.h:61
SbVec3s & getMin(void)
Definition SbBox3s.h:51
SbVec3f getCenter(void) const
Definition SbBox3s.h:71
SbVec3s & getMax(void)
Definition SbBox3s.h:53
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:37
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition SbVec3s.h:36

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 19 2023 for Coin by Doxygen. 1.9.7