DinverCore/VoronoiNavigator.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of DinverCore.
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 : 2009-05-06
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef VORONOINAVIGATOR_H
00028 #define VORONOINAVIGATOR_H
00029 
00030 #include <QGpCoreTools.h>
00031 #include "DinverCoreDLLExport.h"
00032 #include "ScaledModels.h"
00033 #include "PdfCurve.h"
00034 #include "Model.h"
00035 
00036 namespace DinverCore {
00037 
00038 class DINVERCORE_EXPORT VoronoiNavigator
00039 {
00040   TRANSLATIONS("VoronoiNavigator")
00041 public:
00042   VoronoiNavigator(const ScaledModels * m);
00043   ~VoronoiNavigator();
00044 
00045   void cellLimits(int& xMin, int &xMax, int& iMin, int& iMax);
00046   PdfCurve intersections(double xMinLimit, double xMaxLimit);
00047 
00048   inline void setCurrentPoint(int index);
00049   inline void setCurrentPoint(const int * coordinates);
00050 
00051   int currentCell() const {return _currentCell;}
00052   QVector<int> cellAt(const int * p) const;
00053   QVector<int> cellAt(const double * p) const;
00054   int cellCount() const {return _cells->modelCount();}
00055 
00056   void setCurrentAxis(int a);
00057   void incrementAxis();
00058   int currentAxis() const {return _currentAxis;}
00059 
00060   void setValue(int v) {_currentPoint[ _currentAxis ]=v * _cells->scale(_currentAxis);}
00061   void setValue(double v) {_currentPoint[ _currentAxis ]=v * _cells->scale(_currentAxis);}
00062   void setCurrentCell(int index) {_currentCell=index;}
00063 
00064   void checkAxisDistances();
00065   void printCurrentPoint();
00066   void checkCurrentPoint();
00067 private:
00068   void setCell(int * cells, int nCells);
00069   void lowerIntersections(PdfCurve& f, double xMinLimit, int * cells, int nCells, double invS2);
00070   void higherIntersections(PdfCurve& f, double xMaxLimit, int * cells, int nCells, double invS2);
00071 
00072   const ScaledModels * _cells;
00073 
00074   int _currentAxis;
00075   int _currentCell;
00076   double * _currentPoint;
00077 
00078   double * _axisDistances;
00079 };
00080 
00081 inline void VoronoiNavigator::setCurrentPoint(int index)
00082 {
00083   TRACE;
00084   _currentCell=index;
00085   int nd=_cells->parameterCount();
00086   for(int id=0; id < nd; id++ ) {
00087     _currentPoint[ id ]=_cells->v(id)[_currentCell];
00088   }
00089 }
00090 
00091 inline void VoronoiNavigator::setCurrentPoint(const int * coordinates)
00092 {
00093   TRACE;
00094   _currentCell=-1;
00095   int nd=_cells->parameterCount();
00096   for(int id=0; id < nd; id++ ) {
00097     _currentPoint[ id ]=_cells->scale(id) * coordinates[id];
00098   }
00099 }
00100 
00101 } // namespace DinverCore
00102 
00103 #endif // VORONOINAVIGATOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines