]> git.mxchange.org Git - flightgear.git/blobdiff - DEM/dem.hxx
Fixes for win32.
[flightgear.git] / DEM / dem.hxx
index a3b5f215c66efd8a4d3cf8850720e5e2e60eb438..de96a3700d871c4a485ed7ac0116ed84ea19bad7 100644 (file)
 #define _DEM_H
 
 
+#ifndef __cplusplus                                                          
+# error This library requires C++
+#endif                                   
+
+
 #include <stdio.h>
 
-#include <Scenery/Bucket/bucketutils.h>
+#include <Bucket/bucketutils.h>
+
+//#include <zlib/zlib.h>
+#include <Misc/fgstream.hxx>
 
 
 #define DEM_SIZE 1200
@@ -39,7 +47,8 @@
 
 class fgDEM {
     // file pointer for input
-    FILE *fd;
+    // gzFile fd;
+    fg_gzifstream *in;
 
     // coordinates (in arc seconds) of south west corner
     double originx, originy;
@@ -50,9 +59,9 @@ class fgDEM {
     // Distance between column and row data points (in arc seconds)
     double col_step, row_step;
     
-    // the actual mesh data allocated here
-    // float dem_data[DEM_SIZE_1][DEM_SIZE_1];
-    // float output_data[DEM_SIZE_1][DEM_SIZE_1];
+    // pointers to the actual mesh data allocated here
+    float (*dem_data)[DEM_SIZE_1];
+    float (*output_data)[DEM_SIZE_1];
 
     // Current "A" Record Information
     char dem_description[80], dem_quadrangle[80];
@@ -71,25 +80,37 @@ class fgDEM {
     int do_data;
     int cur_col, cur_row;
 
+    // return next token from input stream
+    string next_token();
+
+    // return next integer from input stream
+    int next_int();
+
+    // return next double from input stream
+    double next_double();
+
+    // return next exponential num from input stream
+    int next_exp();
+
 public:
 
-    // Constructor (opens a DEM file)
+    // Constructor
     fgDEM( void );
 
     // open a DEM file (use "-" if input is coming from stdin)
-    int open ( char *file );
+    int open ( const string& file );
 
     // close a DEM file
-    int close ( void );
+    int close ();
 
     // parse a DEM file
-    int parse( float dem_data[DEM_SIZE_1][DEM_SIZE_1] );
+    int parse();
 
     // read and parse DEM "A" record
-    void read_a_record( );
+    int read_a_record();
 
     // read and parse DEM "B" record
-    void read_b_record( float dem_data[DEM_SIZE_1][DEM_SIZE_1] );
+    void read_b_record();
 
     // Informational methods
     double info_originx( void ) { return(originx); }
@@ -98,28 +119,22 @@ public:
     // return the current altitude based on mesh data.  We should
     // rewrite this to interpolate exact values, but for now this is
     // good enough
-    double interpolate_altitude( float dem_data[DEM_SIZE_1][DEM_SIZE_1], 
-                                double lon, double lat);
+    double interpolate_altitude( double lon, double lat );
 
     // Use least squares to fit a simpler data set to dem data
-    void fit( float dem_data[DEM_SIZE_1][DEM_SIZE_1], 
-             float output_data[DEM_SIZE_1][DEM_SIZE_1], 
-             char *fg_root, double error, struct fgBUCKET *p );
+    void fit( double error, fgBUCKET *p );
 
     // Initialize output mesh structure
-    void outputmesh_init( float output_data[DEM_SIZE_1][DEM_SIZE_1] );
+    void outputmesh_init( void );
 
     // Get the value of a mesh node
-    double outputmesh_get_pt( float output_data[DEM_SIZE_1][DEM_SIZE_1],
-                             int i, int j );
+    double outputmesh_get_pt( int i, int j );
 
     // Set the value of a mesh node
-    void outputmesh_set_pt( float output_data[DEM_SIZE_1][DEM_SIZE_1],
-                           int i, int j, double value );
+    void outputmesh_set_pt( int i, int j, double value );
 
     // Write out a node file that can be used by the "triangle" program
-    void outputmesh_output_nodes( float output_data[DEM_SIZE_1][DEM_SIZE_1],
-                                 char *fg_root, struct fgBUCKET *p );
+    void outputmesh_output_nodes( const string& fg_root, fgBUCKET *p );
 
     // Destructor
     ~fgDEM( void );
@@ -130,6 +145,29 @@ public:
 
 
 // $Log$
+// Revision 1.8  1998/09/19 17:59:46  curt
+// Use c++ streams (fg_gzifstream).  Also converted many character arrays to
+// the string class.
+//
+// Revision 1.7  1998/07/04 00:47:19  curt
+// typedef'd struct fgBUCKET.
+//
+// Revision 1.6  1998/06/05 18:14:40  curt
+// Abort out early when reading the "A" record if it doesn't look like
+// a proper DEM file.
+//
+// Revision 1.5  1998/04/22 13:14:46  curt
+// Fixed a bug in zlib usage.
+//
+// Revision 1.4  1998/04/21 17:03:41  curt
+// Prepairing for C++ integration.
+//
+// Revision 1.3  1998/04/18 03:53:06  curt
+// Added zlib support.
+//
+// Revision 1.2  1998/04/14 02:43:28  curt
+// Used "new" to auto-allocate large DEM parsing arrays in class constructor.
+//
 // Revision 1.1  1998/04/08 22:57:23  curt
 // Adopted Gnu automake/autoconf system.
 //