Go to the documentation of this file.00001
00008
00009
00010
00011 #include <iostream>
00012 #include <gtest/gtest.h>
00013 #include <ecl/linear_algebra.hpp>
00014 #include <ecl/formatters/floats.hpp>
00015 #include "../../include/ecl/maps/grid_map.hpp"
00016
00017
00018
00019
00020
00021 using std::cout;
00022 using std::endl;
00023 using ecl::RightAlign;
00024 using ecl::Format;
00025 using ecl::GridMap;
00026 using ecl::linear_algebra::Vector2d;
00027 using ecl::linear_algebra::Vector2i;
00028
00029
00030
00031
00032
00033 namespace ecl {
00034 namespace maps {
00035 namespace tests {
00036
00037
00038
00039
00040
00041 class Cell {
00042 public:
00043 Cell() : i(0), j(0) {};
00044 unsigned int i;
00045 unsigned int j;
00046 };
00047
00048
00049 }
00050 }
00051 }
00052
00053
00054
00055
00056
00057 using ecl::maps::tests::Cell;
00058
00059
00060
00061
00062
00063 TEST(GridMapTests,allEggsInOneBasket) {
00064
00065 SUCCEED();
00066 }
00067
00068
00069
00070
00071 int main(int argc, char **argv) {
00072
00073 Format<double> format; format.width(8); format.precision(2); format.align(RightAlign);
00074
00075 cout << endl;
00076 cout << "***********************************************************" << endl;
00077 cout << " Construction" << endl;
00078 cout << "***********************************************************" << endl;
00079 cout << endl;
00080
00081 std::cout << "Creating a 5x5 grid map over the world area [0.0,0.0]->[10.0,10.0]" << std::endl;
00082 GridMap<Cell,5,5> map(0.0,0.0,2.0);
00083
00084 typedef GridMap<Cell,5,5> Map;
00085
00086 cout << endl;
00087 cout << "***********************************************************" << endl;
00088 cout << " Iteration" << endl;
00089 cout << "***********************************************************" << endl;
00090 cout << endl;
00091
00092 Map::iterator iter;
00093 int i = 0;
00094 int j = 0;
00095 for ( iter = map.begin(); iter != map.end(); ++iter ) {
00096 iter->i = i; iter->j = j;
00097 ++j;
00098 if ( j == map.cols() ) {
00099 j = 0;
00100 ++i;
00101 }
00102 }
00103 Map::const_iterator const_iter;
00104 std::cout << std::endl;
00105 for ( const_iter = map.begin(); const_iter != map.end(); ++const_iter ) {
00106 std::cout << "[" << const_iter->i << "," << const_iter->j << "]" << std::endl;
00107 }
00108 std::cout << std::endl;
00109
00110 std::cout << "Front: " << "[" << map.front().i << "," << map.front().j << "]" << std::endl;
00111 std::cout << "Back: " << "[" << map.back().i << "," << map.back().j << "]" << std::endl;
00112 std::cout << std::endl;
00113
00114 for ( j = map.rows(); j > 0; --j ) {
00115 unsigned int index = j - 1;
00116 for ( i = 0; i < map.cols(); ++i ) {
00117 std::cout << "[" << map(i,index).i << "," << map(i,index).j << "]";
00118 }
00119 std::cout << std::endl;
00120 }
00121 std::cout << std::endl;
00122
00123 cout << endl;
00124 cout << "***********************************************************" << endl;
00125 cout << " Transform" << endl;
00126 cout << "***********************************************************" << endl;
00127 cout << endl;
00128
00129 Vector2i cell_coords = map.cellCoordinates(1.5,2.3);
00130 std::cout << "Cell coordinates [1.5,2.3]->[" << cell_coords[0] << "," << cell_coords[1] << "]" << std::endl;
00131
00132 Vector2d world_coords = map.worldCoordinates(2,3);
00133 std::cout << "World coordinates [2,3] ->[" << world_coords[0] << "," << world_coords[1] << "]" << std::endl;
00134
00135 cout << endl;
00136 cout << "***********************************************************" << endl;
00137 cout << " Passed" << endl;
00138 cout << "***********************************************************" << endl;
00139 cout << endl;
00140
00141 testing::InitGoogleTest(&argc,argv);
00142 return RUN_ALL_TESTS();
00143 }
00144
00145