]> git.mxchange.org Git - flightgear.git/blob - FixNode/main.c
More c++ compile tweaks.
[flightgear.git] / FixNode / main.c
1 /* triload.c -- read in a .node file and fix the z values of the interpolated 
2  *              points
3  *
4  * Written by Curtis Olson, started November 1997.
5  *
6  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
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.
17  *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  */
25
26
27 #include <dirent.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <sys/types.h>
31
32 #include "../Dem2node/demparse.h"
33 #include "fixnode.h"
34 #include "triload.h"
35
36
37 /* Original DEM which is used to interpolate z values */
38 static struct MESH dem_mesh;
39
40 /* Node list */
41 static double nodes[MAX_NODES][3];
42
43 /* find all the matching files in the specified directory and fix them */
44 void process_files(char *root_path) {
45     DIR *d;
46     struct dirent *de;
47     char file_path[256];
48     char *ptr;
49     int len;
50
51     if ( (d = opendir(root_path)) == NULL ) {
52         printf("cannot open directory '%s'.", root_path);
53         exit(-1);
54     }
55
56     while ( (de = readdir(d)) != NULL ) {
57         len = strlen(de->d_name);
58         if ( len > 7 ) {
59             ptr = de->d_name;
60             ptr += (len - 7);
61             /* printf("--> %s \n", ptr); */
62
63             if ( strcmp(ptr, ".1.node") == 0 ) {
64                 strcpy(file_path, root_path);
65                 strcat(file_path, "/");
66                 strcat(file_path, de->d_name);
67                 printf("File = %s\n", file_path);
68
69                 /* load the input data files */
70                 triload(file_path, nodes);
71
72                 fixnodes(file_path, &dem_mesh, nodes);
73             }
74         }
75     }
76 }
77
78
79 /* main */
80 int main(int argc, char **argv) {
81     char demfile[256], root_path[256];
82
83     if ( argc != 3 ) {
84         printf("Usage %s demfile root_path\n", argv[0]);
85         exit(-1);
86     }
87
88     strcpy(demfile, argv[1]);
89     strcpy(root_path, argv[2]);
90
91     /* load the corresponding dem file so we can interpolate elev values */
92     dem_parse(demfile, &dem_mesh);
93
94     /* process all the *.1.node files in the specified directory */
95     process_files(root_path);
96
97     return(0);
98 }
99
100
101 /* $Log$
102 /* Revision 1.4  1998/03/03 16:00:58  curt
103 /* More c++ compile tweaks.
104 /*
105  * Revision 1.3  1998/01/09 23:03:08  curt
106  * Restructured to split 1deg x 1deg dem's into 64 subsections.
107  *
108  * Revision 1.2  1997/12/02 13:12:07  curt
109  * Updated to fix every node.
110  *
111  * Revision 1.1  1997/11/27 00:17:34  curt
112  * Initial revision.
113  *
114  */