n-Dimensional Fast Methods  0.7
 All Classes Functions Variables Typedefs Pages
test_fmm3d.cpp
1 /* An example to run FMM on a 3D grid loaded from a given text file. */
2 
3 #include <iostream>
4 #include <array>
5 
6 #include <fast_methods/ndgridmap/fmcell.h>
7 #include <fast_methods/ndgridmap/ndgridmap.hpp>
8 
9 #include <fast_methods/fm/fmm.hpp>
10 #include <fast_methods/io/maploader.hpp>
11 #include <fast_methods/io/gridwriter.hpp>
12 
13 using namespace std;
14 using namespace std::chrono;
15 
16 int main(int argc, char **argv)
17 {
18  // A bit of shorthand.
19  typedef nDGridMap<FMCell, 3> FMGrid3D;
20  typedef array<unsigned int, 3> Coord3D;
21 
22  // Grid, start and goal definition.
23  FMGrid3D grid_fmm;
24  MapLoader::loadMapFromText(argv[1], grid_fmm);
25  Coord3D init_point = {5, 5, 5};
26 
27  // Solvers declaration.
28  std::vector<Solver<FMGrid3D>*> solvers;
29  solvers.push_back(new FMM<FMGrid3D>);
30 
31  // Executing every solver individually over the same grid.
32  for (Solver<FMGrid3D>* s :solvers)
33  {
34  s->setEnvironment(&grid_fmm);
35  s->setInitialPoints(init_point);
36  s->compute();
37  cout << "\tElapsed "<< s->getName() <<" time: " << s->getTime() << " ms" << '\n';
38  GridWriter::saveGridValues("3dresult.grid", grid_fmm);
39  }
40 
41  return 0;
42 }
static void saveGridValues(const char *filename, nDGridMap< T, ndims > &grid)
Saves grid values in ASCII format into the specified file.
Definition: gridwriter.hpp:48
Templated class which represents a n-dimensional grid map. Its cells are assumed to be cubic...
Definition: ndgridmap.hpp:47
static int loadMapFromText(const char *filename, nDGridMap< T, ndims > &grid)
Loads the initial binary map for a given grid. It is based on the nDGridMap::setOccupancy() which has...
Definition: maploader.hpp:96
Abstract class that serves as interface for the actual solvers implemented. It requires (at least) th...
Definition: solver.hpp:40
Implements the Fast Marching Method (FMM).
Definition: fmm.hpp:64