00001
00002
00004 #ifdef WIN32
00005 #pragma warning(disable:4786)
00006 #endif
00007 #include "Table2D.h"
00008 #include "GenericFileReader2D.h"
00009 #include "BilinearInterpolator2D.h"
00010 #include "FourNearestNeighboursMeanInterpolator2D.h"
00011 #include "NearestNeighbourInterpolator2D.h"
00013
00015 namespace Interpolator
00016 {
00018
00019
00020
00021
00022
00024 Table2D::~Table2D()
00025 {
00026 DESTRUCTION(_mInterpolator);
00027 DESTRUCTION(_mData);
00028 }
00029
00035 Table2D::Table2D( std::string sName,
00036 std::string sDescription,
00037 std::string sInterpolationType,
00038 std::string sFilePath) :
00039 Table(sName,sDescription,sInterpolationType,sFilePath)
00040 {
00041 GenericFileReader2D* _mFileReader = new GenericFileReader2D(sFilePath);
00042
00043 double* mXValues = _mFileReader->getDataX();
00044 double* mYValues = _mFileReader->getDataY();
00045 double* mZValues = _mFileReader->getDataZ();
00046
00047 long lNbXValues = _mFileReader->getNbDataX();
00048 long lNbYValues = _mFileReader->getNbDataY();
00049
00050
00051 std::string _sXName = _mFileReader->getDataXName();
00052 std::string _sYName = _mFileReader->getDataYName();
00053 std::string _sZName = _mFileReader->getDataZName();
00054
00055 _mData = new InterpolationData2D( _sXName,_sYName,_sZName,
00056 lNbXValues,lNbYValues,
00057 mXValues,mYValues,mZValues);
00058
00059 initializeInterpolator();
00060 delete(_mFileReader);
00061
00062 }
00063
00064
00077 Table2D::Table2D( std::string sName,
00078 std::string sDescription,
00079 std::string sInterpolationType,
00080 std::string sXName,
00081 std::string sYName,
00082 std::string sZName,
00083 long lNbDataX,
00084 long lNbDataY,
00085 double* mXValues,
00086 double* mYValues,
00087 double* mZValues) :
00088 Table(sName,sDescription,sInterpolationType)
00089 {
00090
00091 _mData = new InterpolationData2D( sXName,sYName,sZName,
00092 lNbDataX,lNbDataY,
00093 mXValues,mYValues,mZValues);
00094
00095 initializeInterpolator();
00096
00097
00098 }
00099
00101 void Table2D::initializeInterpolator()
00102 {
00104 if (getInterpolationType() == "Bilinear")
00105 {
00106 _mInterpolator = new BilinearInterpolator2D("Bilinear Interpolator",
00107 getDescription(),
00108 _mData);
00109 }
00110
00112 else if (getInterpolationType() == "Nearest")
00113 {
00114 _mInterpolator = new NearestNeighbourInterpolator2D("Nearest Neighbour Interpolator",
00115 getDescription(),
00116 "Nearest Neighbour",
00117 _mData);
00118 }
00119
00121 else if (getInterpolationType() == "FourNearestMean")
00122 {
00123 _mInterpolator = new FourNearestNeighboursMeanInterpolator2D( "FourNearestNeighboursMean Interpolator",
00124 getDescription(),
00125 _mData);
00126 }
00127 }
00128
00129
00131 double Table2D::computeValue(double dXValue, double dYvalue)
00132 {
00133 return _mInterpolator->getInterpolatedValue(dXValue,dYvalue);
00134 }
00135
00138 double Table2D::computeValue()
00139 {
00140 return 0.0;
00141 }
00142
00144 InterpolationData2D* Table2D::getInterpolationData() const
00145 {
00146 return _mData;
00147 }
00148
00150 void Table2D::printInfos()
00151 {
00152 if(Interpolator::_verb == true) cout << "\n##### TABLE 2D --> " << getName() << " #####" << endl;
00153 if(Interpolator::_verb == true) cout << "\tInterpolation Type:" << getInterpolationType() << endl;
00154 if(Interpolator::_verb == true) cout << "\t" << getDescription() << endl;
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00171 void Table2D::setXValue(int i,double dNewValue)
00172 {
00173
00174 _mInterpolator->getInterpolatedData()->setXValue(i,dNewValue);
00175 }
00176
00178 void Table2D::setYValue(int i,double dNewValue)
00179 {
00180
00181 _mInterpolator->getInterpolatedData()->setYValue(i,dNewValue);
00182 }
00183
00185 void Table2D::setZValue(int i,int j,double dNewValue)
00186 {
00187
00188 _mInterpolator->getInterpolatedData()->setZValue(i,j,dNewValue);
00189 }
00190
00192 void Table2D::setValues(long lNbXData,long lNbYData,double* dNewXValues,double* dNewYValues,double* dNewZValues)
00193 {
00194
00195 _mInterpolator->getInterpolatedData()->setValues(lNbXData,lNbYData,dNewXValues,dNewYValues,dNewZValues);
00196 }
00197
00198
00199
00203 double Table2D::getXValue(int i) const
00204 {
00205 return _mInterpolator->getInterpolatedData()->getXValue(i);
00206 }
00207
00211 double Table2D::getYValue(int i) const
00212 {
00213 return _mInterpolator->getInterpolatedData()->getYValue(i);
00214 }
00215
00219 double Table2D::getZValue(int i,int j) const
00220 {
00221 return _mInterpolator->getInterpolatedData()->getZValue(i,j);
00222 }
00223
00226 double* Table2D::getXValues() const
00227 {
00228 return _mInterpolator->getInterpolatedData()->getXValues();
00229 }
00230
00233 double* Table2D::getYValues() const
00234 {
00235 return _mInterpolator->getInterpolatedData()->getYValues();
00236 }
00237
00240 double* Table2D::getZValues() const
00241 {
00242 return _mInterpolator->getInterpolatedData()->getZValues();
00243 }
00244
00245
00247 long Table2D::getNbXData() const
00248 {
00249 return _mInterpolator->getInterpolatedData()->getNbXData();
00250 }
00251
00253 long Table2D::getNbYData() const
00254 {
00255 return _mInterpolator->getInterpolatedData()->getNbYData();
00256 }
00257
00259 long Table2D::getNbZData() const
00260 {
00261 return _mInterpolator->getInterpolatedData()->getNbZData();
00262 }
00263
00264
00265
00266 }
00267
00268
00269