00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 ;
00103
00104 template < typename MapType >
00105 void MapDewarper<MapType>::dewarp()
00106 {
00107
00108 typename MapType::iterator feat_iter = elements_.begin();
00109 while (feat_iter != elements_.end() )
00110 {
00111
00112
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
00120 for (unsigned int i=0; i < 2; i++)
00121 {
00122 DoubleReal temp;
00123 temp = pos[i];
00124
00125 grid_iter->getMappings().at(i).apply(temp);
00126 pos[i] = temp;
00127 }
00128 feat_iter->setPosition(pos);
00129 }
00130 grid_iter++;
00131
00132 }
00133
00134 feat_iter++;
00135 }
00136 }
00137 }
00138
00139 #endif // OPENMS_ANALYSIS_MAPMATCHER_MAPDEWARPER_H