Tue, 07 May 2013 19:48:51 +0300
Added Intersector interface. I'm beginning to think that groups were a bad idea...
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
18 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
19 | #ifndef BBOX_H |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
20 | #define BBOX_H |
0 | 21 | |
22 | #include "common.h" | |
121
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
23 | #include "types.h" |
0 | 24 | |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
25 | // ============================================================================= |
121
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
26 | // bbox |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
27 | // |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
28 | // The bounding box is the box that encompasses a given set of objects. The |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
29 | // global instance g_BBox is the bbox for the model we have open. |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
30 | // v0 is the minimum vertex, v1 is the maximum vertex. |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
31 | // ============================================================================= |
0 | 32 | class bbox { |
33 | public: | |
34 | bbox (); | |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
35 | void reset (); |
0 | 36 | void calculate (); |
121
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
37 | double size () const; |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
38 | void calcObject (LDObject* obj); |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
39 | void calcVertex (vertex v); |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
40 | vertex center () const; |
164 | 41 | bool empty () const; |
0 | 42 | |
121
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
43 | bbox& operator<< (LDObject* obj) { |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
44 | calcObject (obj); |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
45 | return *this; |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
46 | } |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
47 | |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
48 | bbox& operator<< (vertex& v) { |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
49 | calcVertex (v); |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
50 | return *this; |
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
51 | } |
164 | 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; | |
0 | 59 | }; |
60 | ||
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
61 | #endif // BBOX_H |