Modified Files:

interpolater.cxx interpolater.hxx: Enable reading tables directly
	from our dom like tree.
This commit is contained in:
frohlich 2006-12-02 15:56:55 +00:00
parent a4b28e5737
commit aef2a1c484
2 changed files with 19 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/props/props.hxx>
#include "interpolater.hxx" #include "interpolater.hxx"
@ -39,6 +40,15 @@ SGInterpTable::SGInterpTable()
{ {
} }
SGInterpTable::SGInterpTable(const SGPropertyNode* interpolation)
{
if (!interpolation)
return;
std::vector<SGPropertyNode_ptr> entries = interpolation->getChildren("entry");
for (unsigned i = 0; i < entries.size(); ++i)
addEntry(entries[i]->getDoubleValue("ind", 0.0),
entries[i]->getDoubleValue("dep", 0.0));
}
// Constructor -- loads the interpolation table from the specified // Constructor -- loads the interpolation table from the specified
// file // file

View File

@ -42,6 +42,8 @@
#include STL_STRING #include STL_STRING
SG_USING_STD(string); SG_USING_STD(string);
class SGPropertyNode;
/** /**
* A class that provids a simple linear 2d interpolation lookup table. * A class that provids a simple linear 2d interpolation lookup table.
* The actual table is expected to be loaded from a file. The * The actual table is expected to be loaded from a file. The
@ -56,6 +58,13 @@ public:
*/ */
SGInterpTable(); SGInterpTable();
/**
* Constructor. Loads the interpolation table from an interpolation
* property node.
* @param interpolation property node having entry children
*/
SGInterpTable(const SGPropertyNode* interpolation);
/** /**
* Constructor. Loads the interpolation table from the specified file. * Constructor. Loads the interpolation table from the specified file.
* @param file name of interpolation file * @param file name of interpolation file