]> git.mxchange.org Git - flightgear.git/blob - Array/array.hxx
First mostly successful tile triangulation works. There's plenty of tweaking
[flightgear.git] / Array / array.hxx
1 // array.hxx -- Array management class
2 //
3 // Written by Curtis Olson, started March 1998.
4 //
5 // Copyright (C) 1998 - 1999  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _ARRAY_HXX
26 #define _ARRAY_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 #include <Include/compiler.h>
35
36 #include <vector>
37
38 #include <Bucket/newbucket.hxx>
39 #include <Math/point3d.hxx>
40 #include <Misc/fgstream.hxx>
41
42 FG_USING_STD(vector);
43
44
45 #define ARRAY_SIZE 1200
46 #define ARRAY_SIZE_1 1201
47
48
49 typedef vector < Point3D > fitnode_list;
50 typedef fitnode_list::iterator fitnode_list_iterator;
51 typedef fitnode_list::const_iterator const_fitnode_list_iterator;
52
53
54 class FGArray {
55
56 private:
57
58     // file pointer for input
59     // gzFile fd;
60     fg_gzifstream *in;
61
62     // coordinates (in arc seconds) of south west corner
63     double originx, originy;
64     
65     // number of columns and rows
66     int cols, rows;
67     
68     // Distance between column and row data points (in arc seconds)
69     double col_step, row_step;
70     
71     // pointers to the actual grid data allocated here
72     float (*in_data)[ARRAY_SIZE_1];
73     // float (*out_data)[ARRAY_SIZE_1];
74
75     // output nodes
76     fitnode_list node_list;
77
78     // Initialize output mesh structure
79     // void outputmesh_init( void );
80
81     // Get the value of a mesh node
82     // double outputmesh_get_pt( int i, int j );
83
84     // Set the value of a mesh node
85     // void outputmesh_set_pt( int i, int j, double value );
86
87 #if 0
88     // Write out a node file that can be used by the "triangle" program
89     // void outputmesh_output_nodes( const string& fg_root, FGBucket& p );
90 #endif
91
92 public:
93
94     // Constructor
95     FGArray( void );
96     FGArray( const string& file );
97
98     // Destructor
99     ~FGArray( void );
100
101     // open an Array file (use "-" if input is coming from stdin)
102     int open ( const string& file );
103
104     // close a Array file
105     int close();
106
107     // parse a Array file
108     int parse();
109
110     // Use least squares to fit a simpler data set to dem data
111     void fit( double error );
112
113     // add a node to the output (fitted) node list
114     void add_fit_node( int i, int j, double val );
115
116     // return the current altitude based on grid data.  We should
117     // rewrite this to interpolate exact values, but for now this is
118     // good enough
119     double interpolate_altitude( double lon, double lat );
120
121     // Informational methods
122     inline double get_originx() const { return originx; }
123     inline double get_originy() const { return originy; }
124     inline int get_cols() const { return cols; }
125     inline int get_rows() const { return rows; }
126     inline double get_col_step() const { return col_step; }
127     inline double get_row_step() const { return row_step; }
128
129     inline fitnode_list get_fit_node_list() const { return node_list; }
130 };
131
132
133 #endif // _ARRAY_HXX
134
135
136 // $Log$
137 // Revision 1.3  1999/03/20 20:32:52  curt
138 // First mostly successful tile triangulation works.  There's plenty of tweaking
139 // to do, but we are marching in the right direction.
140 //
141 // Revision 1.2  1999/03/13 23:50:27  curt
142 // Tweaked output formatting a bit.
143 //
144 // Revision 1.1  1999/03/13 18:45:02  curt
145 // Initial revision. (derived from libDEM.a code.)
146 //