#include "splittris.h"
-#include "../../Src/Include/constants.h"
-#include "../../Src/Include/types.h"
-#include "../../Src/Math/fg_geodesy.h"
-#include "../../Src/Math/mat3.h"
-#include "../../Src/Math/polar.h"
-#include "../../Src/Scenery/tileutils.h"
+#include <Include/fg_constants.h>
+#include <Include/fg_types.h>
+#include <Bucket/bucketutils.h>
+#include "fg_geodesy.h"
+#include "mat3.h"
+#include "polar.h"
int nodecount, tricount;
double xmin, xmax, ymin, ymax;
-double nodes_orig[MAX_NODES][3];
-int tris[MAX_TRIS][3];
-int new_tris[MAX_TRIS][3];
+static double nodes_orig[MAX_NODES][3];
+static int tris[MAX_TRIS][3];
+/* static int new_tris[MAX_TRIS][3]; */
-struct fgCartesianPoint nodes_cart[MAX_NODES];
+static struct fgCartesianPoint nodes_cart[MAX_NODES];
-struct bucket ne_index, nw_index, sw_index, se_index;
-struct bucket north_index, south_index, east_index, west_index;
+struct fgBUCKET ne_index, nw_index, sw_index, se_index;
+struct fgBUCKET north_index, south_index, east_index, west_index;
/* convert a geodetic point lon(arcsec), lat(arcsec), elev(meter) to
* a cartesian point */
struct fgCartesianPoint p3, double normal[3])
{
double v1[3], v2[3];
- float temp;
+ double temp;
v1[0] = p2.x - p1.x; v1[1] = p2.y - p1.y; v1[2] = p2.z - p1.z;
v2[0] = p3.x - p1.x; v2[1] = p3.y - p1.y; v2[2] = p3.z - p1.z;
long int index;
if ( strcmp(ext, ".sw") == 0 ) {
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&sw_index, scene_path);
- index = gen_index(&sw_index);
+ fgBucketGenBasePath(&sw_index, scene_path);
+ index = fgBucketGenIndex(&sw_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".se") == 0 ) {
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&se_index, scene_path);
- index = gen_index(&se_index);
+ fgBucketGenBasePath(&se_index, scene_path);
+ index = fgBucketGenIndex(&se_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".ne") == 0 ) {
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.nw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&ne_index, scene_path);
- index = gen_index(&ne_index);
+ fgBucketGenBasePath(&ne_index, scene_path);
+ index = fgBucketGenIndex(&ne_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".nw") == 0 ) {
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.ne", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&nw_index, scene_path);
- index = gen_index(&nw_index);
+ fgBucketGenBasePath(&nw_index, scene_path);
+ index = fgBucketGenIndex(&nw_index);
sprintf(file, "%s/%s/%ld.1.se", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.sw", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".south") == 0 ) {
- gen_base_path(&south_index, scene_path);
- index = gen_index(&south_index);
+ fgBucketGenBasePath(&south_index, scene_path);
+ index = fgBucketGenIndex(&south_index);
sprintf(file, "%s/%s/%ld.1.north", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".north") == 0 ) {
- gen_base_path(&north_index, scene_path);
- index = gen_index(&north_index);
+ fgBucketGenBasePath(&north_index, scene_path);
+ index = fgBucketGenIndex(&north_index);
sprintf(file, "%s/%s/%ld.1.south", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".west") == 0 ) {
- gen_base_path(&west_index, scene_path);
- index = gen_index(&west_index);
+ fgBucketGenBasePath(&west_index, scene_path);
+ index = fgBucketGenIndex(&west_index);
sprintf(file, "%s/%s/%ld.1.east", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
}
if ( strcmp(ext, ".east") == 0 ) {
- gen_base_path(&east_index, scene_path);
- index = gen_index(&east_index);
+ fgBucketGenBasePath(&east_index, scene_path);
+ index = fgBucketGenIndex(&east_index);
sprintf(file, "%s/%s/%ld.1.west", basepath, scene_path, index);
if ( file_exists(file) ) {
return(1);
} else {
fp = body;
}
- fprintf(fp, "gdn %.2f %.2f %.2f\n",
- nodes_orig[i][0], nodes_orig[i][1], nodes_orig[i][2]);
+
+ if ( fp != NULL ) {
+ fprintf(fp, "gdn %.2f %.2f %.2f\n",
+ nodes_orig[i][0], nodes_orig[i][1], nodes_orig[i][2]);
+ }
}
printf(" calculating and writing normals\n");
}
}
- fclose(sw);
- fclose(se);
- fclose(ne);
- fclose(nw);
+ if ( sw ) { fclose(sw); }
+ if ( se ) { fclose(se); }
+ if ( ne ) { fclose(ne); }
+ if ( nw ) { fclose(nw); }
- fclose(north);
- fclose(south);
- fclose(east);
- fclose(west);
+ if ( north ) { fclose(north); }
+ if ( south ) { fclose(south); }
+ if ( east ) { fclose(east); }
+ if ( west ) { fclose(west); }
- fclose(body);
+ if ( body ) { fclose(body); }
}
int main(int argc, char **argv) {
char basename[256], basepath[256], temp[256];
- struct bucket p;
+ struct fgBUCKET p;
long int index;
int len;
}
index = atoi(temp);
printf("%ld\n", index);
- parse_index(index, &p);
+ fgBucketParseIndex(index, &p);
printf("bucket = %d %d %d %d\n", p.lon, p.lat, p.x, p.y);
/* generate the indexes of the neighbors */
- offset_bucket(&p, &ne_index, 1, 1);
- offset_bucket(&p, &nw_index, -1, 1);
- offset_bucket(&p, &se_index, 1, -1);
- offset_bucket(&p, &sw_index, -1, -1);
+ fgBucketOffset(&p, &ne_index, 1, 1);
+ fgBucketOffset(&p, &nw_index, -1, 1);
+ fgBucketOffset(&p, &se_index, 1, -1);
+ fgBucketOffset(&p, &sw_index, -1, -1);
- offset_bucket(&p, &north_index, 0, 1);
- offset_bucket(&p, &south_index, 0, -1);
- offset_bucket(&p, &east_index, 1, 0);
- offset_bucket(&p, &west_index, -1, 0);
+ fgBucketOffset(&p, &north_index, 0, 1);
+ fgBucketOffset(&p, &south_index, 0, -1);
+ fgBucketOffset(&p, &east_index, 1, 0);
+ fgBucketOffset(&p, &west_index, -1, 0);
/*
printf("Corner indexes = %ld %ld %ld %ld\n",
/* $Log$
-/* Revision 1.2 1998/01/14 15:54:43 curt
-/* Initial revision completed.
+/* Revision 1.8 1998/04/14 02:26:08 curt
+/* Code reorganizations. Added a Lib/ directory for more general libraries.
/*
+ * Revision 1.7 1998/04/08 23:21:13 curt
+ * Adopted Gnu automake/autoconf system.
+ *
+ * Revision 1.6 1998/03/03 15:36:13 curt
+ * Tweaks for compiling with g++
+ *
+ * Revision 1.5 1998/03/03 03:37:04 curt
+ * Cumulative tweaks.
+ *
+ * Revision 1.4 1998/01/31 00:41:26 curt
+ * Made a few changes converting floats to doubles.
+ *
+ * Revision 1.3 1998/01/27 18:37:04 curt
+ * Lots of updates to get back in sync with changes made over in .../Src/
+ *
+ * Revision 1.2 1998/01/14 15:54:43 curt
+ * Initial revision completed.
+ *
* Revision 1.1 1998/01/14 02:11:31 curt
* Initial revision.
*