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

@ -74,6 +74,28 @@ SGInterpTable::SGInterpTable( const std::string& file )
} }
// 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;
while ( in ) {
double ind, dep;
in >> ind >> dep;
in >> std::skipws;
_table[ind] = dep;
}
}
// Add an entry to the table. // Add an entry to the table.
void SGInterpTable::addEntry (double ind, double dep) void SGInterpTable::addEntry (double ind, double 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,6 +70,11 @@ 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.