CGR Localization
 All Classes Namespaces Files Functions Variables Macros Pages
vector_map.h
Go to the documentation of this file.
1 //========================================================================
2 // This software is free: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License Version 3,
4 // as published by the Free Software Foundation.
5 //
6 // This software is distributed in the hope that it will be useful,
7 // but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 // GNU Lesser General Public License for more details.
10 //
11 // You should have received a copy of the GNU Lesser General Public License
12 // Version 3 in the file COPYING that came with this distribution.
13 // If not, see <http://www.gnu.org/licenses/>.
14 //========================================================================
20 //========================================================================
21 
22 #include <vector>
23 #include <fstream>
24 #include <algorithm>
25 #include <string>
26 
27 #include "geometry.h"
28 #include "line.h"
29 #include "triangle.h"
30 #include "terminal_utils.h"
31 #include "timer.h"
32 #include <eigen3/Eigen/Eigen>
33 
34 #ifndef VECTOR_MAP_H
35 #define VECTOR_MAP_H
36 
37 using namespace std;
38 
39 class VectorMap{
40 
41 public:
42  typedef struct {
43  double a0;
44  double a1;
45  int index;
46  vector2f v0;
47  vector2f v1;
48  } LineSegment;
49 
50  vector<line2f> lines;
51 
52  double vectorScale, vectorOriginX, vectorOriginY, vectorRotation;
53  bool vectorFlipY;
54  string mapName;
55  string mapsFolder;
56 
58  float minX, minY, maxX, maxY;
62  unsigned int visListWidth, visListHeight;
63  bool preRenderExists;
64  double profileTimes[100];
65 private:
66  vector<vector<vector<int> > > visibilityList;
67 
68 public:
69  VectorMap(const char* _mapsFolder){lines.clear(); mapsFolder=string(_mapsFolder);}
70  VectorMap(const char *name, const char* _mapsFolder, bool usePreRender);
71  ~VectorMap();
72 
73  vector<LineSegment> sortLineSegments(vector2f &loc, vector<line2f> &lines);
74 
76  int getLineCorrespondence(vector2f loc, float angle, float minRange, float maxRange, const std::vector< int >& visibilityList);
78  vector<int> getRayToLineCorrespondences(vector2f loc, float angle, float a0, float a1, const std::vector< vector2f > pointCloud, float minRange, float maxRange, bool analytical = false, vector< line2f >* lines = 0);
80  vector<int> getRayToLineCorrespondences(vector2f loc, float a0, float a1, float da, float minRange, float maxRange);
82  vector<int> getRayToLineCorrespondences(vector2f loc, float angle, float da, int numRays, float minRange, float maxRange, bool analytical = false, vector< line2f >* lines = 0);
84  vector<float> getRayCast(vector2f loc, float angle, float da, int numRays, float minRange, float maxRange);
86  void trimOcclusion(vector2f &loc, line2f &line1, line2f &line2, vector<line2f> &sceneLines);
87  void trimOcclusion2(vector2f& loc_g, line2f& line1, line2f& line2, vector<line2f>& sceneLines);
89  vector<int> getSceneLines(vector2f loc, float maxRange);
91  bool loadMap(const char* name, bool usePreRender);
93  vector<int>* getVisibilityList(float x, float y);
94  vector<int>* getVisibilityList(vector2f loc){ return getVisibilityList(loc.x, loc.y); }
96  vector<line2f> sceneRender(vector2f loc, float a0=0.0, float a1=M_2PI);
97 };
98 
99 #endif //VECTOR_MAP_H
Subroutines to spice up stdout.
unsigned int visListWidth
size of the visibilityList array
Definition: vector_map.h:62
Definition: line.h:33
C++ Interfaces: Triangle3d.
float minX
Map Extents.
Definition: vector_map.h:58
double visListResolution
number of meters per cell in visibilityList array
Definition: vector_map.h:60
C++ Interfaces: Line2d.