QGpCoreWave/AutocorrFactory.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreWave.
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 : 2007-02-27
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef AUTOCORRFACTORY_H
00029 #define AUTOCORRFACTORY_H
00030 
00031 #include "Dispersion.h"
00032 #include "ModalFactory.h"
00033 #include "AutocorrRing.h"
00034 #include "QGpCoreWaveDLLExport.h"
00035 
00036 namespace QGpCoreWave {
00037 
00038 class DispersionFactory;
00039 
00040 class QGPCOREWAVE_EXPORT AutocorrFactory : public ModalFactory
00041 {
00042 public:
00043   AutocorrFactory(const QVector<AutocorrRing> * rings);
00044   ~AutocorrFactory();
00045 
00046   int verticalModeCount() const {return maxModeCount(_vertical);}
00047   int horizontalModeCount() const;
00048 
00049   void init();
00050 
00051   bool isVertical() const {return _vertical;}
00052   bool isRadial() const {return _radial;}
00053   bool isTransverse() const {return _transverse;}
00054 
00055   int ringCount() const {return _rings->count();}
00056   ModalStorage& vertical(int ringIndex) const {return *_vertical[ringIndex];}
00057   ModalStorage& radial(int ringIndex) const {return *_radial[ringIndex];}
00058   ModalStorage& transverse(int ringIndex) const {return *_transverse[ringIndex];}
00059 
00060   void calculate(DispersionFactory * disp);
00061   void calculate(double alphaR, DispersionFactory * disp);
00062   void calculateVertical(DispersionFactory * disp);
00063   void calculateHorizontal(double alphaR, DispersionFactory * disp);
00064   void calculateHorizontal(int iOmega, double alphaR, DispersionFactory * disp);
00065   //void setAlpha(const QList<ModalCurve> curves);
00066   //void setHorizontalAutocorr();
00067 
00068   virtual void setMode (const Mode& m);
00069   virtual const RealValue * mode(const Mode& m) const;
00070   virtual int storageCount() const {return _rings->count()*3;}
00071   inline virtual void writeReportHeader(QDataStream& s) const;
00072   inline virtual ModalStorage * storage(int storageIndex) const;
00073 
00074   double radialAutocorr(double omega, double r1, double r2, double alpha, double cr, double cl);
00075   double transverseAutocorr(double omega, double r1, double r2, double alpha, double cr, double cl);
00076 protected:
00077   virtual ModalStorage * newStorage(int nModes) {return new ModalStorage (nModes, x());}
00078   ModalStorage ** newHorizontalStorage();
00079   void upgrade (  ModalStorage **& s, int ringIndex, int requestedMode);
00080 private:
00081   int maxModeCount(ModalStorage ** s) const;
00082   void setInvalid(ModalStorage ** s);
00083 
00084   const QVector<AutocorrRing> * _rings;
00085   ModalStorage ** _vertical;
00086   ModalStorage ** _radial;
00087   ModalStorage ** _transverse;
00088   // internals
00089   int _nVerticalModes;
00090   int _nHorizontalModes;
00091   /*ModalStorage ** _jRR;
00092   ModalStorage ** _jLR;
00093   ModalStorage ** _jRT;
00094   ModalStorage ** _jLT;
00095   RealStatisticalValue ** _alpha;*/
00096 };
00097 
00098 inline void AutocorrFactory::writeReportHeader(QDataStream& s) const
00099 {
00100   TRACE;
00101   s << _rings->count();
00102 }
00103 
00104 inline ModalStorage * AutocorrFactory::storage(int storageIndex) const
00105 {
00106   TRACE;
00107   int iRing=storageIndex/3;
00108   int iComponent=storageIndex-iRing*3;
00109   switch (iComponent) {
00110   case 1:
00111     if(_radial) return _radial[iRing]; else return 0;
00112   case 2:
00113     if(_transverse) return _transverse[iRing]; else return 0;
00114   default:
00115     if(_vertical) return _vertical[iRing]; else return 0;
00116   }
00117 }
00118 
00119 } // namespace QGpCoreWave
00120 
00121 #endif // AUTOCORRFACTORY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines