crsm_map.cpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of CrsmSlam.
00003     CrsmSlam is free software: you can redistribute it and/or modify 
00004     it under the terms of the GNU General Public License as published by
00005     the Free Software Foundation, either version 3 of the License, or
00006     (at your option) any later version.
00007 
00008     CrsmSlam is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011     GNU General Public License for more details.
00012 
00013     You should have received a copy of the GNU General Public License
00014     along with CrsmSlam.  If not, see <http://www.gnu.org/licenses/>.
00015 * 
00016 * Author : Manos Tsardoulias, etsardou@gmail.com
00017 * Organization : AUTH, PANDORA Robotics Team
00018 * */
00019 
00020 #include <crsm_slam/crsm_map.h>
00021 
00022 namespace crsm_slam{
00023 
00028 CrsmMap::CrsmMap(unsigned int size_){
00029         
00030         info.width=size_;
00031         info.height=size_;
00032         
00033         info.originx=size_/2;
00034         info.originy=size_/2;
00035         
00036         p=new unsigned char *[info.width];
00037         for(unsigned int i=0;i<info.width;i++)
00038                 p[i]=new unsigned char [info.height];
00039 
00040         for(unsigned int i=0;i<info.width;i++)
00041                 for(unsigned int j=0;j<info.height;j++)
00042                         p[i][j]=127;
00043 }
00044 
00050 void CrsmMap::expandMap(CrsmExpansion expansion){
00051         
00052         
00053         
00054         int newOriginx=info.originx+expansion.expansions[LEFT];
00055         int newOriginy=info.originy+expansion.expansions[UP];
00056         
00057         int newWidth=info.width+expansion.expansions[LEFT]+expansion.expansions[RIGHT];
00058         int newHeight=info.height+expansion.expansions[UP]+expansion.expansions[DOWN];
00059         
00060         unsigned char ** newMap;
00061         newMap=new unsigned char *[newWidth];
00062         for(unsigned int i=0;i<newWidth;i++)
00063                 newMap[i]=new unsigned char[newHeight];
00064         for(unsigned int i=0;i<newWidth;i++)
00065                 for(unsigned int j=0;j<newHeight;j++)
00066                         newMap[i][j]=127;
00067         
00068         for(unsigned int i=0;i<info.width;i++)
00069                 for(unsigned int j=0;j<info.height;j++)
00070                         newMap[i+expansion.expansions[LEFT]][j+expansion.expansions[UP]]=p[i][j];
00071                         
00072         for(unsigned int i=0;i<info.width;i++)
00073                 delete [] p[i];
00074         delete [] p;
00075 
00076         p=newMap;
00077         info.width=newWidth;
00078         info.height=newHeight;
00079         
00080         info.originx=newOriginx;
00081         info.originy=newOriginy;
00082 }
00083 
00084 }


crsm_slam
Author(s): Manos Tsardoulias
autogenerated on Thu Aug 27 2015 12:54:13