map_test.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "map.h"
3 #include "harray2d.h"
4 
5 using namespace std;
6 using namespace GMapping;
7 
8 struct SimpleCell{
9  int value;
10  SimpleCell(int v=0){value=v;}
11  static const SimpleCell& Unknown();
13 };
14 
16 
18  if (address)
19  return *address;
20  address=new SimpleCell(-1);
21  return *address;
22 }
23 
25 
26 int main (int argc, char ** argv){
27  CGrid g1(Point(0.,0.), 200, 200, 0.1);
28  CGrid g2(Point(10.,10.), 200, 200, 0.1);
29  {
31  IntPoint pp=g1.world2map(Point(5.1,5.1));
32  cout << pp.x << " " << pp.y << endl;
33  ps.insert(pp);
34  g1.storage().setActiveArea(ps,false);
35  g1.storage().allocActiveArea();
36  g1.cell(Point(5.1,5.1)).value=5;
37  cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
38  g1.resize(-150, -150, 150, 150);
39  cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
40  CGrid g3(g1);
41  g1=g2;
42  }
43  cerr << "copy and modify test" << endl;
44  CGrid *ap,* gp1=new CGrid(Point(0,0), 200, 200, 0.1);
45  CGrid* gp0=new CGrid(*gp1);
46  for (int i=1; i<10; i++){
47  ap=new CGrid(*gp1);
48  delete gp1;
49  gp1=gp0;
50  gp0=ap;
51  IntPoint pp=gp0->world2map(Point(5.1,5.1));
53  ps.insert(pp);
54  gp1->storage().setActiveArea(ps,false);
55  gp1->storage().allocActiveArea();
56  gp1->cell(Point(5.1,5.1)).value=i;
57  cout << "cell value" << (int) gp1->cell(Point(5.1,5.1)).value << endl;
58  }
59  delete gp0;
60  delete gp1;
61  return 0;
62 }
int main(int argc, char **argv)
Definition: map_test.cpp:26
std::set< point< int >, pointcomparator< int > > PointSet
Definition: harray2d.h:13
static const SimpleCell & Unknown()
Definition: map_test.cpp:17
Cell & cell(int x, int y)
Definition: map.h:46
static SimpleCell * address
Definition: map_test.cpp:12
point< double > Point
Definition: point.h:202
int value
Definition: map_test.cpp:9
Map< SimpleCell, HierarchicalArray2D< SimpleCell > > CGrid
Definition: map_test.cpp:24
SimpleCell(int v=0)
Definition: map_test.cpp:10
IntPoint world2map(const Point &p) const
Definition: map.h:179
void resize(double xmin, double ymin, double xmax, double ymax)
Definition: map.h:138
Storage & storage()
Definition: map.h:81


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Mon Jun 10 2019 14:04:22