DinverDCCore/DCModelInfo.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of DinverDCCore.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
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 General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2006-05-17
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef DCMODELINFO_H
00028 #define DCMODELINFO_H
00029 
00030 #include <DinverCore.h>
00031 #include <QGpCoreTools.h>
00032 #include "DinverDCCoreDLLExport.h"
00033 
00034 namespace DinverDCCore {
00035 
00036 class DINVERDCCORE_EXPORT DCModelInfo : public SharedObject
00037 {
00038 public:
00039   DCModelInfo() {_report=0;_samples=0;}
00040   ~DCModelInfo()
00041   {
00042     ReportReader::removeReference(_report);
00043     delete [] _samples;
00044   }
00045 
00046   void setCurveCount(int n) {delete [] _samples; if(n>0) _samples=new Curve[n]; else _samples=0;}
00047 
00048   void setReport(ReportReader * r) {_report=r;_report->addReference();}
00049   void setIndexInReport(int i) {_indexInReport=i;}
00050   void setMisfit(double m) {_misfit=m;}
00051   void setOffset(int curveIndex, int offset) {_samples[ curveIndex ].offset=offset;}
00052   void setSampleCount(int curveIndex, int nSamples) {_samples[ curveIndex ].nSamples=nSamples;}
00053 
00054   ReportReader * report() const {return _report;}
00055   int indexInReport() const {return _indexInReport;}
00056   double misfit() const {return _misfit;}
00057   int offset(int curveIndex) const {return _samples[ curveIndex ].offset;}
00058   int sampleCount(int curveIndex) const {return _samples[ curveIndex ].nSamples;}
00059 
00060   // The sign is reversed to sort by decreasing misfit
00061   static bool misfitLessThan(const DCModelInfo * i1, const DCModelInfo * i2)
00062   {
00063     /* When dealing with minimum misfit reports, there are a lot of models
00064        with the same misfit. Hence this is condition does not ensure a unique
00065        order of a list of models. The model index is added to have a unique order. */
00066     if(i1->_misfit>i2->_misfit) return true;
00067     else if (i1->_misfit<i2->_misfit) return false;
00068     else {
00069       if(i1->_indexInReport<i2->_indexInReport) return true;
00070       else return false;
00071     }
00072   }
00073   static bool loadLessThan(const DCModelInfo * i1, const DCModelInfo * i2)
00074   {
00075     if(i1->_report < i2->_report) return true;
00076     else if(i1->_report > i2->_report) return false;
00077     else {
00078       if(i1->_indexInReport < i2->_indexInReport) return true;
00079       else return false;
00080     }
00081   }
00082 private:
00083   ReportReader * _report;
00084   int _indexInReport;
00085   double _misfit;
00086   struct Curve {
00087     int nSamples, offset;
00088   };
00089   Curve * _samples;
00090 };
00091 
00092 } // namespace DinverDCCore
00093 
00094 #endif // DCMODELINFO_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines