1
0
Fork 0

Renamed assemtris.[ch] to assemtris.[ch]xx

This commit is contained in:
curt 1998-09-25 19:35:25 +00:00
parent c27d116cce
commit 216be72f34
4 changed files with 172 additions and 167 deletions

View file

@ -26,7 +26,7 @@
bin_PROGRAMS = assemtris bin_PROGRAMS = assemtris
assemtris_SOURCES = assemtris.c assemtris.h assemtris_SOURCES = assemtris.cxx assemtris.hxx
assemtris_LDADD = \ assemtris_LDADD = \
$(top_builddir)/Lib/Bucket/libBucket.a $(top_builddir)/Lib/Bucket/libBucket.a
@ -36,6 +36,9 @@ INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# Revision 1.4 1998/09/25 19:35:25 curt
# Renamed assemtris.[ch] to assemtris.[ch]xx
#
# Revision 1.3 1998/07/30 23:49:23 curt # Revision 1.3 1998/07/30 23:49:23 curt
# Removed libtool support. # Removed libtool support.
# #

View file

@ -1,33 +1,33 @@
/* splittris.c -- reassemble the pieces produced by splittris // assemtris.c -- reassemble the pieces produced by splittris
* //
* Written by Curtis Olson, started January 1998. // Written by Curtis Olson, started January 1998.
* //
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
* //
* This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. // (at your option) any later version.
* //
* This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. // GNU General Public License for more details.
* //
* You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* //
* $Id$ // $Id$
* (Log is kept at end of this file) */ // (Log is kept at end of this file)
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* for atoi() */ #include <stdlib.h> // for atoi()
#include <string.h> #include <string.h>
#include <sys/stat.h> /* for stat() */ #include <sys/stat.h> // for stat()
#include <unistd.h> /* for stat() */ #include <unistd.h> // for stat()
#include "assemtris.h" #include "assemtris.h"
@ -36,10 +36,8 @@
#include <Bucket/bucketutils.h> #include <Bucket/bucketutils.h>
/* // #define OFFSET_LON 0.1
#define OFFSET_LON 0.1 // #define OFFSET_LAT 0.1
#define OFFSET_LAT 0.1
*/
#define OFFSET_LON 0.0 #define OFFSET_LON 0.0
#define OFFSET_LAT 0.0 #define OFFSET_LAT 0.0
@ -56,7 +54,7 @@ fgBUCKET ne_index, nw_index, sw_index, se_index;
fgBUCKET north_index, south_index, east_index, west_index; fgBUCKET north_index, south_index, east_index, west_index;
/* return the file base name ( foo/bar/file.ext = file.ext ) */ // return the file base name ( foo/bar/file.ext = file.ext )
void extract_file(char *in, char *base) { void extract_file(char *in, char *base) {
int len, i; int len, i;
@ -72,7 +70,7 @@ void extract_file(char *in, char *base) {
} }
/* return the file path name ( foo/bar/file.ext = foo/bar ) */ // return the file path name ( foo/bar/file.ext = foo/bar )
void extract_path(char *in, char *base) { void extract_path(char *in, char *base) {
int len, i; int len, i;
@ -88,7 +86,7 @@ void extract_path(char *in, char *base) {
} }
/* check to see if specified node is in the extra list */ // check to see if specified node is in the extra list
int is_extra_node(double *n) { int is_extra_node(double *n) {
int i; int i;
@ -104,10 +102,10 @@ int is_extra_node(double *n) {
return(0); return(0);
} }
/* Read all the extra nodes. These typically define inner areas to // Read all the extra nodes. These typically define inner areas to
exclude from triangulations. There will be a .poly file that // exclude from triangulations. There will be a .poly file that
refers to these by position number which assumes all the extra // refers to these by position number which assumes all the extra
nodes come first in the generated .node file. */ // nodes come first in the generated .node file.
void read_extra_nodes(char *exfile) { void read_extra_nodes(char *exfile) {
FILE *fd; FILE *fd;
int i, junk1, junk2, junk3; int i, junk1, junk2, junk3;
@ -136,7 +134,7 @@ void read_extra_nodes(char *exfile) {
} }
/* check if a file exists */ // check if a file exists
int file_exists(char *file) { int file_exists(char *file) {
struct stat stat_buf; struct stat stat_buf;
int result; int result;
@ -146,18 +144,18 @@ int file_exists(char *file) {
result = stat(file, &stat_buf); result = stat(file, &stat_buf);
if ( result != 0 ) { if ( result != 0 ) {
/* stat failed, no file */ // stat failed, no file
printf("not found.\n"); printf("not found.\n");
return(0); return(0);
} else { } else {
/* stat succeeded, file exists */ // stat succeeded, file exists
printf("exists.\n"); printf("exists.\n");
return(1); return(1);
} }
} }
/* check to see if a shared object exists */ // check to see if a shared object exists
int shared_object_exists(char *basepath, char *ext, char *file) { int shared_object_exists(char *basepath, char *ext, char *file) {
char scene_path[256]; char scene_path[256];
long int index; long int index;
@ -343,32 +341,32 @@ int shared_object_exists(char *basepath, char *ext, char *file) {
} }
/* my custom file opening routine ... don't open if a shared edge or // my custom file opening routine ... don't open if a shared edge or
* vertex alread exists */ // vertex alread exists
FILE *my_open(char *basename, char *basepath, char *ext) { FILE *my_open(char *basename, char *basepath, char *ext) {
FILE *fp; FILE *fp;
char filename[256]; char filename[256];
/* check if a shared object already exists */ // check if a shared object already exists
if ( shared_object_exists(basepath, ext, filename) ) { if ( shared_object_exists(basepath, ext, filename) ) {
/* not an actual file open error, but we've already got the // not an actual file open error, but we've already got the
* shared edge, so we don't want to create another one */ // shared edge, so we don't want to create another one
fp = fopen(filename, "r"); fp = fopen(filename, "r");
printf("Opening %s\n", filename); printf("Opening %s\n", filename);
return(fp); return(fp);
} else { } else {
/* open the file */ // open the file
printf("not opening\n"); printf("not opening\n");
return(NULL); return(NULL);
} }
} }
/* given a file pointer, read all the gdn (geodetic nodes from it.) // given a file pointer, read all the gdn (geodetic nodes from it.)
The specified offset values (in arcsec) are used to overlap the // The specified offset values (in arcsec) are used to overlap the
edges of the tile slightly to cover gaps induced by floating point // edges of the tile slightly to cover gaps induced by floating point
precision problems. 1 arcsec == about 100 feet so 0.01 arcsec == // precision problems. 1 arcsec == about 100 feet so 0.01 arcsec ==
about 1 foot */ // about 1 foot
void read_nodes(FILE *fp, double offset_lon, double offset_lat) { void read_nodes(FILE *fp, double offset_lon, double offset_lat) {
double n[3]; double n[3];
char line[256]; char line[256];
@ -388,11 +386,10 @@ void read_nodes(FILE *fp, double offset_lon, double offset_lat) {
nodes[nodecount][1] = n[1] + offset_lat; nodes[nodecount][1] = n[1] + offset_lat;
nodes[nodecount][2] = n[2]; nodes[nodecount][2] = n[2];
/* // printf("read_nodes(%d) %.2f %.2f %.2f %s", nodecount,
printf("read_nodes(%d) %.2f %.2f %.2f %s", nodecount, // nodes[nodecount][0], nodes[nodecount][1],
nodes[nodecount][0], nodes[nodecount][1], // nodes[nodecount][2], line);
nodes[nodecount][2], line);
*/
nodecount++; nodecount++;
} else { } else {
@ -406,8 +403,8 @@ void read_nodes(FILE *fp, double offset_lon, double offset_lat) {
} }
/* load in nodes from the various split and shared pieces to // load in nodes from the various split and shared pieces to
* reconstruct a tile */ // reconstruct a tile
void build_node_list(char *basename, char *basepath) { void build_node_list(char *basename, char *basepath) {
char exfile[256]; char exfile[256];
FILE *ne, *nw, *se, *sw, *north, *south, *east, *west, *body; FILE *ne, *nw, *se, *sw, *north, *south, *east, *west, *body;
@ -455,19 +452,19 @@ void build_node_list(char *basename, char *basepath) {
} }
/* dump in WaveFront .obj format */ // dump in WaveFront .obj format
void dump_nodes(char *basename) { void dump_nodes(char *basename) {
char file[256]; char file[256];
FILE *fd; FILE *fd;
int i; int i;
/* generate output file name */ // generate output file name
strcpy(file, basename); strcpy(file, basename);
// len = strlen(file); // len = strlen(file);
// file[len-2] = '\0'; // file[len-2] = '\0';
strcat(file, ".node"); strcat(file, ".node");
/* dump vertices */ // dump vertices
printf("Creating node file: %s\n", file); printf("Creating node file: %s\n", file);
printf(" writing vertices in .node format.\n"); printf(" writing vertices in .node format.\n");
fd = fopen(file, "w"); fd = fopen(file, "w");
@ -480,7 +477,7 @@ void dump_nodes(char *basename) {
i, exnodes[i][0], exnodes[i][1], exnodes[i][2]); i, exnodes[i][0], exnodes[i][1], exnodes[i][2]);
} }
/* now write out actual node data */ // now write out actual node data
for ( i = 0; i < nodecount; i++ ) { for ( i = 0; i < nodecount; i++ ) {
fprintf(fd, "%d %.2f %.2f %.2f 0\n", excount + i + 1, fprintf(fd, "%d %.2f %.2f %.2f 0\n", excount + i + 1,
nodes[i][0], nodes[i][1], nodes[i][2]); nodes[i][0], nodes[i][1], nodes[i][2]);
@ -499,13 +496,13 @@ int main(int argc, char **argv) {
strcpy(basename, argv[1]); strcpy(basename, argv[1]);
len = strlen(basename); len = strlen(basename);
/* find the base path of the file */ // find the base path of the file
extract_path(basename, basepath); extract_path(basename, basepath);
extract_path(basepath, basepath); extract_path(basepath, basepath);
extract_path(basepath, basepath); extract_path(basepath, basepath);
printf("%s\n", basepath); printf("%s\n", basepath);
/* find the index of the current file */ // find the index of the current file
extract_file(basename, temp); extract_file(basename, temp);
// len = strlen(temp); // len = strlen(temp);
// if ( len >= 2 ) { // if ( len >= 2 ) {
@ -517,7 +514,7 @@ int main(int argc, char **argv) {
printf("bucket = %d %d %d %d\n", printf("bucket = %d %d %d %d\n",
my_index.lon, my_index.lat, my_index.x, my_index.y); my_index.lon, my_index.lat, my_index.x, my_index.y);
/* generate the indexes of the neighbors */ // generate the indexes of the neighbors
fgBucketOffset(&my_index, &ne_index, 1, 1); fgBucketOffset(&my_index, &ne_index, 1, 1);
fgBucketOffset(&my_index, &nw_index, -1, 1); fgBucketOffset(&my_index, &nw_index, -1, 1);
fgBucketOffset(&my_index, &se_index, 1, -1); fgBucketOffset(&my_index, &se_index, 1, -1);
@ -528,68 +525,70 @@ int main(int argc, char **argv) {
fgBucketOffset(&my_index, &east_index, 1, 0); fgBucketOffset(&my_index, &east_index, 1, 0);
fgBucketOffset(&my_index, &west_index, -1, 0); fgBucketOffset(&my_index, &west_index, -1, 0);
/* // printf("Corner indexes = %ld %ld %ld %ld\n",
printf("Corner indexes = %ld %ld %ld %ld\n", // ne_index, nw_index, sw_index, se_index);
ne_index, nw_index, sw_index, se_index); // printf("Edge indexes = %ld %ld %ld %ld\n",
printf("Edge indexes = %ld %ld %ld %ld\n", // north_index, south_index, east_index, west_index);
north_index, south_index, east_index, west_index);
*/
/* load the input data files */ // load the input data files
build_node_list(basename, basepath); build_node_list(basename, basepath);
/* dump in WaveFront .obj format */ // dump in WaveFront .obj format
dump_nodes(basename); dump_nodes(basename);
return(0); return(0);
} }
/* $Log$ // $Log$
/* Revision 1.13 1998/09/21 20:56:30 curt // Revision 1.1 1998/09/25 19:35:29 curt
/* Changes to avoid setting airport area nodes back to their original // Renamed assemtris.[ch] to assemtris.[ch]xx
/* elevations if they have been changed. //
/* // Revision 1.13 1998/09/21 20:56:30 curt
* // Changes to avoid setting airport area nodes back to their original
* Revision 1.12 1998/09/09 16:24:51 curt // elevations if they have been changed.
* Fixed a bug in the handling of exclude files which was causing //
* a crash by calling fclose() on an invalid file handle. //
* Removed overlapping offsets. // Revision 1.12 1998/09/09 16:24:51 curt
* // Fixed a bug in the handling of exclude files which was causing
* Revision 1.11 1998/08/06 12:47:59 curt // a crash by calling fclose() on an invalid file handle.
* Removed overlap in tiles as a test. // Removed overlapping offsets.
* //
* Revision 1.10 1998/07/21 04:34:20 curt // Revision 1.11 1998/08/06 12:47:59 curt
* Mods to handle extra nodes (i.e. preserve cutouts). // Removed overlap in tiles as a test.
* //
* Revision 1.9 1998/07/04 00:55:39 curt // Revision 1.10 1998/07/21 04:34:20 curt
* typedef'd struct fgBUCKET. // Mods to handle extra nodes (i.e. preserve cutouts).
* //
* Revision 1.8 1998/06/01 17:58:19 curt // Revision 1.9 1998/07/04 00:55:39 curt
* Added a slight border overlap to try to minimize pixel wide gaps between // typedef'd struct fgBUCKET.
* tiles due to round off error. This is not a perfect solution, but helps. //
* // Revision 1.8 1998/06/01 17:58:19 curt
* Revision 1.7 1998/04/14 02:26:00 curt // Added a slight border overlap to try to minimize pixel wide gaps between
* Code reorganizations. Added a Lib/ directory for more general libraries. // tiles due to round off error. This is not a perfect solution, but helps.
* //
* Revision 1.6 1998/04/08 22:54:58 curt // Revision 1.7 1998/04/14 02:26:00 curt
* Adopted Gnu automake/autoconf system. // Code reorganizations. Added a Lib/ directory for more general libraries.
* //
* Revision 1.5 1998/03/03 16:00:52 curt // Revision 1.6 1998/04/08 22:54:58 curt
* More c++ compile tweaks. // Adopted Gnu automake/autoconf system.
* //
* Revision 1.4 1998/01/31 00:41:23 curt // Revision 1.5 1998/03/03 16:00:52 curt
* Made a few changes converting floats to doubles. // More c++ compile tweaks.
* //
* Revision 1.3 1998/01/27 18:37:00 curt // Revision 1.4 1998/01/31 00:41:23 curt
* Lots of updates to get back in sync with changes made over in .../Src/ // Made a few changes converting floats to doubles.
* //
* Revision 1.2 1998/01/15 21:33:36 curt // Revision 1.3 1998/01/27 18:37:00 curt
* Assembling triangles and building a new .node file with the proper shared // Lots of updates to get back in sync with changes made over in .../Src/
* vertices now works. Now we just have to use the shared normals and we'll //
* be all set. // Revision 1.2 1998/01/15 21:33:36 curt
* // Assembling triangles and building a new .node file with the proper shared
* Revision 1.1 1998/01/15 02:45:26 curt // vertices now works. Now we just have to use the shared normals and we'll
* Initial revision. // be all set.
* //
*/ // Revision 1.1 1998/01/15 02:45:26 curt
// Initial revision.
//

View file

@ -1,45 +0,0 @@
/* splittris.h -- reassemble the pieces produced by splittris
*
* Written by Curtis Olson, started January 1998.
*
* 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 ASSEMTRIS_H
#define ASSEMTRIS_H
#include <stdio.h>
#include <string.h>
#define MAX_NODES 200000
#define MAX_TRIS 400000
#endif /* SPLITTRIS_H */
/* $Log$
/* Revision 1.1 1998/01/15 02:45:26 curt
/* Initial revision.
/*
*/

48
AssemTris/assemtris.hxx Normal file
View file

@ -0,0 +1,48 @@
// splittris.h -- reassemble the pieces produced by splittris
//
// Written by Curtis Olson, started January 1998.
//
// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
//
// 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 ASSEMTRIS_H
#define ASSEMTRIS_H
#include <stdio.h>
#include <string.h>
#define MAX_NODES 200000
#define MAX_TRIS 400000
#endif // SPLITTRIS_H
// $Log$
// Revision 1.1 1998/09/25 19:35:31 curt
// Renamed assemtris.[ch] to assemtris.[ch]xx
//
// Revision 1.1 1998/01/15 02:45:26 curt
// Initial revision.
//