Fri, 15 Mar 2013 20:11:18 +0200
Initial commit
0 | 1 | #include <QApplication> |
2 | #include "gui.h" | |
3 | #include "io.h" | |
4 | #include "bbox.h" | |
5 | ||
6 | vector<OpenFile*> g_LoadedFiles; | |
7 | OpenFile* g_CurrentFile = NULL; | |
8 | LDForgeWindow* g_qWindow = NULL; | |
9 | bbox g_BBox; | |
10 | ||
11 | int main (int argc, char** argv) { | |
12 | g_CurrentFile = IO_ParseLDFile ("55966.dat"); | |
13 | g_BBox.calculate(); | |
14 | ||
15 | printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n", | |
16 | FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1)); | |
17 | printf ("%u objects\n", g_CurrentFile->objects.size()); | |
18 | ||
19 | QApplication app (argc, argv); | |
20 | LDForgeWindow* win = new LDForgeWindow; | |
21 | g_qWindow = win; | |
22 | g_qWindow->buildObjList (); | |
23 | win->show (); | |
24 | return app.exec (); | |
25 | } | |
26 | ||
27 | vertex vertex::midpoint (vertex& other) { | |
28 | vertex mid; | |
29 | mid.x = (x + other.x); | |
30 | mid.y = (y + other.y); | |
31 | mid.z = (z + other.z); | |
32 | return mid; | |
33 | } | |
34 | ||
35 | static str getCoordinateRep (double fCoord) { | |
36 | str zRep = str::mkfmt ("%.3f", fCoord); | |
37 | ||
38 | // Remove trailing zeroes | |
39 | while (zRep[~zRep - 1] == '0') | |
40 | zRep -= 1; | |
41 | ||
42 | // If there was only zeroes in the decimal place, remove | |
43 | // the decimal point now. | |
44 | if (zRep[~zRep - 1] == '.') | |
45 | zRep -= 1; | |
46 | ||
47 | return zRep; | |
48 | } | |
49 | ||
50 | str vertex::getStringRep () { | |
51 | return str::mkfmt ("(%s, %s, %s)", | |
52 | getCoordinateRep (x).chars(), | |
53 | getCoordinateRep (y).chars(), | |
54 | getCoordinateRep (z).chars()); | |
55 | } |