~ubuntu-branches/debian/sid/coin2/sid

« back to all changes in this revision

Viewing changes to include/Inventor/SbBox3d.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-06-28 02:38:17 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628023817-lgrh0u677j1gcqgf
Tags: 2.5.0-2
* debian/control: Change suggests from libopenal0 to libopenal0a.
  Closes: #488001.  Change ${Source-Version} to ${binary:Version}.
  Update to standards version 3.8.0.

* debian/rules: Do not ignore errors in clean rule.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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) 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 <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
 
 
88
  void getSpan(const SbVec3d & dir, double & dmin, double & dmax) const;
 
89
 
 
90
  void print(FILE * file) const;
 
91
 
 
92
protected:
 
93
  SbVec3d minpt, maxpt;
 
94
 
 
95
}; // SbBox3d
 
96
 
 
97
COIN_DLL_API inline int operator == (const SbBox3d & b1, const SbBox3d & b2) {
 
98
  return ((b1.getMin() == b2.getMin()) && (b1.getMax() == b2.getMax()));
 
99
}
 
100
 
 
101
COIN_DLL_API inline int operator != (const SbBox3d & b1, const SbBox3d & b2) {
 
102
  return !(b1 == b2);
 
103
}
 
104
 
 
105
#endif // !COIN_SBBOX3D_H