00001 // Author Antonio Bulgheroni, <mailto:antonio.bulgheroni@gmail.com> 00002 // Copyright 2009 Antonio Bulgheroni 00003 00004 // $Rev:: 7 $: Revision of the last commit 00005 // $Author:: drhilbert $: Author of the last commit 00006 // $Date:: 2009-08-27 00:08:23 +0200 (Thu, 27 Aug 2009) $: Date of the last commit 00007 00008 // This file is part of Mimotera++. 00009 // 00010 // Mimotera++ is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // Mimotera++ is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with Mimotera++. If not, see <http://www.gnu.org/licenses/>. 00022 00023 00024 #include "mimotera++/MimoteraDecoder.hh" 00025 #include "mimotera++/MimoteraException.hh" 00026 00027 // system include 00028 #include <algorithm> 00029 00030 using namespace std; 00031 using namespace Mimotera; 00032 00033 void MimoteraDecoder::getXY(size_t rawPos, Coord_t & x, Coord_t & y ) { 00034 00035 if ( ( rawPos % kChanWidth) >= (kChanWidth - kMarkersPerRow) ) { 00036 MIMOTERA_THROWX( MarkerPixelException, "Marker pixel" ); 00037 } 00038 00039 x = ( rawPos % kChanWidth ) + (kChanWidth - kMarkersPerRow) * kLookUp[ ( rawPos * kChan ) / ( kXPixel * kYPixel ) ]; 00040 y = ( (rawPos / kChanWidth) % kYPixel); 00041 00042 } 00043 00044 size_t MimoteraDecoder::getRawPosition( Coord_t x, Coord_t y ) { 00045 00046 size_t quarterBefore = find( &kLookUp[0], &kLookUp[3], x / ( kChanWidth - kMarkersPerRow ) ) - kLookUp; 00047 size_t fullQuarter = quarterBefore * ( kChanWidth * kYPixel ); 00048 size_t fullRow = y * kChanWidth; 00049 size_t xPrime = x % ( kChanWidth - kMarkersPerRow ) ; 00050 return fullQuarter + fullRow + xPrime; 00051 00052 }