Updated to support -lDEM class.
This commit is contained in:
parent
c98579b6de
commit
31c774d723
5 changed files with 125 additions and 102 deletions
|
@ -27,7 +27,7 @@
|
|||
TARGET = fixnode
|
||||
|
||||
CFILES = fixnode.c main.c triload.c
|
||||
LDLIBS = ../Dem2node/demparse.o ../Dem2node/mesh.o -lm
|
||||
LDLIBS = -lDEM -lScenery -lm
|
||||
|
||||
|
||||
include $(FG_ROOT_SRC)/commondefs
|
||||
|
@ -46,6 +46,9 @@ include $(COMMONRULES)
|
|||
|
||||
#---------------------------------------------------------------------------
|
||||
# $Log$
|
||||
# Revision 1.3 1998/03/19 02:50:19 curt
|
||||
# Updated to support -lDEM class.
|
||||
#
|
||||
# Revision 1.2 1998/01/21 02:55:50 curt
|
||||
# Incorporated new make system from Bob Kuehne <rpk@sgi.com>.
|
||||
#
|
||||
|
|
|
@ -29,12 +29,14 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "fixnode.h"
|
||||
#include "../Dem2node/mesh.h"
|
||||
#include "triload.h"
|
||||
|
||||
|
||||
/* load the node information */
|
||||
void fixnodes(char *filename, struct MESH *m, double nodes[MAX_NODES][3]) {
|
||||
void fixnodes( char *filename, fgDEM dem,
|
||||
float dem_data[DEM_SIZE_1][DEM_SIZE_1],
|
||||
double nodes[MAX_NODES][3] )
|
||||
{
|
||||
char toname[256];
|
||||
FILE *fd;
|
||||
int i;
|
||||
|
@ -50,7 +52,8 @@ void fixnodes(char *filename, struct MESH *m, double nodes[MAX_NODES][3]) {
|
|||
/* printf("Current: %d %.2f %.2f %.2f\n", i, nodes[i][0],
|
||||
nodes[i][1], nodes[i][2]); */
|
||||
|
||||
nodes[i][2] = mesh_altitude(m, nodes[i][0], nodes[i][1]);
|
||||
nodes[i][2] =
|
||||
dem.interpolate_altitude(dem_data, nodes[i][0], nodes[i][1]);
|
||||
|
||||
/* printf("Fixed: %d %.2f %.2f %.2f\n", i, nodes[i][0],
|
||||
nodes[i][1], nodes[i][2]); */
|
||||
|
@ -77,9 +80,12 @@ void fixnodes(char *filename, struct MESH *m, double nodes[MAX_NODES][3]) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.4 1998/03/03 16:00:57 curt
|
||||
/* More c++ compile tweaks.
|
||||
/* Revision 1.5 1998/03/19 02:50:19 curt
|
||||
/* Updated to support -lDEM class.
|
||||
/*
|
||||
* Revision 1.4 1998/03/03 16:00:57 curt
|
||||
* More c++ compile tweaks.
|
||||
*
|
||||
* Revision 1.3 1998/01/09 23:03:08 curt
|
||||
* Restructured to split 1deg x 1deg dem's into 64 subsections.
|
||||
*
|
||||
|
|
|
@ -1,55 +1,59 @@
|
|||
/* fixnode.h -- traverse the node file and fix the elevation of all the new
|
||||
* interpolated points.
|
||||
*
|
||||
* Written by Curtis Olson, started November 1997.
|
||||
*
|
||||
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
*/
|
||||
// fixnode.h -- traverse the node file and fix the elevation of all the new
|
||||
// interpolated points.
|
||||
//
|
||||
// Written by Curtis Olson, started November 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
//
|
||||
|
||||
|
||||
#ifndef FIXNODE_H
|
||||
#define FIXNODE_H
|
||||
#ifndef _FIXNODE_H
|
||||
#define _FIXNODE_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "triload.h"
|
||||
#include "../Dem2node/mesh.h"
|
||||
#include "../DEM/dem.h"
|
||||
|
||||
|
||||
/* load the node information */
|
||||
void fixnodes(char *basename, struct MESH *m, double nodes[MAX_NODES][3]);
|
||||
// load the node information
|
||||
void fixnodes( char *basename, fgDEM dem,
|
||||
float dem_data[DEM_SIZE_1][DEM_SIZE_1],
|
||||
double nodes[MAX_NODES][3] );
|
||||
|
||||
|
||||
#endif /* FIXNODE_H */
|
||||
#endif // _FIXNODE_H
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.3 1998/03/03 16:00:58 curt
|
||||
/* More c++ compile tweaks.
|
||||
/*
|
||||
* Revision 1.2 1997/12/02 13:12:07 curt
|
||||
* Updated to fix every node.
|
||||
*
|
||||
* Revision 1.1 1997/11/27 00:17:33 curt
|
||||
* Initial revision.
|
||||
*
|
||||
*/
|
||||
// $Log$
|
||||
// Revision 1.4 1998/03/19 02:50:19 curt
|
||||
// Updated to support -lDEM class.
|
||||
//
|
||||
// Revision 1.3 1998/03/03 16:00:58 curt
|
||||
// More c++ compile tweaks.
|
||||
//
|
||||
// Revision 1.2 1997/12/02 13:12:07 curt
|
||||
// Updated to fix every node.
|
||||
//
|
||||
// Revision 1.1 1997/11/27 00:17:33 curt
|
||||
// Initial revision.
|
||||
//
|
||||
|
|
107
FixNode/main.c
107
FixNode/main.c
|
@ -1,27 +1,27 @@
|
|||
/* triload.c -- read in a .node file and fix the z values of the interpolated
|
||||
* points
|
||||
*
|
||||
* Written by Curtis Olson, started November 1997.
|
||||
*
|
||||
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
* (Log is kept at end of this file)
|
||||
*/
|
||||
// triload.c -- read in a .node file and fix the z values of the interpolated
|
||||
// points
|
||||
//
|
||||
// Written by Curtis Olson, started November 1997.
|
||||
//
|
||||
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
//
|
||||
|
||||
|
||||
#include <dirent.h>
|
||||
|
@ -29,18 +29,20 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "../Dem2node/demparse.h"
|
||||
#include "../DEM/dem.h"
|
||||
#include "fixnode.h"
|
||||
#include "triload.h"
|
||||
|
||||
|
||||
/* Original DEM which is used to interpolate z values */
|
||||
static struct MESH dem_mesh;
|
||||
// Storage for the original DEM data which is used to interpolate z values
|
||||
static fgDEM dem;
|
||||
static float dem_data[DEM_SIZE_1][DEM_SIZE_1];
|
||||
|
||||
/* Node list */
|
||||
// Node list
|
||||
static double nodes[MAX_NODES][3];
|
||||
|
||||
/* find all the matching files in the specified directory and fix them */
|
||||
|
||||
// find all the matching files in the specified directory and fix them
|
||||
void process_files(char *root_path) {
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
|
@ -58,7 +60,7 @@ void process_files(char *root_path) {
|
|||
if ( len > 7 ) {
|
||||
ptr = de->d_name;
|
||||
ptr += (len - 7);
|
||||
/* printf("--> %s \n", ptr); */
|
||||
// printf("--> %s \n", ptr);
|
||||
|
||||
if ( strcmp(ptr, ".1.node") == 0 ) {
|
||||
strcpy(file_path, root_path);
|
||||
|
@ -66,17 +68,17 @@ void process_files(char *root_path) {
|
|||
strcat(file_path, de->d_name);
|
||||
printf("File = %s\n", file_path);
|
||||
|
||||
/* load the input data files */
|
||||
// load the input data files
|
||||
triload(file_path, nodes);
|
||||
|
||||
fixnodes(file_path, &dem_mesh, nodes);
|
||||
fixnodes(file_path, dem, dem_data, nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* main */
|
||||
// main
|
||||
int main(int argc, char **argv) {
|
||||
char demfile[256], root_path[256];
|
||||
|
||||
|
@ -88,27 +90,32 @@ int main(int argc, char **argv) {
|
|||
strcpy(demfile, argv[1]);
|
||||
strcpy(root_path, argv[2]);
|
||||
|
||||
/* load the corresponding dem file so we can interpolate elev values */
|
||||
dem_parse(demfile, &dem_mesh);
|
||||
// load the corresponding dem file so we can interpolate elev values
|
||||
dem.open(demfile);
|
||||
dem.parse(dem_data);
|
||||
dem.close();
|
||||
|
||||
/* process all the *.1.node files in the specified directory */
|
||||
// process all the *.1.node files in the specified directory
|
||||
process_files(root_path);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.4 1998/03/03 16:00:58 curt
|
||||
/* More c++ compile tweaks.
|
||||
/*
|
||||
* Revision 1.3 1998/01/09 23:03:08 curt
|
||||
* Restructured to split 1deg x 1deg dem's into 64 subsections.
|
||||
*
|
||||
* Revision 1.2 1997/12/02 13:12:07 curt
|
||||
* Updated to fix every node.
|
||||
*
|
||||
* Revision 1.1 1997/11/27 00:17:34 curt
|
||||
* Initial revision.
|
||||
*
|
||||
*/
|
||||
// $Log$
|
||||
// Revision 1.5 1998/03/19 02:50:20 curt
|
||||
// Updated to support -lDEM class.
|
||||
//
|
||||
// Revision 1.4 1998/03/03 16:00:58 curt
|
||||
// More c++ compile tweaks.
|
||||
//
|
||||
// Revision 1.3 1998/01/09 23:03:08 curt
|
||||
// Restructured to split 1deg x 1deg dem's into 64 subsections.
|
||||
//
|
||||
// Revision 1.2 1997/12/02 13:12:07 curt
|
||||
// Updated to fix every node.
|
||||
//
|
||||
// Revision 1.1 1997/11/27 00:17:34 curt
|
||||
// Initial revision.
|
||||
//
|
||||
//
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef TRILOAD_H
|
||||
#define TRILOAD_H
|
||||
#ifndef _TRILOAD_H
|
||||
#define _TRILOAD_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -43,13 +43,16 @@ extern int nodecount, tricount;
|
|||
void triload(char *basename, double nodes[MAX_NODES][3]);
|
||||
|
||||
|
||||
#endif /* TRILOAD_H */
|
||||
#endif // _TRILOAD_H
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.3 1998/03/03 16:00:59 curt
|
||||
/* More c++ compile tweaks.
|
||||
/* Revision 1.4 1998/03/19 02:50:20 curt
|
||||
/* Updated to support -lDEM class.
|
||||
/*
|
||||
* Revision 1.3 1998/03/03 16:00:59 curt
|
||||
* More c++ compile tweaks.
|
||||
*
|
||||
* Revision 1.2 1998/01/09 23:03:09 curt
|
||||
* Restructured to split 1deg x 1deg dem's into 64 subsections.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue