android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / LoadTopography.cpp
blob361bf72b1032e14ab088c0019fd591f221d4cba4
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * This program loads the topography from a map file and exits. Useful
26 * for valgrind and profiling.
29 #include "Topography/TopographyStore.hpp"
30 #include "Topography/TopographyFile.hpp"
31 #include "Topography/XShape.hpp"
32 #include "OS/Args.hpp"
33 #include "OS/PathName.hpp"
34 #include "IO/ZipLineReader.hpp"
35 #include "Operation/Operation.hpp"
37 #include <zzip/zzip.h>
39 #include <stdio.h>
40 #include <tchar.h>
42 #ifdef ENABLE_OPENGL
44 static void
45 TriangulateAll(const TopographyFile &file)
47 const unsigned short *count;
48 for (const XShape &shape : file)
49 if (shape.get_type() == MS_SHAPE_POLYGON)
50 for (unsigned i = 0; i < 4; ++i)
51 shape.get_indices(i, 1, count);
54 static void
55 TriangulateAll(const TopographyStore &store)
57 for (unsigned i = 0; i < store.size(); ++i)
58 TriangulateAll(store[i]);
61 #endif
63 int main(int argc, char **argv)
65 Args args(argc, argv, "PATH");
66 const char *path = args.ExpectNext();
67 args.ExpectEnd();
69 ZZIP_DIR *dir = zzip_dir_open(path, NULL);
70 if (dir == NULL) {
71 fprintf(stderr, "Failed to open %s\n", (const char *)path);
72 return EXIT_FAILURE;
75 ZipLineReaderA reader(dir, "topology.tpl");
76 if (reader.error()) {
77 fprintf(stderr, "Failed to open %s\n", (const char *)path);
78 return EXIT_FAILURE;
81 TopographyStore topography;
82 NullOperationEnvironment operation;
83 topography.Load(operation, reader, NULL, dir);
84 zzip_dir_close(dir);
86 topography.LoadAll();
88 #ifdef ENABLE_OPENGL
89 TriangulateAll(topography);
90 #endif
92 return EXIT_SUCCESS;