From 577f80482d334379da792823d8d4e05001a97ae5 Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Thu, 29 Nov 2012 10:37:31 +0100 Subject: [PATCH] Output lib: remove unused functions, use SG_LOG and clean up --- src/Lib/Output/output.cxx | 99 +++++---------------------------------- src/Lib/Output/output.hxx | 26 ++-------- 2 files changed, 17 insertions(+), 108 deletions(-) diff --git a/src/Lib/Output/output.cxx b/src/Lib/Output/output.cxx index 47acb8cb..0b7fa059 100644 --- a/src/Lib/Output/output.cxx +++ b/src/Lib/Output/output.cxx @@ -1,4 +1,4 @@ -// output.cxx -- routines to output a polygon model of an airport +// output.cxx -- routines to output index files of an airport // // Written by Curtis Olson, started September 1999. // @@ -18,54 +18,23 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // -// $Id: output.cxx,v 1.10 2004-11-19 22:25:50 curt Exp $ -// #ifdef HAVE_CONFIG_H #include #endif -#include - #include #include -#include -#include - -#include -#include +#include #include #include -#include - #include "output.hxx" -using std:: cout ; -using std:: endl ; using std::string; - -void write_polygon( const TGPolygon& poly, const string& base ) { - for ( int i = 0; i < poly.contours(); ++i ) { - char name[256]; - sprintf(name, "%s%d", base.c_str(), i ); - FILE *fp = fopen( name, "w" ); - - fprintf(fp, "hole = %d\n", poly.get_hole_flag(i)); - for ( int j = 0; j < poly.contour_size( i ); ++j ) { - Point3D p0 = poly.get_pt(i, j); - fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y()); - } - Point3D p0 = poly.get_pt(i, 0); - fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y()); - fclose(fp); - } -} - - // update index file (list of objects to be included in final scenery build) void write_index( const string& base, const SGBucket& b, const string& name ) { @@ -75,13 +44,12 @@ void write_index( const string& base, const SGBucket& b, const string& name ) sgp.create_dir( 0755 ); string file = dir + "/" + b.gen_index_str() + ".ind"; - // string file = dir + "/" + name; - cout << "Writing object to " << file << endl; + SG_LOG( SG_GENERAL, SG_DEBUG, "Writing object to " << file ); FILE *fp; if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - cout << "ERROR: opening " << file << " for writing!" << endl; - exit(-1); + SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + exit(-1); } fprintf( fp, "OBJECT %s\n", name.c_str() ); @@ -101,13 +69,12 @@ void write_index_shared( const string &base, const SGBucket &b, sgp.create_dir( 0755 ); string file = dir + "/" + b.gen_index_str() + ".ind"; - // string file = dir + "/" + name; - cout << "Writing shared object to " << file << endl; + SG_LOG( SG_GENERAL, SG_DEBUG, "Writing shared object to " << file ); FILE *fp; if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - cout << "ERROR: opening " << file << " for writing!" << endl; - exit(-1); + SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + exit(-1); } fprintf( fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(), @@ -116,8 +83,8 @@ void write_index_shared( const string &base, const SGBucket &b, } void write_object_sign( const string &base, const SGBucket &b, - const SGGeod &p, const string& sign, - const double &heading, const int &size) + const SGGeod &p, const string& sign, + const double &heading, const int &size) { string dir = base + "/" + b.gen_base_path(); SGPath sgp( dir ); @@ -125,55 +92,15 @@ void write_object_sign( const string &base, const SGBucket &b, sgp.create_dir( 0755 ); string file = dir + "/" + b.gen_index_str() + ".ind"; - // string file = dir + "/" + name; - cout << "Writing sign to " << file << endl; + SG_LOG( SG_GENERAL, SG_DEBUG, "Writing sign to " << file ); FILE *fp; if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - cout << "ERROR: opening " << file << " for writing!" << endl; - exit(-1); + SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + exit(-1); } fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %u\n", sign.c_str(), p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size ); fclose( fp ); } - -void write_boundary( const string& base, const SGBucket& b, - const TGPolygon& bounds, long int p_index ) -{ - Point3D p; - - string dir = base + "/" + b.gen_base_path(); - SGPath sgp( dir ); - sgp.append( "dummy" ); - sgp.create_dir( 0755 ); - - string file = dir + "/" + b.gen_index_str(); - - char poly_index[256]; - sprintf( poly_index, "%ld", p_index ); - file += "."; - file += poly_index; - - cout << "Writing boundary to " << file << endl; - - FILE *fp; - if ( (fp = fopen( file.c_str(), "w" )) == NULL ) { - cout << "ERROR: opening " << file << " for writing!" << endl; - exit(-1); - } - - fprintf( fp, "Hole\n" ); - - fprintf( fp, "%d\n", bounds.contours() ); - for ( int i = 0; i < bounds.contours(); ++i ) { - fprintf( fp, "%d\n", bounds.contour_size(i) ); - fprintf( fp, "%d\n", bounds.get_hole_flag(i) ); - for ( int j = 0; j < bounds.contour_size(i); ++j ) { - p = bounds.get_pt( i, j ); - fprintf( fp, "%.15f %.15f\n", p.x(), p.y() ); - } - } - fclose( fp ); -} diff --git a/src/Lib/Output/output.hxx b/src/Lib/Output/output.hxx index 1c34d663..5b7d508f 100644 --- a/src/Lib/Output/output.hxx +++ b/src/Lib/Output/output.hxx @@ -1,4 +1,4 @@ -// output.hxx -- routines to output a polygon model of an airport +// output.hxx -- routines to output index files of an airport // // Written by Curtis Olson, started September 1999. // @@ -18,8 +18,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // -// $Id: output.hxx,v 1.5 2004-11-19 22:25:50 curt Exp $ -// #ifndef _TG_OUTPUT_HXX @@ -29,21 +27,8 @@ #include #endif -#include - -#include -#include - -#include #include -#include - -#include - - -void write_polygon( const TGPolygon& poly, const std::string& base ); - // update index file (list of objects to be included in final scenery build) void write_index( const std::string& base, const SGBucket& b, const std::string& name ); @@ -56,10 +41,7 @@ void write_index_shared( const std::string &base, const SGBucket &b, // update index file (list of shared objects to be included in final // scenery build) void write_object_sign( const std::string &base, const SGBucket &b, - const SGGeod &p, const std::string& sign, - const double &heading, const int &size ); + const SGGeod &p, const std::string& sign, + const double &heading, const int &size ); -void write_boundary( const std::string& base, const SGBucket& b, - const TGPolygon& bounds, long int p_index ); - -#endif // _TG_OUTPUT_HXX +#endif