Native SGPath API on SGInterpTable

- string-based version will be removed in the future.
This commit is contained in:
James Turner 2016-06-23 15:21:26 +01:00
parent bd896096cc
commit 8cfe5a2e08
2 changed files with 29 additions and 1 deletions

View File

@ -64,6 +64,28 @@ SGInterpTable::SGInterpTable( const std::string& file )
return; return;
} }
in >> skipcomment;
while ( in ) {
double ind, dep;
in >> ind >> dep;
in >> std::skipws;
_table[ind] = dep;
}
}
// Constructor -- loads the interpolation table from the specified
// file
SGInterpTable::SGInterpTable( const SGPath& file )
{
SG_LOG( SG_MATH, SG_INFO, "Initializing Interpolator for " << file );
sg_gzifstream in( file );
if ( !in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
return;
}
in >> skipcomment; in >> skipcomment;
while ( in ) { while ( in ) {
double ind, dep; double ind, dep;

View File

@ -41,6 +41,7 @@
#include <string> #include <string>
class SGPropertyNode; class SGPropertyNode;
class SGPath;
/** /**
* A class that provids a simple linear 2d interpolation lookup table. * A class that provids a simple linear 2d interpolation lookup table.
@ -69,7 +70,12 @@ public:
*/ */
SGInterpTable( const std::string& file ); SGInterpTable( const std::string& file );
/**
* Constructor. Loads the interpolation table from the specified file.
* @param file name of interpolation file
*/
SGInterpTable( const SGPath& path );
/** /**
* Add an entry to the table, extending the table's length. * Add an entry to the table, extending the table's length.
* *