QGpCoreTools/IrregularGrid2D.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2003-01-14
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef IrregularGrid2D_H
00030 #define IrregularGrid2D_H
00031 
00032 #include "IrregularGrid2DData.h"
00033 #include "GridSearch.h"
00034 #include "Translations.h"
00035 #include "XMLClass.h"
00036 
00037 namespace QGpCoreTools {
00038 
00039 class QGPCORETOOLS_EXPORT IrregularGrid2D : public XMLClass
00040 {
00041   TRANSLATIONS("IrregularGrid2D")
00042 public:
00043   IrregularGrid2D() {_d=new IrregularGrid2DData;}
00044   IrregularGrid2D(int nx, int ny) {_d=new IrregularGrid2DData(nx, ny);}
00045 
00046   virtual const QString& xml_tagName() const {return xmlIrregularGrid2DTag;}
00047   static const QString xmlIrregularGrid2DTag;
00048 
00049   void operator=(const GridSearch& o) {_d->operator=(o);}
00050   void operator+=(const IrregularGrid2D& o) {_d->operator+=( *o._d);}
00051 
00052   int nx() const {return _d->nx();}
00053   int ny() const {return _d->ny();}
00054   void clear() {_d->clear();}
00055   void init(int nx, int ny) {_d->init(nx, ny);}
00056   void init(int nx, int ny, double value) {_d->init(nx, ny, value);}
00057   void init(double value=0.0)  {_d->init(value);}
00058   bool isLike(IrregularGrid2D& o) const {return _d->isLike( *o._d);}
00059   // Function to set _x and _y values
00060   void setLinear(AxisType axis, double min, double max) {_d->setLinear(axis, min, max);}
00061   void setLog(AxisType axis, double min, double max) {_d->setLog(axis, min, max);}
00062   // Resample the grid at x defined by xModel (e.g. from another curve)
00063   void resample(AxisType axis, const QVector<double>& xModel, SamplingOptions options) {_d->resample(axis, xModel, options);}
00064   void resample(AxisType axis, int n, double min, double max, SamplingOptions options) {_d->resample(axis, n, min, max, options);}
00065   // Cut function between two x values
00066   void cut(AxisType axis, double min, double max, SamplingOptions options) {_d->cut(axis, min, max, options);}
00067   void inverse(AxisType axis) {_d->inverse(axis);}
00068   void log10(AxisType axis) {_d->log10(axis);}
00069   void log10() {_d->log10();}
00070   void pow10(AxisType axis) {_d->pow10(axis);}
00071   void pow10() {_d->pow10();}
00072   void multiplyCoordinates(AxisType axis, double fac) {_d->multiplyCoordinates(axis, fac);}
00073   void multiplyValues(AxisType along, int index, double fac) {_d->multiplyValues(along, index, fac);}
00074   void multiplyValues(double fac) {_d->multiplyValues(fac);}
00075   const double * axisData(AxisType axis) const {return _d->axisData(axis);}
00076   // Function to acces the grid
00077   double value(int ix, int iy) const {return _d->value(ix, iy);}
00078   void setValue(int ix, int iy, double val) {return _d->setValue(ix, iy, val);}
00079   double * valuePointer(int ix, int iy) {return _d->valuePointer(ix, iy);}
00080   const double * valuePointer(int ix, int iy) const {return _d->valuePointer(ix, iy);}
00081   QVector<double> x() const {return _d->x();}
00082   QVector<double> y() const {return _d->y();}
00083   double x(int ix) const {return _d->x(ix);}
00084   double y(int iy) const {return _d->y(iy);}
00085   void setX(int ix, double val) {_d->setX(ix,val);}
00086   void setY(int iy, double val) {_d->setY(iy,val);}
00087   inline Point2D coordinates(int ix, int iy) const {return _d->coordinates(ix, iy);}
00088   double minimumValue() const {return _d->minimumValue();}
00089   double maximumValue() const {return _d->maximumValue();}
00090   double minimumValue(int& ix, int& iy) const {return _d->minimumValue(ix, iy);}
00091   double maximumValue(int& ix, int& iy) const {return _d->maximumValue(ix, iy);}
00092   double minimumAxis(AxisType axis) const {return _d->minimumAxis(axis);}
00093   double maximumAxis(AxisType axis) const {return _d->maximumAxis(axis);}
00094   double sum(AxisType along, int index) const {return _d->sum(along, index);}
00095   double mean(AxisType along, int index) const {return _d->mean(along, index);}
00096   double median(AxisType along, int index) const {return _d->median(along, index);}
00097   double mode(AxisType along, int index) const {return _d->mode(along, index);}
00098   double variance(AxisType along, int index) const {return _d->variance(along, index);}
00099   double variance(AxisType along, int index, double average) const {return _d->variance(along, index, average);}
00100   double normalize(AxisType along, int index) {return _d->normalize(along, index);}
00101   void smooth(AxisType along, int index) {_d->smooth(along, index);}
00102   double smoothInvalidCells(AxisType along, int index,
00103                             double invalidValue, double sigma2,
00104                             double RVal, bool modify) {return _d->smoothInvalidCells(along, index, invalidValue, sigma2, RVal, modify);}
00105   void printValues(AxisType along, int index) {_d->printValues(along, index);}
00106 
00107   int indexOfX(double val) const {return _d->indexOfX(val);}
00108   int indexOfY(double val) const {return _d->indexOfY(val);}
00109   /* Get values of a row or a column of the grid as a Curve object
00110       Return a row if along X_Axis, a column if along Y_Axis **/
00111   Curve<Point2D> crossSection(AxisType axis, int ixy) const {return _d->crossSection(axis, ixy);}
00112   Curve<Point2D> crossSection(Segment2D seg, double deltaX=0) const {return _d->crossSection(seg, deltaX);}
00113   Curve<Point2D> crossSection(const Curve<Point2D>& path, double deltaX=0) const {return _d->crossSection(path, deltaX);}
00114   Curve<Point2D> integralCrossSection(AxisType axis,int index) const {
00115      return _d->integralCrossSection(axis, index);
00116   }
00117   template <class CurveClass, class PointClass> CurveClass followMaximumX() const {
00118     return _d->followMaximumX<CurveClass, PointClass>();
00119   }
00120   template <class CurveClass, class PointClass> CurveClass followMaximumX(int ixMin, int ixMax, int iyMax) const {
00121     return _d->followMaximumX<CurveClass, PointClass>(ixMin, ixMax, iyMax);
00122   }
00123   template <class CurveClass, class PointClass> void followMaximumX(CurveClass& curve, double min, double max) const {
00124     return _d->followMaximumX<CurveClass, PointClass>(curve, min, max);
00125   }
00126   template <class CurveClass, class PointClass> CurveClass followMaximumY() const {
00127     return _d->followMaximumY<CurveClass, PointClass>();
00128   }
00129   template <class CurveClass, class PointClass> CurveClass followMaximumY(int iyMin, int iyMax, int ixMax) const {
00130     return _d->followMaximumY<CurveClass, PointClass>(iyMin, iyMax, ixMax);
00131   }
00132   template <class CurveClass, class PointClass> void followMaximumY(CurveClass& curve, double min, double max) const {
00133     return _d->followMaximumY<CurveClass, PointClass>(curve, min, max);
00134   }
00135   // Geometries of cells
00136   double width(int ix) const {return _d->width(ix);}
00137   double height(int iy) const {return _d->height(iy);}
00138   double left(int ix) const {return _d->left(ix);}
00139   double right(int ix) const {return _d->right(ix);}
00140   double bottom(int iy) const {return _d->bottom(iy);}
00141   double top(int iy) const {return _d->top(iy);}
00142 protected:
00143   virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00144   virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00145   virtual XMLMember xml_member(XML_MEMBER_ARGS);
00146   virtual void xml_writeBinaryData(XML_WRITEBINARYDATA_ARGS) const;
00147   virtual bool xml_setBinaryData(XML_SETBINARYDATA_ARGS);
00148   virtual bool xml_setBinaryData200411(XML_SETBINARYDATA_ARGS);
00149 private:
00150   QSharedDataPointer<IrregularGrid2DData> _d;
00151 };
00152 
00153 QGPCORETOOLS_EXPORT QTextStream& operator>>(QTextStream& s, IrregularGrid2D& grd);
00154 QGPCORETOOLS_EXPORT QTextStream& operator<<(QTextStream& s, const IrregularGrid2D& grd);
00155 
00156 } // namespace QGpCoreTools
00157 
00158 #endif // IRREGULARGRID2D.H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines