X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWeatherCM%2Fsphrintp.h;h=cf60e9e0ca2a3c50e03e6b87d87f388752d947d0;hb=a4e81f4ff075e6a3c0c2ea1b5a29c0bcdfdbc671;hp=78ab4bd4736d2059b34545656aa9ffa63282d3db;hpb=949fc00815feb26e79e7498c82d4129b6961f2c8;p=flightgear.git diff --git a/src/WeatherCM/sphrintp.h b/src/WeatherCM/sphrintp.h index 78ab4bd47..cf60e9e0c 100644 --- a/src/WeatherCM/sphrintp.h +++ b/src/WeatherCM/sphrintp.h @@ -32,43 +32,61 @@ #ifndef SPHRINTP_H #define SPHRINTP_H +#include +#include STL_IOSTREAM + #include "linintp2.h" #include -template +#ifndef SG_HAVE_NATIVE_SGI_COMPILERS +SG_USING_NAMESPACE(std); +SG_USING_STD(cout); +#endif + + class SphereInterpolate { public: SphereInterpolate (int n, const double* x, const double* y, - const double* z, const T* f); - SphereInterpolate (int n, const sgVec2* p, const T* f); + const double* z, const unsigned int* f); + SphereInterpolate (int n, const sgVec2* p, const unsigned int* f); ~SphereInterpolate (); void GetSphericalCoords (const double x, const double y, const double z, double& thetaAngle, double& phiAngle) const; - int Evaluate (const double x, const double y, const double z, T& f) const; - int Evaluate (const double thetaAngle, const double phiAngle, T& f) const; + int Evaluate (const double x, const double y, const double z, EvaluateData& f) const; + int Evaluate (const double thetaAngle, const double phiAngle, EvaluateData& f) const; -#ifndef MACOS +#ifndef macintosh // CodeWarrior doesn't know the differece between sgVec2 and // sgVec3, so I commented this out for Mac builds. This change is // related to a similar change in FGLocalWeatherDatabase module. - T Evaluate(const sgVec2& p) const + EvaluateData Evaluate(const sgVec2& p) const { - T retval; + EvaluateData retval; Evaluate(p[1], p[0], retval); return retval; } #endif - T Evaluate(const sgVec3& p) const + EvaluateData Evaluate(const sgVec3& p) const { - T retval; - Evaluate(p[1], p[0], retval); + EvaluateData retval; + if (!Evaluate(p[1], p[0], retval)) + { + cout << "Error during spherical interpolation. Point (" + << p[0] << "/" << p[1] << "/" << p[2] << ") was in no triangle\n"; + retval.index[0] = 0; //fake something + retval.index[1] = 0; + retval.index[2] = 0; + retval.percentage[0] = 1.0; + retval.percentage[1] = 0.0; + retval.percentage[2] = 0.0; + } return retval; } @@ -76,10 +94,8 @@ protected: int numPoints; double* theta; double* phi; - T* func; - mgcLinInterp2D* pInterp; + unsigned int* func; + mgcLinInterp2D* pInterp; }; -#include "sphrintp.inl" - #endif