Box.h
1 /**************************************************************************\
2  *
3  * FILE: Box.h
4  *
5  * This source file is part of DIME.
6  * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License, version 2, as
10  * published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License (the accompanying file named COPYING) for more
16  * details.
17  *
18  **************************************************************************
19  *
20  * If you need DIME for a non-GPL project, contact Systems In Motion
21  * to acquire a Professional Edition License:
22  *
23  * Systems In Motion http://www.sim.no/
24  * Prof. Brochs gate 6 sales@sim.no
25  * N-7030 Trondheim Voice: +47 22114160
26  * NORWAY Fax: +47 67172912
27  *
28 \**************************************************************************/
29 
30 #ifndef DIME_BOX_H
31 #define DIME_BOX_H
32 
33 #include <dime/Basic.h>
34 #include <dime/util/Linear.h>
35 
36 class DIME_DLL_API dimeBox
37 {
38 public:
39  dimeVec3f min, max;
40 public:
41  dimeBox();
42  dimeBox(const dxfdouble x0, const dxfdouble y0, const dxfdouble z0,
43  const dxfdouble x1, const dxfdouble y1, const dxfdouble z1);
44 
45  void set(const dxfdouble x0, const dxfdouble y0, const dxfdouble z0,
46  const dxfdouble x1, const dxfdouble y1, const dxfdouble z1);
47 
48  void get(dxfdouble &x0, dxfdouble &y0, dxfdouble &z0,
49  dxfdouble &x1, dxfdouble &y1, dxfdouble &z1) const;
50 
51  bool operator & (const dimeBox &box) const;
52 
53  bool pointInside(const dimeVec3f &pt) const;
54 
55  dimeVec3f center() const;
56 
57  void makeEmpty();
58  void grow(const dimeVec3f &pt);
59  dxfdouble size() const;
60  bool hasExtent() const;
61 }; // class dimeBox
62 
63 inline bool
64 dimeBox::pointInside(const dimeVec3f &pt) const
65 {
66  return ! (pt[0] < this->min[0] || pt[0] >= this->max[0] ||
67  pt[1] < this->min[1] || pt[1] >= this->max[1] ||
68  pt[2] < this->min[2] || pt[2] >= this->max[2]);
69 }
70 
71 inline dimeVec3f
72 dimeBox::center() const
73 {
74  return dimeVec3f((min[0]+max[0])*0.5f,
75  (min[1]+max[1])*0.5f,
76  (min[2]+max[2])*0.5f);
77 }
78 
79 #endif // ! DIME_BOX_H
80 

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.