| 28 // The bounding box is the box that encompasses a given set of objects. The |
28 // The bounding box is the box that encompasses a given set of objects. The |
| 29 // global instance g_BBox is the bbox for the model we have open. |
29 // global instance g_BBox is the bbox for the model we have open. |
| 30 // v0 is the minimum vertex, v1 is the maximum vertex. |
30 // v0 is the minimum vertex, v1 is the maximum vertex. |
| 31 // ============================================================================= |
31 // ============================================================================= |
| 32 class bbox { |
32 class bbox { |
| |
33 READ_PROPERTY (bool, empty) |
| |
34 READ_PROPERTY (vertex, v0) |
| |
35 READ_PROPERTY (vertex, v1) |
| |
36 |
| 33 public: |
37 public: |
| 34 bbox (); |
38 bbox (); |
| 35 void reset (); |
39 void reset (); |
| 36 void calculate (); |
40 void calculate (); |
| 37 double size () const; |
41 double size () const; |
| 38 void calcObject (LDObject* obj); |
42 void calcObject (LDObject* obj); |
| 39 void calcVertex (vertex v); |
43 void calcVertex (vertex v); |
| 40 vertex center () const; |
44 vertex center () const; |
| 41 bool empty () const; |
|
| 42 |
45 |
| 43 bbox& operator<< (LDObject* obj) { |
46 bbox& operator<< (LDObject* obj) { |
| 44 calcObject (obj); |
47 calcObject (obj); |
| 45 return *this; |
48 return *this; |
| 46 } |
49 } |
| 47 |
50 |
| 48 bbox& operator<< (vertex& v) { |
51 bbox& operator<< (vertex& v) { |
| 49 calcVertex (v); |
52 calcVertex (v); |
| 50 return *this; |
53 return *this; |
| 51 } |
54 } |
| 52 |
|
| 53 const vertex& v0 () { return m_v0; } |
|
| 54 const vertex& v1 () { return m_v1; } |
|
| 55 |
|
| 56 private: |
|
| 57 vertex m_v0, m_v1; |
|
| 58 bool m_empty; |
|
| 59 }; |
55 }; |
| 60 |
56 |
| 61 #endif // BBOX_H |
57 #endif // BBOX_H |