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>
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
);
55 TriangulateAll(const TopographyStore
&store
)
57 for (unsigned i
= 0; i
< store
.size(); ++i
)
58 TriangulateAll(store
[i
]);
63 int main(int argc
, char **argv
)
65 Args
args(argc
, argv
, "PATH");
66 const char *path
= args
.ExpectNext();
69 ZZIP_DIR
*dir
= zzip_dir_open(path
, NULL
);
71 fprintf(stderr
, "Failed to open %s\n", (const char *)path
);
75 ZipLineReaderA
reader(dir
, "topology.tpl");
77 fprintf(stderr
, "Failed to open %s\n", (const char *)path
);
81 TopographyStore topography
;
82 NullOperationEnvironment operation
;
83 topography
.Load(operation
, reader
, NULL
, dir
);
89 TriangulateAll(topography
);