From aef2a1c4847ac2080320129ceed2979cdeb5cb89 Mon Sep 17 00:00:00 2001 From: frohlich Date: Sat, 2 Dec 2006 15:56:55 +0000 Subject: [PATCH] Modified Files: interpolater.cxx interpolater.hxx: Enable reading tables directly from our dom like tree. --- simgear/math/interpolater.cxx | 10 ++++++++++ simgear/math/interpolater.hxx | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/simgear/math/interpolater.cxx b/simgear/math/interpolater.cxx index ae2af9b6..59caa2fc 100644 --- a/simgear/math/interpolater.cxx +++ b/simgear/math/interpolater.cxx @@ -29,6 +29,7 @@ #include #include +#include #include "interpolater.hxx" @@ -39,6 +40,15 @@ SGInterpTable::SGInterpTable() { } +SGInterpTable::SGInterpTable(const SGPropertyNode* interpolation) +{ + if (!interpolation) + return; + std::vector 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 // file diff --git a/simgear/math/interpolater.hxx b/simgear/math/interpolater.hxx index 1681d9d3..797ddf4f 100644 --- a/simgear/math/interpolater.hxx +++ b/simgear/math/interpolater.hxx @@ -42,6 +42,8 @@ #include STL_STRING SG_USING_STD(string); +class SGPropertyNode; + /** * A class that provids a simple linear 2d interpolation lookup table. * The actual table is expected to be loaded from a file. The @@ -56,6 +58,13 @@ public: */ 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. * @param file name of interpolation file