]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_binobj.cxx
Cygwin fixes.
[simgear.git] / simgear / io / sg_binobj.cxx
index 3c1f976f961ceb9e56d95e3208ea0b4caee1c1eb..6acd4d9b4204c1894ead2a16a57b1a6845713310 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started January 2000.
 //
-// Copyright (C) 2000  Curtis L. Olson  - curt@flightgear.org
+// Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/debug/logstream.hxx>
 
 #include <stdio.h>
 #include <time.h>
@@ -42,8 +43,6 @@
 
 SG_USING_STD( string );
 SG_USING_STD( vector );
-SG_USING_STD( cout );
-SG_USING_STD( endl );
 
 
 enum {
@@ -90,7 +89,7 @@ public:
        while ( size < s ) {
            size *= 2;
        }
-       cout << "Creating a new buffer of size = " << size << endl;
+        SG_LOG(SG_EVENT, SG_DEBUG, "Creating a new buffer of size = " << size);
        ptr = new char[size];
     }
 
@@ -108,7 +107,7 @@ public:
            while ( size < s ) {
                size *= 2;
            }
-           cout << "resizing buffer to size = " << size << endl;
+            SG_LOG(SG_EVENT, SG_DEBUG, "resizing buffer to size = " << size);
            ptr = new char[size];
        }
     }
@@ -117,7 +116,7 @@ public:
 
 // calculate the center of a list of points, by taking the halfway
 // point between the min and max points.
-static Point3D calc_center( point_list& wgs84_nodes ) {
+Point3D sgCalcCenter( point_list& wgs84_nodes ) {
     Point3D p, min, max;
 
     if ( wgs84_nodes.size() ) {
@@ -322,8 +321,8 @@ bool SGBinObject::read_bin( const string& file ) {
     if ( (fp = gzopen( file.c_str(), "rb" )) == NULL ) {
        string filegz = file + ".gz";
        if ( (fp = gzopen( filegz.c_str(), "rb" )) == NULL ) {
-           cout << "ERROR: opening " << file << " or " << filegz
-                << "for reading!" << endl;
+            SG_LOG( SG_EVENT, SG_ALERT,
+               "ERROR: opening " << file << " or " << filegz << "for reading!");
 
            return false;
        }
@@ -361,7 +360,7 @@ bool SGBinObject::read_bin( const string& file ) {
     local_tm = localtime( &calendar_time );
     char time_str[256];
     strftime( time_str, 256, "%a %b %d %H:%M:%S %Z %Y", local_tm);
-    cout << "File created on " << time_str << endl;
+    SG_LOG( SG_EVENT, SG_DEBUG, "File created on " << time_str);
 #endif
 
     // read number of top level objects
@@ -404,9 +403,9 @@ bool SGBinObject::read_bin( const string& file ) {
 
                double *dptr = (double *)ptr;
                if ( sgIsBigEndian() ) {
-                   sgEndianSwap( (uint64 *)&(dptr[0]) );
-                   sgEndianSwap( (uint64 *)&(dptr[1]) );
-                   sgEndianSwap( (uint64 *)&(dptr[2]) );
+                   sgEndianSwap( (uint64_t *)&(dptr[0]) );
+                   sgEndianSwap( (uint64_t *)&(dptr[1]) );
+                   sgEndianSwap( (uint64_t *)&(dptr[2]) );
                }
                gbs_center = Point3D( dptr[0], dptr[1], dptr[2] );
                // cout << "Center = " << gbs_center << endl;
@@ -657,7 +656,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
     // write header magic
     sgWriteUInt( fp, SG_FILE_MAGIC_NUMBER );
     time_t calendar_time = time(NULL);
-    sgWriteLong( fp, (long int)calendar_time );
+    sgWriteLong( fp, (int32_t)calendar_time );
 
     // calculate and write number of top level objects
     string material;
@@ -1146,7 +1145,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
            for ( i = start; i < end; ++i ) {
                for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
                    group_nodes.push_back( wgs84_nodes[ tris_v[i][j] ] );
-                   bs_center = calc_center( group_nodes );
+                   bs_center = sgCalcCenter( group_nodes );
                    bs_radius = sgCalcBoundingRadius( bs_center, group_nodes );
                }
            }
@@ -1197,7 +1196,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
            for ( i = start; i < end; ++i ) {
                for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
                    group_nodes.push_back( wgs84_nodes[ strips_v[i][j] ] );
-                   bs_center = calc_center( group_nodes );
+                   bs_center = sgCalcCenter( group_nodes );
                    bs_radius = sgCalcBoundingRadius( bs_center, group_nodes );
                }
            }