diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -49,10 +49,11 @@ int main(int argc, char** argv) } else if (argv[1][1] == 'm') { printf("[OK] Generate mesh\n"); multiresolution_meshing(argc, argv); - } else { - fprintf(stderr, "[ERR] Flag not understood: %s\n", argv[1]); } + } else { + fprintf(stderr, "[ERR] Flag not understood: %s\n", argv[1]); + fprintf(stderr, "[ERR] Usage: ./mammoth -[a|m] <input/file>\n"); } return 0; @@ -81,6 +82,7 @@ int multiresolution_meshing(int argc, char** argv) int n_bounds; int *levels; double *boundary_coords; + double *elevations; if (argc < 2) { fprintf(stderr, "[ERR] No input file provided.\n"); @@ -123,6 +125,16 @@ int multiresolution_meshing(int argc, char** argv) /* * ---------------------------------------------------------------------- + * read in dem data + * ---------------------------------------------------------------------- + */ + + elevations = calloc(nrow * ncol, sizeof(double)); + get_data(datafilename, nrow, ncol, ncol, elevations); + printf("[OK] DEM data read\n"); + + /* + * ---------------------------------------------------------------------- * read in boundary * ---------------------------------------------------------------------- */ @@ -305,7 +317,7 @@ int multiresolution_meshing(int argc, char** argv) printf(" done\n"); - write_avs(&out[0], 1); + write_avs(&out[0], 1, elevations, ncol, nrow, xllcorner, yllcorner, cellsize, nodata); for (int current_level = 1; current_level < nlevels; ++ current_level) { @@ -389,7 +401,7 @@ int multiresolution_meshing(int argc, char** argv) printf(" done\n"); - write_avs(&out[current_level], current_level+1); + write_avs(&out[current_level], current_level+1, elevations, ncol, nrow, xllcorner, yllcorner, cellsize, nodata); } @@ -409,6 +421,7 @@ int multiresolution_meshing(int argc, char** argv) free(out[0].neighborlist); free(levels); + free(elevations); free(boundary_coords); return 0; @@ -949,8 +962,10 @@ int get_data(char *datafilename, int nrow, int ncol, int ncol_padded, double *da if (strcmp(key, "nodata_value") == 0) { fscanf(dp, "%lf", &nodata); +#if VERBOSE printf("[OK] Starting to read data\n"); - +#endif + for (int i = 0; i < nrow; i ++) { for (int j = 0; j < ncol; j ++) { fscanf(dp, "%lf", &data[j + ncol_padded * i]); |