From: James Turner Date: Thu, 23 Jun 2016 14:21:26 +0000 (+0100) Subject: Native SGPath API on SGInterpTable X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c6add2db392105e7a6f660cca9c88047641eaf47;p=simgear.git Native SGPath API on SGInterpTable - string-based version will be removed in the future. --- diff --git a/simgear/math/interpolater.cxx b/simgear/math/interpolater.cxx index b9526ea9..cbbb31cf 100644 --- a/simgear/math/interpolater.cxx +++ b/simgear/math/interpolater.cxx @@ -64,6 +64,28 @@ SGInterpTable::SGInterpTable( const std::string& file ) 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; while ( in ) { double ind, dep; diff --git a/simgear/math/interpolater.hxx b/simgear/math/interpolater.hxx index 34dff626..5f928502 100644 --- a/simgear/math/interpolater.hxx +++ b/simgear/math/interpolater.hxx @@ -41,6 +41,7 @@ #include class SGPropertyNode; +class SGPath; /** * A class that provids a simple linear 2d interpolation lookup table. @@ -69,7 +70,12 @@ public: */ 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. *