Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

MapDewarper.h (Maintainer: Eva Lange)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Eva Lange $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_ANALYSIS_MAPMATCHING_MAPDEWARPER_H
00028 #define OPENMS_ANALYSIS_MAPMATCHING_MAPDEWARPER_H
00029 
00030 #include<OpenMS/ANALYSIS/MAPMATCHING/Grid.h>
00031 
00032 #include<OpenMS/KERNEL/FeatureMap.h>
00033 #include<vector>
00034 
00035 namespace OpenMS
00036 {
00037 
00043   template < typename MapType = FeatureMap< Feature > >
00044   class MapDewarper
00045   {
00046   public:
00047 
00049     MapDewarper()
00050         : grid_(), elements_()
00051     {}
00052 
00054     virtual ~MapDewarper()
00055     {}
00056 
00058     void dewarp();
00059 
00063 
00064     inline void setGrid(Grid& g)
00065     {
00066       grid_ = g;
00067     }
00069     inline Grid& getGrid()
00070     {
00071       return grid_;
00072     }
00074     inline const Grid& getGrid() const
00075     {
00076       return grid_;
00077     }
00079     inline void setMap(MapType& elem)
00080     {
00081       elements_ = elem;
00082     }
00084     inline MapType& getMap()
00085     {
00086       return elements_;
00087     }
00089     inline const MapType& getMap() const
00090     {
00091       return elements_;
00092     }
00094 
00095   protected:
00097     Grid grid_;
00098 
00100     MapType elements_;
00101   }
00102   ; // end of class MapDewarper
00103 
00104   template < typename MapType >
00105   void MapDewarper<MapType>::dewarp()
00106   {
00107     // iterate over all elements...
00108     typename MapType::iterator feat_iter = elements_.begin();
00109     while (feat_iter != elements_.end() )
00110     {
00111       // Test in which cell this feature is included
00112       // and apply the corresponding transformation
00113       typename Grid::iterator grid_iter = grid_.begin();
00114       while (grid_iter != grid_.end() )
00115       {
00116         if (grid_iter->encloses(feat_iter->getPosition() ) )
00117         {
00118           DPosition<2> pos = feat_iter->getPosition();
00119           // apply transform for every coordinate
00120           for (unsigned int i=0; i < 2; i++)
00121           {
00122             DoubleReal temp;
00123             temp = pos[i];
00124             //std::cout << "Retrieving mapping " << i << std::endl;
00125             grid_iter->getMappings().at(i).apply(temp);
00126             pos[i] = temp;
00127           }
00128           feat_iter->setPosition(pos);
00129         }
00130         grid_iter++;
00131 
00132       } // end while (grid)
00133 
00134       feat_iter++;
00135     }
00136   }// end while (features)
00137 } // end of namespace OpenMS
00138 
00139 #endif  // OPENMS_ANALYSIS_MAPMATCHER_MAPDEWARPER_H

Generated Tue Apr 1 15:36:35 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1