]> git.mxchange.org Git - flightgear.git/blobdiff - Array/array.cxx
First mostly successful tile triangulation works. There's plenty of tweaking
[flightgear.git] / Array / array.cxx
index 200fcdc5742c643405435772b56e2620f745817a..90e04142d7ee42039c7f1a010f42564a72652bd0 100644 (file)
@@ -60,14 +60,14 @@ FG_USING_STD(string);
 FGArray::FGArray( void ) {
     // cout << "class FGArray CONstructor called." << endl;
     in_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
-    out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
+    // out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
 }
 
 
 FGArray::FGArray( const string &file ) {
     // cout << "class FGArray CONstructor called." << endl;
     in_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
-    out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
+    // out_data = new float[ARRAY_SIZE_1][ARRAY_SIZE_1];
 
     FGArray::open(file);
 }
@@ -110,10 +110,6 @@ FGArray::close() {
 // parse Array file
 int
 FGArray::parse() {
-    int i;
-
-    // cur_col = 0;
-
     *in >> originx >> originy;
     *in >> cols >> col_step;
     *in >> rows >> row_step;
@@ -134,6 +130,16 @@ FGArray::parse() {
 }
 
 
+// add a node to the output (fitted) node list
+void FGArray::add_fit_node( int i, int j, double val ) {
+    double x = (originx + i * col_step) / 3600.0;
+    double y = (originy + j * row_step) / 3600.0;
+    cout << Point3D(x, y, val) << endl;
+    node_list.push_back( Point3D(x, y, val) );
+}
+
+
+#if 0
 // Initialize output mesh structure
 void FGArray::outputmesh_init( void ) {
     int i, j;
@@ -157,6 +163,7 @@ void FGArray::outputmesh_set_pt( int i, int j, double value ) {
     // cout << "Setting data[" << i << "][" << j << "] = " << value << endl;
    out_data[i][j] = value;
 }
+#endif
 
 
 // Use least squares to fit a simpler data set to dem data
@@ -174,7 +181,7 @@ void FGArray::fit( double error ) {
     error_sq = error * error;
 
     cout << "  Initializing output mesh structure" << endl;
-    outputmesh_init();
+    // outputmesh_init();
 
     // determine dimensions
     colmin = 0;
@@ -185,12 +192,13 @@ void FGArray::fit( double error ) {
         << colmax << "," << rowmax << endl;;
     
     // include the corners explicitly
-    outputmesh_set_pt(colmin, rowmin, in_data[colmin][rowmin]);
-    outputmesh_set_pt(colmin, rowmax, in_data[colmin][rowmax]);
-    outputmesh_set_pt(colmax, rowmax, in_data[colmax][rowmax]);
-    outputmesh_set_pt(colmax, rowmin, in_data[colmax][rowmin]);
+    add_fit_node( colmin, rowmin, in_data[colmin][rowmin] );
+    add_fit_node( colmin, rowmax-1, in_data[colmin][rowmax] );
+    add_fit_node( colmax-1, rowmin, in_data[colmax][rowmin] );
+    add_fit_node( colmax-1, rowmax-1, in_data[colmax][rowmax] );
 
     cout << "  Beginning best fit procedure" << endl;
+    lasty = 0;
 
     for ( row = rowmin; row < rowmax; row++ ) {
        // fit  = fopen("fit.dat",  "w");
@@ -279,7 +287,7 @@ void FGArray::fit( double error ) {
            if ( start > colmin ) {
                // skip this for the first line segment
                cury = m * x[0] + b;
-               outputmesh_set_pt(start, row, (lasty + cury) / 2);
+               add_fit_node( start, row, (lasty + cury) / 2 );
                // fprintf(fit, "%.2f %.2f\n", x[0], (lasty + cury) / 2);
            }
 
@@ -547,11 +555,19 @@ void FGArray::outputmesh_output_nodes( const string& fg_root, FGBucket& p )
 FGArray::~FGArray( void ) {
     // printf("class FGArray DEstructor called.\n");
     delete [] in_data;
-    delete [] out_data;
+    // delete [] out_data;
 }
 
 
 // $Log$
+// Revision 1.4  1999/03/20 20:32:51  curt
+// First mostly successful tile triangulation works.  There's plenty of tweaking
+// to do, but we are marching in the right direction.
+//
+// Revision 1.3  1999/03/17 23:48:17  curt
+// Removed forced -g compile flag.
+// Fixed a couple compiler warnings.
+//
 // Revision 1.2  1999/03/13 23:50:26  curt
 // Tweaked output formatting a bit.
 //