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);
}
FGArray::open( const string& file ) {
// open input file (or read from stdin)
if ( file == "-" ) {
- cout << "Opening array data pipe from stdin" << endl;
+ cout << " Opening array data pipe from stdin" << endl;
// fd = stdin;
// fd = gzdopen(STDIN_FILENO, "r");
- cout << "Not yet ported ..." << endl;
+ cout << " Not yet ported ..." << endl;
return 0;
} else {
in = new fg_gzifstream( file );
if ( !(*in) ) {
- cout << "Cannot open " << file << endl;
+ cout << " Cannot open " << file << endl;
return 0;
}
- cout << "Opening array data file: " << file << endl;
+ cout << " Opening array data file: " << file << endl;
}
return 1;
// parse Array file
int
FGArray::parse() {
- int i;
-
- // cur_col = 0;
-
*in >> originx >> originy;
*in >> cols >> col_step;
*in >> rows >> row_step;
}
+// 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;
// 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
-void FGArray::fit( FGBucket& p, double error ) {
+void FGArray::fit( double error ) {
double x[ARRAY_SIZE_1], y[ARRAY_SIZE_1];
double m, b, max_error, error_sq;
double x1, y1;
error_sq = error * error;
- cout << "Initializing output mesh structure" << endl;
- outputmesh_init();
+ cout << " Initializing output mesh structure" << endl;
+ // outputmesh_init();
// determine dimensions
colmin = 0;
colmax = cols;
rowmin = 0;
rowmax = rows;
- cout << "Fitting region = " << colmin << "," << rowmin << " to "
+ cout << " Fitting region = " << colmin << "," << rowmin << " to "
<< 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;
+ cout << " Beginning best fit procedure" << endl;
+ lasty = 0;
for ( row = rowmin; row < rowmax; row++ ) {
// fit = fopen("fit.dat", "w");
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);
}
// generate the base directory
string base_path = p.gen_base_path();
- cout << "fg_root = " << fg_root << " Base Path = " << base_path << endl;
+ cout << " fg_root = " << fg_root << " Base Path = " << base_path << endl;
dir = fg_root + "/Scenery/" + base_path;
- cout << "Dir = " << dir << endl;
+ cout << " Dir = " << dir << endl;
// stat() directory and create if needed
errno = 0;
result = stat(dir.c_str(), &stat_buf);
if ( result != 0 && errno == ENOENT ) {
- cout << "Creating directory\n";
+ cout << " Creating directory\n";
command = "mkdir -p " + dir + "\n";
system( command.c_str() );
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.
+//
// Revision 1.1 1999/03/13 18:45:02 curt
// Initial revision. (derived from libDEM.a code.)
//