map_test.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "map.h"
00003 #include "harray2d.h"
00004 
00005 using namespace std;
00006 using namespace GMapping;
00007 
00008 struct SimpleCell{
00009         int value;
00010         SimpleCell(int v=0){value=v;}
00011         static const SimpleCell& Unknown();
00012         static SimpleCell* address;
00013 };
00014 
00015 SimpleCell* SimpleCell::address=0;
00016 
00017 const SimpleCell& SimpleCell::Unknown(){
00018         if (address)
00019                 return *address;
00020         address=new SimpleCell(-1);
00021         return *address;
00022 }
00023 
00024 typedef Map< SimpleCell, HierarchicalArray2D<SimpleCell> > CGrid;
00025 
00026 int main (int argc, char ** argv){
00027         CGrid g1(Point(0.,0.), 200, 200, 0.1);
00028         CGrid g2(Point(10.,10.), 200, 200, 0.1);
00029         {
00030                 HierarchicalArray2D<SimpleCell>::PointSet ps;
00031                 IntPoint pp=g1.world2map(Point(5.1,5.1));
00032                 cout << pp.x << " " << pp.y << endl;
00033                 ps.insert(pp);
00034                 g1.storage().setActiveArea(ps,false);
00035                 g1.storage().allocActiveArea();
00036                 g1.cell(Point(5.1,5.1)).value=5;
00037                 cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
00038                 g1.resize(-150, -150, 150, 150);
00039                 cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
00040                 CGrid g3(g1);
00041                 g1=g2;
00042         }
00043         cerr << "copy and modify test" << endl;
00044         CGrid *ap,* gp1=new CGrid(Point(0,0), 200, 200, 0.1);
00045         CGrid* gp0=new CGrid(*gp1);
00046         for (int i=1; i<10; i++){
00047           ap=new CGrid(*gp1);
00048           delete gp1;
00049           gp1=gp0;
00050           gp0=ap;
00051           IntPoint pp=gp0->world2map(Point(5.1,5.1));
00052           HierarchicalArray2D<SimpleCell>::PointSet ps;
00053           ps.insert(pp);
00054           gp1->storage().setActiveArea(ps,false);       
00055           gp1->storage().allocActiveArea();
00056           gp1->cell(Point(5.1,5.1)).value=i;
00057           cout << "cell value" << (int) gp1->cell(Point(5.1,5.1)).value << endl;
00058         }
00059         delete gp0;
00060         delete gp1;
00061         return 0;
00062 }


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Thu Jun 6 2019 19:25:13